error reading snmp.yml file

1,016 views
Skip to first unread message

Andrew Meyer

unread,
Nov 6, 2017, 9:03:12 AM11/6/17
to Prometheus Users
Hello, I seem to be seeing some errors with prometheus.

Nov  6 13:53:54 mon05 prometheus[17576]: time="2017-11-06T13:53:54Z" level=error msg="Error reading file \"/opt/monitoring/snmp_exporter/snmp.yml\": yaml: unmarshal errors:\n  line 1: cannot unmarshal !!map into []*config.TargetGroup" source="file.go:180"
Nov  6 13:53:59 mon05 prometheus[17576]: time="2017-11-06T13:53:59Z" level=error msg="Error reading file \"/opt/monitoring/snmp_exporter/snmp.yml\": yaml: unmarshal errors:\n  line 1: cannot unmarshal !!map into []*config.TargetGroup" source="file.go:180"
Nov  6 13:54:54 mon05 prometheus[17576]: time="2017-11-06T13:54:54Z" level=info msg="Checkpointing in-memory metrics and chunks..." source="persistence.go:539"
Nov  6 13:55:01 mon05 prometheus[17576]: time="2017-11-06T13:55:01Z" level=info msg="Done checkpointing in-memory metrics and chunks in 7.487848821s." source="persistence.go:563"

I just want to make sure this may or may not be a syntax issue in my config.

In my prometheus.service file I have it looking like this:

ExecStart=/opt/monitoring/prometheus/prometheus -config.file /opt/monitoring/configs/prometheus.yml

In the prometheus.yml file it looks like this:

  - job_name: 'juniper-snmp'
    file_sd_configs:
      - files: [ '/opt/monitoring/snmp_exporter/snmp.yml' ]
    metrics_path: /juniper-snmp
    params:
      module: [ juniper ]
    static_configs:
      - targets:
        - remote-ip
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: prometheus-ip:9116

Ben Kochie

unread,
Nov 6, 2017, 9:29:47 AM11/6/17
to Andrew Meyer, Prometheus Users
From what I can tell, you're trying to feed the snmp_exporter's config file as a target list to Prometheus.

The snmp.yml is a config file for the snmp_exporter, not a target list for Prometheus.

If you want to feed a list of target hosts/IPs to the SNMP exporter, you need to create a target list with the correct format:


--
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/44cf023f-b42d-4578-8180-e0f87da3a480%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Meyer

unread,
Nov 6, 2017, 9:46:24 AM11/6/17
to Prometheus Users
Whoops.   Ok, thank you.  Removing for now.
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.

Andrew Meyer

unread,
Nov 6, 2017, 10:29:59 AM11/6/17
to Prometheus Users
Also,
Would it be best to break out the individual devices in separate job names?  Or could I set them all in one and specify snmp modules per devices?

Thank you!

Ben Kochie

unread,
Nov 6, 2017, 11:18:17 AM11/6/17
to Andrew Meyer, Prometheus Users
Typically I template my config to have a job per type of device.

- job_name: snmp_if_mib
  params:
    module: [ if_mib ]
  static_configs:
    - targets:
      - some-cisco-switch
      - some-hp-switch
      - some-generic-router

- job_name: snmp_wifi_controller
  params:
    module: [ wifi_controller ]
  static_configs:
    - targets:
      - some-primary-wifi-controller
      - some-backup-wifi-controller

    

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/e165e95a-f864-45d4-9c5c-e4dc1d1431b9%40googlegroups.com.

Andrew Meyer

unread,
Nov 6, 2017, 11:26:23 AM11/6/17
to Ben Kochie, Prometheus Users
Ok.  So I generated my snmp.yml w/ Brocade, juniper, cisco, meraki, aruba.  I would then replace the module w/ the correct hardware type, right?  

What about the destination at the end?  I can specify that 1x correct?



Please remember to reply to all if there are multiple recipients.

Ben Kochie

unread,
Nov 6, 2017, 11:29:21 AM11/6/17
to Andrew Meyer, Prometheus Users
Yes, the module param tells the exporter which SNMP walks/auth to use.

The metrics_path should always be `/snmp`

I'm not sure what you mean by the "destination at the end".  You will need to have separate jobs with all of the identical relabel_configs sections on each one.
Reply all
Reply to author
Forward
0 new messages