ricoberger / script_exporter

Prometheus exporter to execute scripts and collect metrics from the output or the exit status.
MIT License
354 stars 82 forks source link

env: expects list of strings, not a map. #80

Closed gacerioni closed 1 year ago

gacerioni commented 1 year ago

Howdy, Rico!

I have a sensitive pwd that I'd like to provide via env vars.

I tried to follow this snippet as an example:

scripts:
  - name: test_env
    command: /tmp/my_script.sh
    env:
      http_proxy: http://proxy.example.com:3128
      https_proxy: http://proxy.example.com:3128

But it throws this message:

script_exporter[2622]: ts=2023-07-03T22:48:51.713Z caller=exporter.go:57 level=error err="yaml: unmarshal errors:\n line 5: cannot unmarshal !!map into []string"

Version: v2.12.0

Long shoot: And when I provide the env var as a list of str, it works:

scripts:
  - name: test_env
    command: /tmp/my_script.sh
    env:
    - http_proxy
    - https_proxy
ricoberger commented 1 year ago

Hi @gacerioni, thanks for pointing out. I missed this during the review of #65.

I will create a PR, so that it is implemented like in the examples.