Integrate SNMP monitoring with InfluxDB and Telegraf for time-series analysis

Intermediate 45 min Apr 04, 2026 197 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Learn to set up a comprehensive SNMP monitoring solution using InfluxDB 2.7 for time-series storage and Telegraf for data collection. Configure monitoring for network devices, system metrics, and create visualization dashboards with Grafana.

Prerequisites

  • Root or sudo access
  • Network devices with SNMP enabled
  • At least 4GB RAM
  • Basic understanding of networking concepts
  • Familiarity with time-series databases

What this solves

SNMP (Simple Network Management Protocol) monitoring provides essential visibility into network devices, servers, and infrastructure components. This tutorial shows you how to build a production-grade monitoring stack using InfluxDB 2.7 for time-series data storage, Telegraf for SNMP data collection, and Grafana for visualization. You'll learn to monitor network interfaces, system resources, and custom OIDs across your infrastructure.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest versions of dependencies.

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget curl gnupg2 software-properties-common apt-transport-https
sudo dnf update -y
sudo dnf install -y wget curl gnupg2 yum-utils

Install InfluxDB 2.7

Add the InfluxData repository and install InfluxDB 2.7 for time-series data storage.

wget -qO- https://repos.influxdata.com/influxdata-archive_compat.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install -y influxdb2
cat <

Configure InfluxDB service

Enable and start InfluxDB, then configure the initial setup through the web interface.

sudo systemctl enable --now influxdb
sudo systemctl status influxdb

Open your web browser and navigate to http://your-server-ip:8086 to complete the initial setup. Create your organization, bucket, and obtain the API token.

Install Telegraf

Install Telegraf to collect SNMP metrics and send them to InfluxDB.

sudo apt install -y telegraf snmp snmp-mibs-downloader
sudo dnf install -y telegraf net-snmp net-snmp-utils

Configure Telegraf for SNMP monitoring

Create a comprehensive Telegraf configuration that includes SNMP inputs and InfluxDB output. This configuration monitors network interfaces, system resources, and custom metrics.

# Global Agent Configuration
[agent]
  interval = "30s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  hostname = ""
  omit_hostname = false

InfluxDB v2 Output Plugin

[[outputs.influxdb_v2]] urls = ["http://localhost:8086"] token = "your-influxdb-token-here" organization = "your-org" bucket = "snmp-metrics" timeout = "5s"

SNMP Plugin for Network Interfaces

[[inputs.snmp]] agents = ["192.168.1.1:161", "192.168.1.2:161"] version = 2 community = "public" name = "network_interfaces" timeout = "5s" retries = 3 # Interface Statistics [[inputs.snmp.field]] name = "hostname" oid = "1.3.6.1.2.1.1.5.0" is_tag = true [[inputs.snmp.table]] name = "interface" inherit_tags = ["hostname"] oid = "1.3.6.1.2.1.2.2" [[inputs.snmp.table.field]] name = "name" oid = "1.3.6.1.2.1.2.2.1.2" is_tag = true [[inputs.snmp.table.field]] name = "type" oid = "1.3.6.1.2.1.2.2.1.3" [[inputs.snmp.table.field]] name = "speed" oid = "1.3.6.1.2.1.2.2.1.5" [[inputs.snmp.table.field]] name = "admin_status" oid = "1.3.6.1.2.1.2.2.1.7" [[inputs.snmp.table.field]] name = "oper_status" oid = "1.3.6.1.2.1.2.2.1.8" [[inputs.snmp.table.field]] name = "in_octets" oid = "1.3.6.1.2.1.2.2.1.10" conversion = "float" [[inputs.snmp.table.field]] name = "out_octets" oid = "1.3.6.1.2.1.2.2.1.16" conversion = "float" [[inputs.snmp.table.field]] name = "in_errors" oid = "1.3.6.1.2.1.2.2.1.14" [[inputs.snmp.table.field]] name = "out_errors" oid = "1.3.6.1.2.1.2.2.1.20"

SNMP Plugin for System Resources

[[inputs.snmp]] agents = ["192.168.1.1:161", "192.168.1.2:161"] version = 2 community = "public" name = "system_resources" timeout = "5s" retries = 3 [[inputs.snmp.field]] name = "hostname" oid = "1.3.6.1.2.1.1.5.0" is_tag = true [[inputs.snmp.field]] name = "uptime" oid = "1.3.6.1.2.1.1.3.0" conversion = "float" [[inputs.snmp.field]] name = "cpu_usage" oid = "1.3.6.1.4.1.2021.11.9.0" conversion = "float" [[inputs.snmp.field]] name = "memory_total" oid = "1.3.6.1.4.1.2021.4.5.0" conversion = "float" [[inputs.snmp.field]] name = "memory_free" oid = "1.3.6.1.4.1.2021.4.6.0" conversion = "float" [[inputs.snmp.field]] name = "disk_usage" oid = "1.3.6.1.4.1.2021.9.1.9.1" conversion = "float"

Configure SNMP community and security

Update the Telegraf configuration with your actual SNMP settings. Replace the placeholder values with your network configuration.

sudo cp /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.backup
sudo nano /etc/telegraf/telegraf.conf
Note: Replace "your-influxdb-token-here" with your actual InfluxDB API token, and update the agents list with your network device IP addresses.

Install and configure Grafana

Install Grafana for creating dashboards and visualizing SNMP metrics from InfluxDB.

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
cat <

Enable and start all services

Start Telegraf and Grafana services and ensure they start automatically on boot.

sudo systemctl enable --now telegraf
sudo systemctl enable --now grafana-server
sudo systemctl status telegraf grafana-server

Configure firewall rules

