fluent / fluent-plugin-prometheus

A fluent plugin that collects metrics and exposes for Prometheus.
Apache License 2.0
258 stars 79 forks source link

Allow environment variables in labels #128

Closed dawidrabiega closed 4 years ago

dawidrabiega commented 4 years ago

Hey, I need to pass value of environment variable to label value. In my case it's nodeName defined as:

    env:
    - name: NODE_NAME
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: spec.nodeName

I would use it in source:

<source>
  @type prometheus_monitor
  <labels>
    node #{ENV['NODE_NAME']}
  </labels>
</source>

Currently it seems, that it's not expanded.

repeatedly commented 4 years ago

Wrap the parameter with ". See official document: https://docs.fluentd.org/configuration/config-file#embedded-ruby-code

dawidrabiega commented 4 years ago

Thanks, It works like a harm!

Correct version:

<source>
  @type prometheus_monitor
  <labels>
    node "#{ENV['NODE_NAME']}"
  </labels>
</source>
ganmacs commented 4 years ago

I'm closing this issue. feel free to ask any questions.