【问题标题】:Logstash output is from another inputLogstash 输出来自另一个输入
【发布时间】:2019-09-09 01:52:06
【问题描述】:

我有一个问题,我的节拍度量被我的 http 管道捕获。

Logstash、Elastic 和 Metricbeat 都在 Kubernetes 中运行。

我的 beatmetric 设置为发送到端口 5044 上的 Logstash 并记录到 /tmp 中的文件。这工作正常。但是,每当我创建一个带有http 输入的管道时,这似乎 捕获beatmetric 输入并将它们发送到http 管道中定义的Elastic 中的index2

为什么会这样?

/usr/share/logstash/pipeline/http.conf

input {
  http {
    port => "8080"
  }
}

output {

  #stdout { codec => rubydebug }

  elasticsearch {

    hosts => ["http://my-host.com:9200"]
    index => "test2"
  }
}

/usr/share/logstash/pipeline/beats.conf

input {
    beats {
        port => "5044"
    }
}

output {
    file {
        path => '/tmp/beats.log'
        codec => "json"
    }
}

/usr/share/logstash/config/logstash.yml

pipeline.id: main
pipeline.workers: 1
pipeline.batch.size: 125
pipeline.batch.delay: 50
http.host: "0.0.0.0"
http.port: 9600
config.reload.automatic: true
config.reload.interval: 3s

/usr/share/logstash/config/pipeline.yml

- pipeline.id: main
  path.config: "/usr/share/logstash/pipeline"

【问题讨论】:

  • 你是如何启动logstash的?您是否使用多个管道和 pipelines.yml 配置?
  • 更新了我的问题。基本上 pipeline.yml 指向一个包含两个 conf 文件的管道目录。一切都在 Kubernetes 中运行(因此通过 docker 镜像自动启动)。

标签: kubernetes logstash pipeline metricbeat


【解决方案1】:

即使您有多个配置文件,logstash 也会将它们作为单个管道读取,将输入、过滤器和输出连接起来,如果您需要作为单独的管道运行,那么您有两个选项。

更改您的pipelines.yml 并创建不同的pipeline.id,每个都指向一个配置文件。

- pipeline.id: beats
  path.config: "/usr/share/logstash/pipeline/beats.conf"
- pipeline.id: http
  path.config: "/usr/share/logstash/pipeline/http.conf"

或者您可以在inputfilteroutput 中使用tags,例如:

input {
  http {
    port => "8080"
    tags => ["http"]
  }
  beats {
    port => "5044"
    tags => ["beats"]
  }
}
output {
 if "http" in [tags] {
      elasticsearch {
        hosts => ["http://my-host.com:9200"]
        index => "test2"
      }
  }
 if "beats" in [tags] {
      file {
        path => '/tmp/beats.log'
        codec => "json"
      }
  }
}

使用pipelines.yml 文件是运行multiple pipelines 的推荐方式

【讨论】:

  • 有道理。这对我来说是缺失的部分。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多