Error in prometheus snmp_exporter

1,725 views
Skip to first unread message

ktorce

unread,
Dec 22, 2022, 5:38:12 AM12/22/22
to Prometheus Users
"server returned HTTP status 400 Bad Request"

Brian Candler

unread,
Dec 22, 2022, 6:50:13 AM12/22/22
to Prometheus Users
That's an error telling you that *you* did something wrong.

If you want *us* to help you find the solution to your problem, then you'll need to show some more information [^1].  What request are you sending? If it's curl, show the command line.  If it's a prometheus scrape, then show the scrape job configuration.

You can also look at the actual request and response using tcpdump: e.g. if you're sending requests to snmp_exporter on localhost (127.0.0.1), which is a common configuration, then:

tcpdump -i lo -nn -s0 -A tcp port 9116

Brian Candler

unread,
Dec 22, 2022, 9:07:27 AM12/22/22
to Prometheus Users
Also, look at the body of the HTTP error response (again, tcpdump can help there) and you may get a clue.  For example:

# curl -v localhost:9116/snmp
*   Trying 127.0.0.1:9116...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9116 (#0)
> GET /snmp HTTP/1.1
> Host: localhost:9116
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Thu, 22 Dec 2022 14:04:17 GMT
< Content-Length: 42
<
'target' parameter must be specified once
* Connection #0 to host localhost left intact


# curl -v 'localhost:9116/snmp?target=1.2.3.4&module=wombat'
*   Trying 127.0.0.1:9116...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9116 (#0)
> GET /snmp?target=1.2.3.4&module=wombat HTTP/1.1
> Host: localhost:9116
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Thu, 22 Dec 2022 14:06:45 GMT
< Content-Length: 24
<
Unknown module 'wombat'
* Connection #0 to host localhost left intact

Brian Candler

unread,
Jan 4, 2023, 4:53:39 PM1/4/23
to Prometheus Users
> E.GET /snmp?module=IF-MIB&target=10.168.200.1 HTTP/1.1
> Host: 127.0.0.1:9116
> User-Agent: Prometheus/2.40.7
> Accept: application/openmetrics-text;version=1.0.0,application/openmetrics-text;version=0.0.1;q=0.75,text/plain;version=0.0.4;q=0.5,*/*;q=0.1
> Accept-Encoding: gzip
> X-Prometheus-Scrape-Timeout-Seconds: 10


> 14:09:55.529438 IP 127.0.0.1.9116 > 127.0.0.1.39169: Flags [P.], seq 1:184, ack 316, win 6146, options [nop,nop,TS val 1795838892 ecr 1795838892], length 183
> E...o.@.@...........#....6=..J.............
> k
> S.k
> S.HTTP/1.1 400 Bad Request
> Content-Type: text/plain; charset=utf-8
> X-Content-Type-Options: nosniff
> Date: Wed, 04 Jan 2023 20:09:55 GMT
> Content-Length: 24

> Unknown module 'IF-MIB' 


Great: there's your answer.  The standard snmp.yml defines a module called "if_mib" (lowercase, underscore) not "IF-MIB" (capitals, hyphen)

Ernesto José Argueta Romero

unread,
Jan 9, 2023, 6:51:21 AM1/9/23
to Prometheus Users
Thanks for your help, my problem was solved just like you said, change 'IF-MIB' to 'if_mib.
Reply all
Reply to author
Forward
0 new messages