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

hel*_*per 0 logstash docker docker-compose elastic-stack

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

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

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

#general settings
logstash.yml
#pipeline setting
pipeline.yml
#a pipe line configuration
myconf.conf1
Run Code Online (Sandbox Code Playgroud)

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

# 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
Run Code Online (Sandbox Code Playgroud)

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

如何将 pipeline.yml 添加到 docker?或者使用这个 docker-compose 文件运行多管道的最佳实践是什么?

感谢任何帮助

docker-compose/logstash 形成 repo:

  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
Run Code Online (Sandbox Code Playgroud)

文件:

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
Run Code Online (Sandbox Code Playgroud)

日志文件

## 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
Run Code Online (Sandbox Code Playgroud)

小智 5

您还需要将 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"

另外,请查看这些使用 Docker 运行 Logstash 的官方指南以及如何配置多个管道:

我希望我能帮到你!

编辑:

官方单证调用文件管道小号.yml代替pipeline.yml的