gpt4 book ai didi

docker - 如何在 filebeat.yml 文件中使用变量

转载 作者:行者123 更新时间:2023-12-02 19:27:02 25 4
gpt4 key购买 nike

我在 filebeat.yml 中使用环境变量,它无法解析变量。

文件beat.yml

 output.elasticsearch:
hosts: [$ELASTICSEARCH_HOST]
template:
name: "filebeat"
path: "fields.yml"
overwrite: false
protocol: "http"

docker-compose.yml

  version: "3.5"

services:

filebeat:
build:
context: ./filebeat
args:
ELK_VERSION: $ELK_VERSION
volumes:
- "/var/lib/docker/containers:/usr/share/dockerlogs/data:ro"
- "/var/run/docker.sock:/var/run/docker.sock"

networks:
default:
name: filebeat-nw
external: true

我将变量 $ELASTICSEARCH_HOST 导出到环境变量。但是它无法解析文档。

我使用命令“docker-compose up --build”将容器作为服务运行

我想了解如何在 filebeat.yml 文件中使用环境变量。

谢谢。

最佳答案

Each variable reference is replaced at startup by the value of the environment variable. The replacement is case-sensitive and occurs before the YAML file is parsed. References to undefined variables are replaced by empty strings unless you specify a default value. To specify a default value, use:

${VAR:default_value}

完整文档为 here

关于docker - 如何在 filebeat.yml 文件中使用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55356397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com