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

fix: Added missing part to setup environment #79

Closed fsadykov closed 1 year ago

fsadykov commented 1 year ago

Hello Maintainers,

Being able to add custom environment variables to script exporter opens up a lot of opportunities to maintain and do more integrations. I am using this feature to be able to add custom params to my scripts se example

values.yaml

config: |
  tls:
    enabled: false

  basicAuth:
    enabled: false

  bearerAuth:
    enabled: false

  scripts:
  - name: testing_script
    command: /usr/bin/env
    args:
    - bash
    - -xc
    - |
      echo '# HELP request_time Total time spent making performing the curl'
      echo '# TYPE request_time gauge'
      curl -ILsk \
        --user "${MY_USERNAME}:${MY_PASSWORD}" \
        -w '%{time_total}' \
        -o /dev/null \
        ${URL} | xargs echo "request_time{script=\"testing_script\"}"

custom-params.yaml

env:
- name: URL
  value: 'https://internal.local'
- name: MY_USERNAME
  value: "integration-agent"
- name: MY_PASSWORD
  value: "example"
ricoberger commented 1 year ago

Hi @fsadykov thanks again for your contribution 🙂