如何使用由 Docker 和 Compose 提供支持的 Elastic stack (ELK) 在 logstash 中 运行 多管道

How to run multi pipeline in logstash using The Elastic stack (ELK) powered by Docker and Compose

我正在使用 this_repo 开始使用 运行宁 ELK 与 Docker。

我的问题是关于 docker-compose 文件中的 logstash 映像:

当我 运行 在本地时,我有 3 个文件

#general settings
logstash.yml
#pipeline setting
pipeline.yml
#a pipe line configuration
myconf.conf1

当我想使用多管道时,我使用 pipeline.yml 文件来控制所有不同的管道,我正在 运行ning

# Example of my pipeline.yml
- pipeline.id: my-first-pipeline
  path.config: "/etc/logstash/my-first-pipeline.config"
  pipeline.workers: 2
- pipeline.id: super-swell-pipeline
  path.config: "/etc/logstash/super-swell-pipeline.config"
  queue.type: persisted

在我用作指南的回购中我只能找到 logstash.yml 而且我不明白如何添加管道。 唯一的 运行ning 管道是默认的 "main",默认情况下只有 运行 logstash.conf 我尝试了不同的配置,所有字段

如何将 pipeline.yml 添加到 docker? 或者最佳做法是什么 运行 使用此 docker-compose 文件设置多个管道?

感谢任何帮助

docker-compose/logstash 形成回购:

  logstash:
    build:
      context: logstash/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./logstash/config/logstash.yml
        target: /usr/share/logstash/config/logstash.yml
        read_only: true
      - type: bind
        #can be either a host path or volume name.
        source: ./logstash/pipeline
        #is the container path where the volume is mounted
        target: /usr/share/logstash/pipeline
        read_only: true
    ports:
      - "5000:5000/tcp"
      - "5000:5000/udp"
      - "9600:9600"
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      - elk
    depends_on:
      - elasticsearch

Docker文件:

ARG ELK_VERSION

# https://www.docker.elastic.co/
FROM docker.elastic.co/logstash/logstash:${ELK_VERSION}

# Add your logstash plugins setup here
# Example: RUN logstash-plugin install logstash-filter-json

logstash.yml

## Default Logstash configuration from Logstash base image.
## https://github.com/elastic/logstash/blob/master/docker/data/logstash/config/logstash-full.yml
#
http.host: "0.0.0.0"
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]

## X-Pack security credentials
#
xpack.monitoring.enabled: false
xpack.monitoring.elasticsearch.username: elastic
xpack.monitoring.elasticsearch.password: changeme

您还需要将 pipelines.yml 文件装载到容器中。 Logstash 正在寻找可能的 pipelines.yml 文件的默认位置是 /usr/share/logstash/config/(您已经将 logstash.yml 文件安装到的同一文件夹)。

请注意,您还必须将当前的本地 pipelines.yml 文件更新为容器 容器内 管道的正确路径。准确的说,你需要改变

path.config: "/etc/logstash/my-first-pipeline.config"

path.config: "/usr/share/logstash/pipeline/my-first-pipeline.config"

此外,请查看 运行 Logstash 与 Docker 以及如何配置多个管道的官方指南:

希望能帮到你!

编辑:

官方文档调用文件pipelines.yml而不是pipeline.yml