How to properly configure snmp_exporter and prometheus.yml?

10,921 views
Skip to first unread message

rob...@irob.se

unread,
Sep 14, 2017, 3:02:52 AM9/14/17
to Prometheus Users
Hi, I'm quite new to Prometheus but so far I've managed to solve any issues. However I'm facing some problems with snmp_exporter. 


Basically I only want to monitor cisco switches with it.

But when I use the suggested configuration in prometheus.yml I get FAILED: relabel configuration requires a regular expression.

scrape_configs:
  - job_name: 'snmp'
    static_configs:
      - targets:
        - 172.16.185.55  # SNMP device.
    metrics_path: /snmp
    params:
      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9116  # SNMP exporter.




When I add a regex like .* I get: FAILED: unknown fields in scrape_config: static_configs

- job_name: 'snmp'
    static_configs:
     - targets:
       - 172.16.185.55  # SNMP device.
    metrics_path: /snmp
    params:
      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        regex: .*
        target_label: __param_target
      - source_labels: [__param_target]
        regex: .*
        target_label: instance
      - target_label: __address__
        regex: .*
        replacement: 127.0.0.1:9116  # SNMP exporter.
When I change to:
- job_name: 'snmp'
    target_groups:
     - targets: ['172.16.185.55']  # SNMP device.
    metrics_path: /snmp
    params:
      module: [if_mib]
    relabel_configs:
      - source_labels: [__address__]
        regex: .*
        target_label: __param_target
      - source_labels: [__param_target]
        regex: .*
        target_label: instance
      - target_label: __address__
        regex: .*
        replacement: 127.0.0.1:9116  # SNMP exporter.
The promtool check-config reports no issues.
But the Prometheus Status page of course have to target for the exporter:
http://127.0.0.1:9116/snmp
module="if_mib"
DOWNnone3.727106627s agoserver returned HTTP status 400 Bad Request
So basically this all boils down to: How to properly configure snmp_exporter?
/ Robert Nilsson


Brian Brazil

unread,
Sep 14, 2017, 3:48:36 AM9/14/17
to rob...@irob.se, Prometheus Users
On 14 September 2017 at 08:02, <rob...@irob.se> wrote:
Hi, I'm quite new to Prometheus but so far I've managed to solve any issues. However I'm facing some problems with snmp_exporter. 


Basically I only want to monitor cisco switches with it.
 
But when I use the suggested configuration in prometheus.yml I get FAILED: relabel configuration requires a regular expression.


What version of Prometheus are you using? That should only happen in rather old versions.

Brian
 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/20533b80-ef83-414c-a104-4b2a00aa3c08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

rob...@irob.se

unread,
Sep 14, 2017, 3:57:46 AM9/14/17
to Prometheus Users
I'm running version:

prometheus -version
prometheus, version 0.16.2+ds (branch: debian/sid, revision: 0.16.2+ds-1ubuntu1)
build date:       20160408-04:15:29
go version:       go1.6
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.



--

Brian Brazil

unread,
Sep 14, 2017, 4:00:19 AM9/14/17
to rob...@irob.se, Prometheus Users
On 14 September 2017 at 08:57, <rob...@irob.se> wrote:
I'm running version:

prometheus -version
prometheus, version 0.16.2+ds (branch: debian/sid, revision: 0.16.2+ds-1ubuntu1)
build date:       20160408-04:15:29
go version:       go1.6


That's fairly old, I'd suggest picking up something newer. The (.*) default was added in a later release.

Brian
 
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0b59d27c-de15-480d-bbe9-4ce6ed9cbba4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

rob...@irob.se

unread,
Sep 14, 2017, 4:46:28 AM9/14/17
to Prometheus Users
Thanks Brian,

I added the Ubuntu artful Repo which contains 1.7.1 and got one step closer to success however now Prometheus reports:

snmp
EndpointStateLabelsLast ScrapeError
http://127.0.0.1:9116/snmp
module="if_mib" target="172.16.185.55"
DOWNinstance="172.16.185.55"13.642s agocontext deadline exceeded

I'm using a custom snmp community but could not find any default community string in snmp.yml.

/ Robert Nilsson

Den torsdag 14 september 2017 kl. 10:00:19 UTC+2 skrev Brian Brazil:
On 14 September 2017 at 08:57, <rob...@irob.se> wrote:
I'm running version:

prometheus -version
prometheus, version 0.16.2+ds (branch: debian/sid, revision: 0.16.2+ds-1ubuntu1)



--

Brian Brazil

unread,
Sep 14, 2017, 4:53:32 AM9/14/17
to rob...@irob.se, Prometheus Users
On 14 September 2017 at 09:46, <rob...@irob.se> wrote:
Thanks Brian,

I added the Ubuntu artful Repo which contains 1.7.1 and got one step closer to success however now Prometheus reports:

snmp
EndpointStateLabelsLast ScrapeError
http://127.0.0.1:9116/snmp
module="if_mib" target="172.16.185.55"
DOWNinstance="172.16.185.55"13.642s agocontext deadline exceeded

I'm using a custom snmp community but could not find any default community string in snmp.yml.

Can you share the relevant bit of your config? The default is "public" https://github.com/prometheus/snmp_exporter/tree/master/generator#file-format

Brian
 
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/94cec4b8-cd16-42aa-ab61-171e409ebef1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

rob...@irob.se

unread,
Sep 14, 2017, 4:56:32 AM9/14/17
to Prometheus Users
Ah, I bet I will get it to work now. Of course I need to generate a Cisco specific yml with custom community (Read the manual first).

Thanks for your help!

/ Robert



--

satyanara...@gmail.com

unread,
Nov 22, 2018, 10:03:17 PM11/22/18
to Prometheus Users
Glad I saw this discussion.  I am facing the same issue as well.  I can access the network devices using "default/public" snmp string, but not with the other defined SNMP strings.  May I know how I can specify the snmp string in generator and generate the data?  Any config snippets would be extremely helpful.

Ben Kochie

unread,
Nov 23, 2018, 3:39:31 AM11/23/18
to satyanara...@gmail.com, Prometheus Users
Yes, you can put your SNMP authentication in the generator.yml. See the README[0].

modules:
  module_name:  # The module name. You can have as many modules as you want.
    walk:       # List of OIDs to walk. Can also be SNMP object names or specific instances.
      - 1.3.6.1.2.1.2              # Same as "interfaces"
    auth:
      # Community string is used with SNMP v1 and v2. Defaults to "public".
      community: FooBar

satyanara...@gmail.com

unread,
Nov 25, 2018, 9:48:21 PM11/25/18
to Prometheus Users
Thank you.  I have already seen that.  How do I generate the new snmp.yml after updating generator.yml - that is the piece I am unsure about?  Could you please share some details on that?

satyanara...@gmail.com

unread,
Nov 27, 2018, 11:34:12 PM11/27/18
to Prometheus Users
Here is what I get when I run the command provided on the doc.

# ./generator generate
-bash: ./generator: No such file or directory
#

Once generator.yml is updated with new community string, is this the command to run to get the new snmp.yml generated?
Reply all
Reply to author
Forward
0 new messages