Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying --config.file=~/snmp_exporter/generator/snmp.yml does not work #1154

Closed
BYT3M3 opened this issue Apr 9, 2024 · 0 comments
Closed

Comments

@BYT3M3
Copy link

BYT3M3 commented Apr 9, 2024

Host operating system: output of uname -a

Linux prometheus-01 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux

snmp_exporter version: output of snmp_exporter --version

snmp_exporter, version 0.25.0 (branch: HEAD, revision: 9c42d6c)

build date:       20231210-10:05:18
go version:       go1.21.5
platform:         linux/amd64
tags:             netgo

What device/snmpwalk OID are you using?

Not applicable

If this is a new device, please link to the MIB(s).

Not applicable

What did you do that produced an error?

I tried to generate a minimal snmp.yaml file, so I could just query a sysUpTime.
My generator.yml file looks like:

---
auths:
 public_v1:
   version: 1
 public_v2:
   version: 2

modules:
 # Default IF-MIB interfaces table with ifIndex.
 if_mib:
   walk: [sysUpTime]
   lookups:
     - source_indexes: [ifIndex]
       lookup: ifAlias
     - source_indexes: [ifIndex]
       # Uis OID to avoid conflict with PaloAlto PAN-COMMON-MIB.
       lookup: 1.3.6.1.2.1.2.2.1.2 # ifDescr
     - source_indexes: [ifIndex]
       # Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
       lookup: 1.3.6.1.2.1.31.1.1.1.1 # ifName
   overrides:
     ifAlias:
       ignore: true # Lookup metric
     ifDescr:
       ignore: true # Lookup metric
     ifName:
       ignore: true # Lookup metric
     ifType:
       type: EnumAsInfo

I converted this to snmp.yml using ./generator -g /tmp/generator.yml -o /tmp/snmp.yml and my snmp.yml looks like:

# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
auths:
  public_v1:
    community: public
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 1
  public_v2:
    community: public
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 2
modules:
  if_mib:
    get:
    - 1.3.6.1.2.1.1.3.0
    metrics:
    - name: sysUpTime
      oid: 1.3.6.1.2.1.1.3
      type: gauge
      help: The time (in hundredths of a second) since the network management portion
        of the system was last re-initialized. - 1.3.6.1.2.1.1.3

What did you expect to see?

When surfing to hostname:9116/config I expect to see:

auths:
  public_v1:
    community: <secret>
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 1
  public_v2:
    community: <secret>
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 2
modules:
  if_mib:
    get:
    - 1.3.6.1.2.1.1.3.0
    metrics:
    - name: sysUpTime
      oid: 1.3.6.1.2.1.1.3
      type: gauge
      help: The time (in hundredths of a second) since the network management portion
        of the system was last re-initialized. - 1.3.6.1.2.1.1.3
    max_repetitions: 25
    retries: 3
    timeout: 5s

And when I try to query a machines sysUpTime, I expect to see:

# HELP snmp_scrape_duration_seconds Total SNMP time scrape took (walk and processing).
# TYPE snmp_scrape_duration_seconds gauge
snmp_scrape_duration_seconds{module="if_mib"} 0.002477075
# HELP snmp_scrape_packets_retried Packets retried for get, bulkget, and walk.
# TYPE snmp_scrape_packets_retried gauge
snmp_scrape_packets_retried{module="if_mib"} 0
# HELP snmp_scrape_packets_sent Packets sent for get, bulkget, and walk; including retries.
# TYPE snmp_scrape_packets_sent gauge
snmp_scrape_packets_sent{module="if_mib"} 1
# HELP snmp_scrape_pdus_returned PDUs returned from get, bulkget, and walk.
# TYPE snmp_scrape_pdus_returned gauge
snmp_scrape_pdus_returned{module="if_mib"} 1
# HELP snmp_scrape_walk_duration_seconds Time SNMP walk/bulkwalk took.
# TYPE snmp_scrape_walk_duration_seconds gauge
snmp_scrape_walk_duration_seconds{module="if_mib"} 0.002360924
# HELP sysUpTime The time (in hundredths of a second) since the network management portion of the system was last re-initialized. - 1.3.6.1.2.1.1.3
# TYPE sysUpTime gauge
sysUpTime 9.895252e+06

What did you see instead?

When going to hostname:9116/config I saw:

{}

And querying the ifMib, yielded:

Unknown auth 'public_v2'

How did I work around this issue?

I just replaced ~ (which is the standard reference to the home directory) with an absolute or a relative path and this did work. This issue is a user friendliness bug. This could be fixed by indicating more clearly that the config file wasn't found or even better: just support using ~.

@prometheus prometheus locked and limited conversation to collaborators Apr 9, 2024
@SuperQ SuperQ converted this issue into discussion #1155 Apr 9, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant