0

我有一个问题,我的 beatmetric 被我的 http 管道捕获。

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

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

为什么它会这样?

/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"
4

1 回答 1

3

即使您有多个配置文件,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"

或者您可以tags在您的input,filter和中使用output,例如:

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的推荐方式

于 2019-04-18T18:44:35.280 回答