SNMP Docker-compose stack

1,449 views
Skip to first unread message

Parthey Khanderia

unread,
May 1, 2020, 11:15:28 AM5/1/20
to Prometheus Users
I am trying to monitor some brocade vdx switches using snmp exporter. I understand the concept of snmp exporter and generator but I can't seem to figure out what I need in my docker-compose file.
SO far I have
Docker-compose .yml
image: prom/prometheus
ports:
- 9990:9090
networks:
- public
volumes:
- prometheus_data:/prometheus
- ./prometheus/:/etc/prometheus/
command:
- '--config.file=/etc/prometheus/prometheus.yml'
depends_on:
- snmp-exporter

snmp-exporter:
image: prom/snmp-exporter
volumes:
- ./snmp_exporter/:/etc/snmp_exporter/
expose:
- 9116
ports:
- 9116:9116

networks:
- public

prometheus:

- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'snmp'
static_configs:
- targets:
- some ip # SNMP device.
metrics_path: /snmp
params:
module: [default]

relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 'snmp-exporter:9116' # The SNMP exporter's real hostname:port

How do I generte a snmp.yml file to query the brocade vdx switch and do I need to have snmp generator in my docker file aswell ?
scrape_configs:

Brian Candler

unread,
May 1, 2020, 11:51:58 AM5/1/20
to Prometheus Users
> do I need to have snmp generator in my docker file aswell

No, the running snmp_exporter needs only the yaml file which was *output* from the generator.

I'd suggest you start with the supplied sample snmp.yml, edit it for your SNMP credentials, and get it working with if_mib.  Then you can look at using other MIBs with the generator.

The easy way to get credentials into the default snmp.yml is to use a YAML anchor+alias+merge trick:

...
if_mib: &if_mib
...
# Put this at the end of the file
if_mib_secret:
  <<: *if_mib
  version: 2
  auth:
    community: blah1234

Parthey Khanderia

unread,
May 4, 2020, 1:06:24 PM5/4/20
to Prometheus Users
Get http://snmp-exporter:9116/snmp?community=blah &module=if_mib&target=blah : context deadline exceeded

I keep getting this erro for context deadline exceeded. Also when i use the string to add in smp.yml it says error parse .yml file

Kinda stuck in a loop here. Please help

Stuart Clark

unread,
May 4, 2020, 1:18:16 PM5/4/20
to Parthey Khanderia, Prometheus Users
That error means the scrape is taking longer than the configured scrape
interval or timeout (whichever is shorter).

If you use curl or similar to make the same request, how long does it
take to reply?

--
Stuart Clark

Parthey Khanderia

unread,
May 4, 2020, 1:20:07 PM5/4/20
to Prometheus Users
snmp-exporter_1  | level=info ts=2020-05-04T17:18:29.187Z caller=collector.go:216 module=if_mib target=my_ip msg="Error scraping target" err="error getting target : context canceled"
 

Parthey Khanderia

unread,
May 4, 2020, 2:22:58 PM5/4/20
to Prometheus Users
When I do curl I get 


[1] 156655
[2] 156656
[$ 'target' parameter must be specified once
 
[1]-  Done                    curl http:ip :9116/snmp?community=string
[2]+  Done                    module=if_mib


Stuart Clark

unread,
May 4, 2020, 3:05:03 PM5/4/20
to Parthey Khanderia, Prometheus Users
As you have & in your query, which is a special character for your shell, you will need to enclose the URL in quotes.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Parthey Khanderia

unread,
May 4, 2020, 3:44:40 PM5/4/20
to Prometheus Users
That part actually worked on. My services are now up. 

The error was while creating snmp.yml


Another question I had was regarding grafana. I am using Prometheus as data source but the Vm I am running my docker-compose the port 9090 is already in use .
To go around this I am using port 9990 but when i try to add datasource it get a " http error bad gateway" 

Anything special I need to do to add datasource since it is docker-compose
Reply all
Reply to author
Forward
0 new messages