This guide explains how to use Nautobot as the source of truth for device metadata in Convergence.
- Nautobot stores all device information (hostname, IP, vendor, site, role, etc.)
- Python script queries Nautobot API and generates OTEL Collector configuration
- OTEL Collector collects metrics with proper device labels automatically
- Grafana displays metrics with accurate device names and metadata
Edit .env file and add your Nautobot details:
# Nautobot Configuration
NAUTOBOT_URL=http://nautobot:8000 # Your Nautobot URL
NAUTOBOT_TOKEN=your-api-token-here # Get from Nautobot UI: Admin → API TokensTo create a Nautobot API token:
- Log into Nautobot
- Go to Admin → Users → API Tokens
- Click Add and create a new token
- Copy the token to your
.envfile
List all devices from Nautobot:
cd /mnt/d/ubuntu-24-04-bbaker4/github-projects/Convergence
python scripts/nautobot_device_discovery.py --list-devicesExpected output:
✅ Found 5 devices in Nautobot
📋 Devices in Nautobot:
• core-switch-1
IP: 192.168.1.1
Vendor: cisco (Catalyst 9300)
Role: core-switch
Site: datacenter-1
Status: active
• edge-switch-2
IP: 192.168.3.2
Vendor: cisco (Catalyst 2960)
Role: access-switch
Site: office-main
Status: active
Generate OTEL Collector config from Nautobot:
python scripts/nautobot_device_discovery.py --generate-config > config/nautobot-devices.yamlThis creates SNMP receiver configs for all active devices in Nautobot with proper labels:
device.name- Actual hostname from Nautobotdevice.ip- Management IPdevice.vendor- Manufacturerdevice.model- Device modeldevice.role- Device role (core, access, etc.)device.site- Physical site location
Option A: Manual (one-time setup)
# Review the generated config
python scripts/nautobot_device_discovery.py --generate-config
# Copy the receivers and processors sections to config/otel-collector/config.yaml
# Update the service.pipelines section with the new receiver/processor names
# Restart OTEL Collector
docker-compose restart otel-collectorOption B: Automated (recommended)
# TODO: Add script to automatically update OTEL config and reload
./scripts/sync_nautobot_devices.shFor devices to be discovered, they must have:
- Primary IPv4 address configured
- Status: Active (staging/offline devices are skipped)
- Device type assigned (for vendor/model info)
- Site assigned
- Device role assigned
✅ Single Source of Truth - Update device name in Nautobot, metrics are automatically updated
✅ Rich Metadata - Site, role, model info on every metric
✅ Auto-Discovery - New devices in Nautobot = automatic monitoring
✅ No Manual Config - No need to manually update OTEL config for each device
✅ Accurate Hostnames - Real device names, not made-up labels
Before:
interface_in_octets_bytes_total{
device_ip="192.168.3.2",
device_vendor="cisco",
interface_name="GigabitEthernet1/0/1"
}
After:
interface_in_octets_bytes_total{
device_name="edge-switch-2",
device_ip="192.168.3.2",
device_vendor="cisco",
device_model="Catalyst 2960",
device_role="access-switch",
device_site="office-main",
interface_name="GigabitEthernet1/0/1"
}
Now you can filter by real attributes:
# All interfaces at a specific site
interface_in_octets_bytes_total{device_site="datacenter-1"}
# All core switches
interface_in_octets_bytes_total{device_role="core-switch"}
# Traffic for a specific device by name
rate(interface_in_octets_bytes_total{device_name="edge-switch-2"}[5m]) * 8
Run device discovery on a schedule to auto-discover new devices:
# Add to crontab
0 * * * * cd /path/to/Convergence && python scripts/nautobot_device_discovery.py --generate-config > config/nautobot-devices.yaml && docker-compose restart otel-collectorThis checks Nautobot every hour for new devices and updates monitoring automatically.
- Make sure
.envfile hasNAUTOBOT_TOKEN=... - Load env vars:
source .envorexport $(cat .env | xargs)
- Check
NAUTOBOT_URLis correct and Nautobot is accessible - Verify API token is valid (check in Nautobot UI)
- Check network connectivity:
curl -H "Authorization: Token YOUR_TOKEN" http://nautobot:8000/api/dcim/devices/
- Check devices in Nautobot have:
- Status = Active
- Primary IP configured
- Device type assigned
- Set up your Nautobot URL and token in
.env - Run
--list-devicesto verify connection - Run
--generate-configto see generated config - Apply config and restart OTEL Collector
- Check Grafana - devices now have real names!