【问题标题】:Google fluentd - using env variables in labelsGoogle fluentd - 在标签中使用环境变量
【发布时间】:2020-09-17 02:21:34
【问题描述】:

我正在尝试在 google-fluentd 的配置文件中添加标签。根据文档https://cloud.google.com/logging/docs/agent/configuration#label-setup,它声明labels 用于静态标签。但是,有什么方法可以将环境变量作为值添加到这些标签中?

...
<match **>
  @type google_cloud
  # Adding labels to the log metadata
  labels {
    "source": "transform",
    "transformId": "\"#{ENV['TRANSFORM_ID']}\""
  }
  buffer_type file
  buffer_path /var/log/google-fluentd/buffers
...

在上面的代码中,sn-p 指的是主要的/etc/google-fluentd/google-fluentd.conf 文件。静态标签source: transform 被添加到日志中,但是从env variable 获取值的transformId 不起作用。

【问题讨论】:

    标签: logging environment-variables fluentd stackdriver


    【解决方案1】:

    我通过以下方式得到了这个工作: labels "#{ENV['LABEL_JSON']}"

    然后传递 env 变量 - 键值对,如 "LABEL_JSON": "{\"TRANSFORM_ID\": \"transformId\", \"TRANSFORM_NAME\": \"jane\"}"

    【讨论】:

      猜你喜欢
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2021-02-13
      • 2019-04-17
      相关资源
      最近更新 更多