Logstash 输出来自另一个输入

Logstash output is from another input

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

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

我的 beatmetric 设置为发送到端口 5044 上的 Logstash 并记录到 /tmp 中的文件。这很好用。但是每当我创建一个带有 http 输入的管道时,这似乎 捕获节拍输入并将它们发送到 Elastic 中的 index2,如 [=14] 中定义的=] 管道。

为什么会这样?

/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.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

的推荐方式