Is there a way to specify the SNMP community from within my prometheus.yml config instead of having it in the generated snmp.yml file? I found an example online about using relabel_configs but it doesn't work for community. I end up with a target for prometheus like
127.0.0.1:9116/snmp?community=mycommunity&module=if_mib&target=10.1.1.26. I searched here about using different communities across devices but it seemed all about changing snmp.yml
- job_name: 'snmp'
scrape_interval: 120s
scrape_timeout: 60s
static_configs:
- targets: ['10.1.1.26', '10.1.1.27']
metrics_path: /snmp
params:
module: [if_mib]
community: [mycommunity]
version: 2
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [hostname]
target_label: instance
- target_label: __address__
replacement:
127.0.0.1:9116 # IP:Port to reach snmp exporter
- source_labels: [snmpCommunity] # Take community from targets
target_label: __param_community
- source_labels: [mib] # Take module also from targets
target_label: __param_module