Prometheus snmp exporter generator.yml file

1,002 views
Skip to first unread message

Marko Juričić

unread,
Nov 19, 2019, 10:25:14 AM11/19/19
to Prometheus Users
Greetings,

I need help with creating generator.yml. My snmpwalk output is something like this:

INPUT: snmpwalk -v2c -c COMMUNITY IP.OF.SERVER 1.3.6.1.4.1.8072.1.3.2.3.1.2.18.99.111.117.114.105.101.114.105.109.97.112.100.97.101.109.111.110.115
OUTPUT: iso.3.6.1.4.1.8072.1.3.2.3.1.2.18.99.111.117.114.105.101.114.105.109.97.112.100.97.101.109.111.110.115 = STRING: "87"

generator.yml:
  linux_CA:
    walk:    
      - 1.3.6.1.4.1.8072.1.3.2.3.1.2.21.112.111.115.116.102.105.120.77.97.105.108.81.117.101.117.101.67.111.117.110.116
      - 1.3.6.1.4.1.8072.1.3.2.3.1.2.18.99.111.117.114.105.101.114.105.109.97.112.100.97.101.109.111.110.115
    
    version: 2
    max_repetitions: 25
    retries: 3
    timeout: 10s

    auth:
      community: COMMUNITY

snmp.yml:
linux_CA:
  get:
  - 1.3.6.1.4.1.8072.1.3.2.3.1.2.18.99.111.117.114.105.101.114.105.109.97.112.100.97.101.109.111.110.115
  - 1.3.6.1.4.1.8072.1.3.2.3.1.2.21.112.111.115.116.102.105.120.77.97.105.108.81.117.101.117.101.67.111.117.110.116
  metrics:
  - name: nsExtendOutputFull
    oid: 1.3.6.1.4.1.8072.1.3.2.3.1.2
    type: DisplayString
    help: The full output from the command, as a single string - 1.3.6.1.4.1.8072.1.3.2.3.1.2
    indexes:
    - labelname: nsExtendToken
      type: DisplayString
  version: 2
  max_repetitions: 25
  retries: 3
  timeout: 10s
  auth:
    community: COMMUNITY

So, in Prometheus when i expose metrics i get:
# HELP nsExtendOutputFull The full output from the command, as a single string - 1.3.6.1.4.1.8072.1.3.2.3.1.2
# TYPE nsExtendOutputFull gauge
nsExtendOutputFull{nsExtendOutputFull="139",nsExtendToken="postfixMailQueueCount"} 1
nsExtendOutputFull{nsExtendOutputFull="85",nsExtendToken="courierimapdaemons"} 1
# HELP snmp_scrape_duration_seconds Total SNMP time scrape took (walk and processing).
# TYPE snmp_scrape_duration_seconds gauge
snmp_scrape_duration_seconds 0.050516882
# HELP snmp_scrape_pdus_returned PDUs returned from walk.
# TYPE snmp_scrape_pdus_returned gauge
snmp_scrape_pdus_returned 2
# HELP snmp_scrape_walk_duration_seconds Time SNMP walk/bulkwalk took.
# TYPE snmp_scrape_walk_duration_seconds gauge
snmp_scrape_walk_duration_seconds 0.050449183


I apologize in advance if this is a beginner mistake but i got confused when constructing generator.yml file. The problem is in:
nsExtendOutputFull{nsExtendOutputFull="139",nsExtendToken="postfixMailQueueCount"} 1

I would like to get something like this:
nsExtendOutputFull{...} 139

So, value should be 139 and not 1. Thank you for your help!

Ben Kochie

unread,
Nov 19, 2019, 10:59:21 AM11/19/19
to Marko Juričić, Prometheus Users
The problem is that `nsExtendOutputFull` is defined as a string.

From the MIB
nsExtendOutputFull  OBJECT-TYPE
    SYNTAX      DisplayString
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION

      "The full output from the command, as a single string"
    ::= { nsExtendOutput1Entry 2 }

To extract the number from the string, you'll need to use a regex extraction.

generator.yml:
modules:
  net-snmp-extend:
    walk:
    - nsExtendOutputFull
    overrides:
      nsExtendOutputFull:
        regex_extracts:
          Value:
          - regex: '(.*)'
            value: '$1' 


Note, this looks like it's coming from a normal node. I would highly recommend using a normal exporter, or the node_exporter textfile collector, to gather this data. SNMP is really only good for legacy devices with no other options.

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/b1d7465d-19ae-4ad1-938c-97dcc2510e84%40googlegroups.com.

Marko Juričić

unread,
Nov 20, 2019, 3:53:11 AM11/20/19
to Ben Kochie, Prometheus Users
Thank you for you solution, it works perfectly!

On that note to use node exporter, we are monitoring thousands of
devices and will use Prometheus to collect data for graphs.

As I noticed, but maybe I am wrong, you can't use node exporter on
remote devices that I can't install it on?

Ben Kochie

unread,
Nov 22, 2019, 4:07:56 PM11/22/19
to Marko Juričić, Prometheus Users
The node_exporter must be installed on the target node. It reads data directly from the kernel via /proc and /sys.
Reply all
Reply to author
Forward
0 new messages