Open the necessary ports for InfluxDB (8086) and Grafana (3000) web interfaces.

sudo ufw allow 8086/tcp comment "InfluxDB"
sudo ufw allow 3000/tcp comment "Grafana"
sudo ufw reload
sudo firewall-cmd --permanent --add-port=8086/tcp --add-port=3000/tcp
sudo firewall-cmd --reload

Configure Grafana data source

Access Grafana at http://your-server-ip:3000 (admin/admin) and add InfluxDB as a data source. Use the following settings for the InfluxDB connection.

URL: http://localhost:8086
Database: (leave empty for InfluxDB 2.x)
Organization: your-org
Token: your-influxdb-token-here
Default Bucket: snmp-metrics

Create SNMP monitoring dashboard

Import or create a dashboard for SNMP metrics. Here's a sample query for network interface traffic monitoring.

from(bucket: "snmp-metrics")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "interface")
  |> filter(fn: (r) => r["_field"] == "in_octets" or r["_field"] == "out_octets")
  |> derivative(unit: 1s, nonNegative: true)
  |> map(fn: (r) => ({ r with _value: r._value * 8.0 }))
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

Configure advanced SNMP monitoring

Add custom OID monitoring

Extend your Telegraf configuration to monitor custom OIDs specific to your equipment. This example shows how to add vendor-specific metrics.

# Custom OID monitoring for specific devices
[[inputs.snmp]]
  agents = ["192.168.1.10:161"]
  version = 2
  community = "monitoring"
  name = "custom_metrics"
  timeout = "10s"
  retries = 3

  # Custom temperature monitoring (example Cisco OID)
  [[inputs.snmp.field]]
    name = "device_name"
    oid = "1.3.6.1.2.1.1.5.0"
    is_tag = true

  [[inputs.snmp.field]]
    name = "temperature"
    oid = "1.3.6.1.4.1.9.9.13.1.3.1.3.1"
    conversion = "float"

  # Power supply status
  [[inputs.snmp.field]]
    name = "power_status"
    oid = "1.3.6.1.4.1.9.9.13.1.5.1.3.1"

  # Fan speed monitoring
  [[inputs.snmp.field]]
    name = "fan_speed"
    oid = "1.3.6.1.4.1.9.9.13.1.4.1.3.1"
    conversion = "float"

Configure SNMP v3 authentication

For production environments, configure SNMPv3 with authentication and privacy for secure monitoring.

[[inputs.snmp]]
  agents = ["192.168.1.1:161"]
  version = 3
  timeout = "5s"
  retries = 3
  
  # SNMPv3 Authentication
  sec_name = "monitoring_user"
  auth_protocol = "SHA"
  auth_password = "strong_auth_password"
  sec_level = "authPriv"
  priv_protocol = "AES"
  priv_password = "strong_priv_password"
  
  name = "secure_monitoring"
  
  [[inputs.snmp.field]]
    name = "hostname"
    oid = "1.3.6.1.2.1.1.5.0"
    is_tag = true

Set up alerting rules

Configure InfluxDB alerts or Grafana alerts to notify you of critical SNMP metrics. This example shows setting up a high CPU usage alert.

sudo systemctl restart telegraf
sudo journalctl -u telegraf -f

Verify your setup

Check that all services are running correctly and collecting data.

# Verify all services are running
sudo systemctl status influxdb telegraf grafana-server

Check Telegraf is collecting SNMP data

sudo journalctl -u telegraf --since "5 minutes ago" | grep -i snmp

Test SNMP connectivity manually

snmpwalk -v2c -c public 192.168.1.1 1.3.6.1.2.1.1.5.0

Check InfluxDB data ingestion

curl -H "Authorization: Token your-token" "http://localhost:8086/api/v2/query?org=your-org" \ -d 'from(bucket:"snmp-metrics") |> range(start: -1h) |> limit(n:10)'

Verify Grafana is accessible

curl -s http://localhost:3000/api/health
Note: If you see SNMP timeout errors, verify that your network devices have SNMP enabled and the community string is correct. Check firewall rules on both the monitoring server and target devices.

Performance optimization

Optimize data retention

Configure appropriate data retention policies in InfluxDB to manage storage usage for time-series data.

# Create retention policy for SNMP data (30 days)
influx bucket create \
  --name snmp-metrics-30d \
  --org your-org \
  --retention 720h \
  --token your-token

Create downsampling task for long-term storage

influx task create \ --org your-org \ --token your-token \ --file downsample-task.flux

Configure collection intervals

Adjust Telegraf collection intervals based on your monitoring requirements and network capacity.

# High-frequency monitoring for critical interfaces
[[inputs.snmp]]
  agents = ["192.168.1.1:161"]
  interval = "10s"
  # ... interface configuration

Standard monitoring for general metrics

[[inputs.snmp]] agents = ["192.168.1.2:161", "192.168.1.3:161"] interval = "60s" # ... system configuration

Common issues

Symptom Cause Fix
SNMP timeout errors Network connectivity or wrong community string Test with snmpwalk -v2c -c public target-ip 1.3.6.1.2.1.1.1.0
No data in InfluxDB Wrong token or organization name Verify token with influx auth list and check Telegraf logs
Telegraf startup fails Configuration syntax error Test config with telegraf --config /etc/telegraf/telegraf.conf --test
High memory usage Too many metrics or short intervals Increase intervals, reduce OID count, or add metric filtering
Missing MIB information MIB files not installed Install with sudo apt install snmp-mibs-downloader and update /etc/snmp/snmp.conf
Grafana connection failed Wrong InfluxDB URL or credentials Test connection from Grafana data source configuration page

Next steps

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle managed devops services for businesses that depend on uptime. From initial setup to ongoing operations.