End-to-End Guide to Prometheus SNMP Exporter Deployment in Kubernetes [Part-2]

Welcome to the second part. Here let’s focus on:

  • SNMP Exporter – Helm Deployment
  • Validating Prometheus Target for Metrics Collection

Install Prometheus SNMP Exporter (Helm):

Step1: Create a config map with the snmp file loaded [In Prod, you can use original chart as a sub-chart and build a wrapper with configmap in it for deployment]

kubectl create configmap snmp-config-map --from-file=snmp.yml

Step2: Download the values.yaml from https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus-snmp-exporter/values.yaml

Step3: Update helm values and save as custom-values.yaml

In the extraConfigmapMounts section, you need to refer previously created config map here.

extraConfigmapMounts: 
  - name: snmp-config-map
    mountPath: /etc/snmp_exporter
    configMap: snmp-config-map
    readOnly: true
    defaultMode: 420

Update ServiceMonitor Section, for module name, refer the earlier post section “Step2: SNMP Exporter Config Generator”

serviceMonitor:
  enabled: true
  namespace: <namespace>
  path: /snmp
  scrapeTimeout: 10s
  module:
    - MELLANOX
  auth:
    - public_v3
  selector:
    release: <add the label as per your environment>

  params: 
    - name: "DE059-SW-SAN701"
      target: 10.55.20.149
      module:
      - MELLANOX

Step4: Install the chart:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install snmp-exporter prometheus-community/prometheus-snmp-exporter -f custom-values.yaml

Validate Data Collection:

Step1: Login to Prometheus, goto Targets section

You should see metrics getting collected.

Troubleshooting

If you notice any other error like HTTP 500, then it could be due to:

  • Connection issue: Network Device not reachable from cluster
  • Authentication Issue
  • SNMP related errors

Step1: Deploy Alpine Pod, save the below file and do kubectl apply

apiVersion: v1
kind: Pod
metadata:
  name: alpine
spec:
  containers:
    - image: alpine:latest
      command:
        - /bin/sh
        - "-c"
        - "sleep 60m"
      imagePullPolicy: IfNotPresent
      name: alpine
  restartPolicy: Always

Step2: Login inside alpine pod

kubectl -n <namespace> exec -it alpine -- sh

Step3: Install snmp package

/ # apk add net-snmp-tools

Step4: Connectivity Test

/ # ping <target-network-device>

If the ping fails then involve relevant team to troubleshoot further by providing traceroute details

Step5: Run snmpwalk command

/ # snmpwalk -v3 -l authPriv -u <username> -a SHA -A <password> -x AES -X <AES\DES Password> <target-network-device> <OID>

Example:

/ # snmpwalk -v3 -l authPriv -u prometheus -a SHA -A prometheus -x AES -X prometheus 10.xx.xx.xx 1.3.6.1.4.1.48690.1.2

You can get any oid from the snmp.yml file

Step6: View Metrics Scrapped: (Right click on the Endpoint URL of Service Monitor from Prometheus Targets Section and Copy the URL)

/ # apk add curl
/ # curl "http://10.42.0.54:9116/snmp?auth=public_v3&module=MELLANOX&target=10.xx.xx.xx"

Leave a comment