Aside: curl is useful for debugging:
curl -g `http://127.0.0.1:9116/snmp?module=if_mib&target=x.x.x.x&debug=true`

However in your case, you've found the problem: you need to set a community 
string.

Unfortunately, snmp_exporter makes it hard to set this, because the MIB and 
the device authentication are bundled together in the "module".  Here's the 
easiest way I've found to do this:

1. Edit snmp.yml (that was supplied with snmp_exporter, or that you 
generated)

2. Find the MIB that you're interested in using: in this case if_mib.  
Modify the first line like this:

*if_mib:*

becomes

*if_mib: &if_mib*

(this is called an "anchor" in YAML)

3. Add to the very *end* of the file:





*if_mib_secret:  <<: *if_mib  version: 2  auth:    community: BlahBlah123*

What you're doing is taking a copy of the "if_mib" section, and then 
overriding some of the parameters (the 'auth' and 'version' keys) without 
changing anything else.

[Aside: you should be able to do steps 1-3 using the snmp generator 
instead, but you'll have to duplicate the if_mib section in generator.yml 
instead, and then run the generator]

4. Restart snmp_exporter, and check this works using curl:


*curl -g 
`http://127.0.0.1:9116/snmp?module=if_mib_secret&target=x.x.x.x&debug=true`*

5. Change your scrape job for these devices to use module if_mib_secret 
instead of if_mib.

Oddly, your scrape job shows a static target of only 127.0.0.1, i.e. it 
looks like you're sending queries to the snmpd running on prometheus 
itself, not to any remote devices.  I would suggest that you use the 
file_sd mechanism, and also that you pick up the module from this, so that 
a single scrape job can handle any combination of targets and SNMP modules.

  - job_name: snmp
    metrics_path: /snmp
    file_sd_configs:
      - files:
          - /etc/prometheus/targets.d/snmp_targets.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: instance
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [module]
        target_label: __param_module
      - target_label: __address__
        replacement: 127.0.0.1:9116  # SNMP exporter

then in snmp_targets.yml you can put:

- labels:
    module: if_mib
  targets:
    - foo
    - bar
- labels:
    module: if_mib_secret
  targets:
    - baz
    - qux


-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/aa9f124e-e927-4ad6-91c5-e261d3c52312n%40googlegroups.com.

Reply via email to