msg="Error parsing config file" err="yaml: line 2: mapping values are not allowed in this context"

72 views
Skip to first unread message

Daly Graty

unread,
Oct 13, 2020, 12:28:01 PM10/13/20
to Prometheus Users
i'am using prometheus+snmp_exporter to monitor my fortigate
it was all running good when suddenly tried to add another snmp target but i got a problem on prometheus status !
i deleted the new target and restarting prometheus as well as snmp_exporter but suddenly i got another error with snp_exporter service :

prometheus.yml

- job_name: 'snmp'
    scrape_interval: 50s
    scrape_timeout: 50s
    static_configs:
      - targets:
        - 197.13.50.186
    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: grafana.so.com:9116  # The SNMP exporter's real hostname:port.

journalctl -eu snmp_exporter shows:

level=error ts=2020-10-13T16:22:53.930Z caller=main.go:156 msg="Error parsing config file" err="yaml: line 2: mapping values are not allowed in this context"

snmp.yml: 

# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
-- apcups: -- MODULE-IDENTITY walk: -- OrgName - 1.3.6.1.2.1.2 -- Fortinet Technologies, Inc.  - 1.3.6.1.4.1.318.1.1.1.12 -- ContactInfo - 1.3.6.1.4.1.318.1.1.1.2 -- Technical Support -
1.3.6.1.4.1.318.1.1.1.3 -- e-mail: sup...@fortinet.com - 1.3.6.1.4.1.318.1.1.1.4 -- http://www.fortinet.com - 1.3.6.1.4.1.318.1.1.1.7.2 -- - 1.3.6.1.4.1.318.1.1.10.2.3.2
  - 1.3.6.1.4.1.318.1.1.26.8.3 FORTINET-FORTIGATE-MIB DEFINITIONS ::= BEGIN get:
  - 1.3.6.1.2.1.1.3.0 IMPORTS - 1.3.6.1.4.1.318.1.1.1.8.1.0
    FnBoolState, FnIndex, fnAdminEntry, fnSysSerial, fortinet metrics:
        FROM FORTINET-CORE-MIB - name: sysUpTime
    ifEntry, ifName, ifIndex oid: 1.3.6.1.2.1.1.3
        FROM IF-MIB type: gauge
    InetAddress, InetAddressPrefixLength, InetAddressType, InetPortNumber help: The time (in hundredths of a second) since the network management portion
        FROM INET-ADDRESS-MIB of the system was last re-initialized. - 1.3.6.1.2.1.1.3
    MODULE-COMPLIANCE, NOTIFICATION-GROUP, OBJECT-GROUP - name: ifNumber
        FROM SNMPv2-CONF oid: 1.3.6.1.2.1.2.1
    sysName type: gauge
        FROM SNMPv2-MIB help: The number of network interfaces (regardless of their current state) present
    Counter32, Counter64, Gauge32, Unsigned32, Integer32, IpAddress, on this system. - 1.3.6.1.2.1.2.1
    MODULE-IDENTITY, NOTIFICATION-TYPE, OBJECT-TYPE, TimeTicks, OBJECT-IDENTITY - name: ifIndex
        FROM SNMPv2-SMI oid: 1.3.6.1.2.1.2.2.1.1
    Ipv6Address type: gauge
        FROM IPV6-TC help: A unique value, greater than zero, for each interface - 1.3.6.1.2.1.2.2.1.1
    CounterBasedGauge64 indexes:
        FROM HCNUM-TC - labelname: ifIndex
    DisplayString, TEXTUAL-CONVENTION, AutonomousType, DateAndTime, PhysAddress type: gauge
        FROM SNMPv2-TC; - name: ifDescr
    oid: 1.3.6.1.2.1.2.2.1.2 fnFortiGateMib MODULE-IDENTITY type: DisplayString
    LAST-UPDATED "201704050000Z" help: A textual string containing information about the interface - 1.3.6.1.2.1.2.2.1.2
    ORGANIZATION indexes:
        "Fortinet Technologies, Inc."  - labelname: ifIndex
    CONTACT-INFO type: gauge
        " - name: ifType
         Technical Support oid: 1.3.6.1.2.1.2.2.1.3
         email: sup...@fortinet.com type: EnumAsInfo
         http://www.fortinet.com" help: The type of interface - 1.3.6.1.2.1.2.2.1.3
    DESCRIPTION indexes:
        "Added fgInternalLTEModemsInfo under fnFortiGateMib, Added Modem, SIM card, Signal Info, - labelname: ifIndex
        Traffic Info, Data Session Info OIDs."  type: gauge
    REVISION "201704050000Z" enum_values:
    DESCRIPTION 1: other
        "Added extended database version OIDs for AV and IPS."  2: regular1822
    REVISION "201701160000Z" 3: hdh1822
    DESCRIPTION 4: ddnX25
        "Added fgFwIppools OIDs."  5: rfc877x25
    REVISION "201609150000Z" 6: ethernetCsmacd
    DESCRIPTION 7: iso88023Csmacd
        "Various non-monotonically increase Counter32 values have been changed to Gauge32."  8: iso88024TokenBus
    REVISION "201606170000Z" 9: iso88025TokenRing
    DESCRIPTION 10: iso88026Man
        "Added fgProcessorFnNP6 in fgProcessorTypes."  11: starLan
    REVISION "201504230000Z" 12: proteon10Mbit
    DESCRIPTION 13: proteon80Mbit
         "Added fgDevice OIDs" 14: hyperchannel


some help please !!!

l.mi...@gmail.com

unread,
Oct 13, 2020, 1:06:02 PM10/13/20
to Prometheus Users
If you paste your file into http://www.yamllint.com/ you'll get some feedback on the errors.
Not sure if what you pasted is 1:1 as it is in the file but there are 2 possible problems:


- job_name: 'snmp'
    scrape_interval: 50s

make sure that both job_name & scrape_interval are indented to the same level, it should be:

- job_name: 'snmp'
  scrape_interval: 50s

Same for all other fields. Spaces matter in yaml the same way as in python.
Another issue might be on the last line:

replacement: grafana.so.com:9116 

graphana.so.com:9116 might be interpreted as a mapping, better wrap it in quotes to ensure that YAML parses it as a string:

replacement: 'grafana.so.com:9116'

jut...@hiya.com

unread,
Oct 13, 2020, 1:08:53 PM10/13/20
to Prometheus Users
The configuration for the snmp_exporter you posted doesn't look right. The first line (after the comment), looks like this:


-- apcups: -- MODULE-IDENTITY walk: -- OrgName - 1.3.6.1.2.1.2 -- Fortinet Technologies, Inc.  - 1.3.6.1.4.1.318.1.1.1.12 -- ContactInfo - 1.3.6.1.4.1.318.1.1.1.2 -- Technical Support -

This isn't correct yaml. The leading dashes are unusual, and it looks like there are a lot of missing newlines and indentation. Refer to this example.

Also, I'm not sure whether that prometheus configuration is the entire configuration. You are posting your scrape configuration, but it isn't under the top-level scrape_configuration field. That may be an issue.
Reply all
Reply to author
Forward
0 new messages