Hello, 

Could anyone help this issue regarding SNMP Exporter: *server returned HTTP 
status 400 Bad Request*

https://www.reddit.com/r/grafana/comments/17s6uvh/snmp_exporter_server_returned_http_status_400_bad/

I'm just trying to scrape 2 OIDs using SNMP_Exporter, but something isn't 
working as I get an error of:

server returned HTTP status 400 Bad Request


[image: r/grafana - SNMP Exporter - server returned HTTP status 400 Bad 
Request] 
<https://preview.redd.it/9z1364gwijzb1.png?width=2572&format=png&auto=webp&s=e8883bb7b10367096783e379a83696ec418f1ce7>

Here is my generator.yml
auths: auth_name: version: 2 # SNMP version to use. Defaults to 2. # 1 will 
use GETNEXT, 2 and 3 use GETBULK. # Community string is used with SNMP v1 
and v2. Defaults to "public_v2". community: public modules: module_name: # 
The module name. You can have as many modules as you want. walk: # List of 
OIDs to walk. Can also be SNMP object names or specific instances. - 
sysUpTime # Same as "1.3.6.1.2.1.1.3" - 1.3.6.1.4.1.33762.7.7.2 # back temp 
- 1.3.6.1.4.1.33762.7.6.2 # Front of display temp max_repetitions: 25 # How 
many objects to request with GET/GETBULK, defaults to 25. # May need to be 
reduced for buggy devices. retries: 3 # How many times to retry a failed 
request, defaults to 3. timeout: 5s # Timeout for each individual SNMP 
request, defaults to 5s. 

I create the snmp.yml
/opt/snmp_exporter/generator# ./generator generate 
ts=2023-11-10T15:30:09.608Z caller=net_snmp.go:162 level=info msg="Loading 
MIBs" 
from=$HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
 
ts=2023-11-10T15:30:11.208Z caller=main.go:122 level=warn msg="NetSNMP 
reported parse error(s)" errors=6 ts=2023-11-10T15:30:11.462Z 
caller=main.go:53 level=info msg="Generating config for module" 
module=module_name ts=2023-11-10T15:30:11.503Z caller=main.go:68 level=info 
msg="Generated metrics" module=module_name metrics=3 
ts=2023-11-10T15:30:11.504Z caller=main.go:93 level=info msg="Config 
written" file=/opt/snmp_exporter/generator/snmp.yml 

Which looks like this:
# WARNING: This file was auto-generated using snmp_exporter generator, 
manual changes will be lost. auths: auth_name: community: public 
security_level: noAuthNoPriv auth_protocol: MD5 priv_protocol: DES version: 
2 modules: module_name: get: - 1.3.6.1.2.1.1.3.0 - 
1.3.6.1.4.1.33762.7.6.2.0 - 1.3.6.1.4.1.33762.7.7.2.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 - name: rFrontTemp oid: 
1.3.6.1.4.1.33762.7.6.2 type: gauge help: Front temperature measured by the 
sensor on the front of the display. - 1.3.6.1.4.1.33762.7.6.2 - name: 
rHumidity oid: 1.3.6.1.4.1.33762.7.7.2 type: gauge help: Relative Humidity 
measured by the sensor embedded on the diagnostic board. - 
1.3.6.1.4.1.33762.7.7.2 max_repetitions: 25 retries: 3 timeout: 5s 

Copy my custom mib file GDS-DIAG-MIB.mib to /usr/share/snmp/mibs as it seem 
to look there.

Copy the generated snmp.yml to my snmp_exporter docker volume:

/var/lib/docker/volumes/snmp-exporter-etc/_data/snmp.yml

Add to the Prometheus.yml to scrape, I've removed the other bits:
- job_name: 'snmp_dep' static_configs: - targets: - 10.1.80.202 # SNMP 
device. # - switch.local # SNMP device. # - tcp://192.168.1.3:1161 # SNMP 
device using TCP transport and custom port. metrics_path: /snmp params: 
module: [GDS-DIAG-MIB] relabel_configs: - source_labels: [__address__] 
target_label: __param_target - source_labels: [__param_target] 
target_label: instance - target_label: __address__ replacement: 
10.1.105.16:9116 # The SNMP exporter's real hostname:port. # Global 
exporter-level metrics - job_name: 'snmp_exporter' static_configs: - 
targets: ['10.1.105.16:9116'] 

Restart Prometheus container.


[image: r/grafana - SNMP Exporter - server returned HTTP status 400 Bad 
Request] 
<https://preview.redd.it/78iq064hjjzb1.png?width=2572&format=png&auto=webp&s=53464389d3313e313bdaa614c89a2b8d66003ca6>

If I do an SNMP walk from the VM docker is on they work too.
snmpwalk -v2c -c public 10.1.80.202 1.3.6.1.4.1.33762.7.6.2.0 
SNMPv2-SMI::enterprises.33762.7.6.2.0 = INTEGER: 45 

Docker info
snmp-exporter: image: quay.io/prometheus/snmp-exporter ports: - 9116:9116 - 
116:116/udp volumes: - snmp-exporter-etc:/etc/snmp-exporter/ restart: 
always command: --config.file=/etc/snmp-exporter/snmp.yml networks: - 
monitoring 

Any help would be most appreciated.

Thanks

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/9cb5b0a4-8e06-44a3-8c79-393690076d6fn%40googlegroups.com.

Reply via email to