helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

[prometheus-snmp-exporter] Add optional auth section

Open iPenguin opened this issue 1 year ago • 1 comments

What this PR does / why we need it

This PR passes the auth parameters available in newer versions of snmp-exporter from the chart to the application configuration.

Which issue this PR fixes

  • fixes #3940

Special notes for your reviewer

Checklist

  • [x] DCO signed
  • [x] Chart Version bumped
  • [x] Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

iPenguin avatar Nov 17 '23 21:11 iPenguin

Hi @xiu, just checking to see if you have any feedback for this PR?

Thanks, Brian

iPenguin avatar Dec 18 '23 15:12 iPenguin

Hi @walker-tom I've fixed the merge conflict. Do you need me to do anything else?

Thanks, Brian

iPenguin avatar Feb 27 '24 18:02 iPenguin

Hi @walker-tom I've fixed the merge conflict. Do you need me to do anything else?

Thanks, Brian

Hi Brian, thanks for updating your PR, could you update the Chart version in Chart.yaml, I think it got lost during the merge conflict. Thanks!

walker-tom avatar Feb 27 '24 18:02 walker-tom

:facepalm: Thanks. I think that should fix it.

iPenguin avatar Feb 27 '24 21:02 iPenguin

This change seems to be broken in the default case where you don't specify an auth in the params[*]. It's attempting to apply the default $.Values.serviceMonitor.auth (which is an array, defaulting to [public_v2]) to a single item in the array:

      auth:
      - {{ .auth | default $.Values.serviceMonitor.auth }}

So it's ending up being:

   auth:
   - [public_v2]

Here's the error from my HelmRelease install:

ServiceMonitor.monitoring.coreos.com "snmp-exporter-prometheus-snmp-exporter-<target1>" is invalid: spec.endpoints[0].params.auth[0]: Invalid value: "array": spec.endpoints[0].params.auth[0] in body must be of type string: "array" && cannot patch "snmp-exporter-prometheus-snmp-exporter-<target2>" with kind ServiceMonitor: ServiceMonitor.monitoring.coreos.com "snmp-exporter-prometheus-snmp-exporter-<target2>" is invalid: spec.endpoints[0].params.auth[0]: Invalid value: "array": spec.endpoints[0].params.auth[0] in body must be of type string: "array"

kevinastone avatar Feb 29 '24 03:02 kevinastone

This change seems to be broken in the default case where you don't specify an auth in the params[*]. It's attempting to apply the default $.Values.serviceMonitor.auth (which is an array, defaulting to [public_v2]) to a single item in the array:

I apologize for the mistake. Thanks for fixing it.

iPenguin avatar Feb 29 '24 14:02 iPenguin

Is there any documentation that gives an example of how to use SNMPv3 auth in prometheus-snmp-exporter via Helm?

abctaylor avatar May 10 '24 18:05 abctaylor

@abctaylor You will need to create an auths configuration for your targets in your SNMP Exporter. As documented in auth-split-migration.md this is now separate to the modules configuration. You can see examples in the generator file format for the settings available for SNMPv3. You then have at least two options for getting this configuration into your Container:

  1. Create an auths configuration YAML file for the exporter in a Secret and mount that into your Container using extraVolumes and extraVolumeMounts, then pass in an argument --config.file=/path/to/extra/auths/file via the extra extraArgs. SNMP Exporter will then load up a this additional configuration
  2. Add the auths configuration to your existing SNMP Exporter configuration file, set the relevant sensitive data as environment variables using envFrom and then reference those env vars in your auths section using --config.expand-environment-variables as mentioned here

Hope this helps.

walker-tom avatar May 18 '24 13:05 walker-tom