Harnessing the Power of Prometheus and Netbox: HTTP Service Discovery for Streamlined Monitoring
Prometheus and Netbox, two powerful tools that, when combined, can supercharge your monitoring capabilities and streamline your operations. In this blog post, we’ll explore the seamless integration of Prometheus with Netbox using HTTP service discovery, which enables you to effortlessly discover and manage your network devices.
Requirements:
- Netbox version 3.5.0+
- Prometheus version 2.28.0+
Create an ‘Export Template’ in Netbox.
For this example select ‘Virtualization > Virtual Machine’ for content types.
Example template code:
[
{% for vm in queryset %}{% if vm.status and vm.primary_ip %}
{
"targets": ["{{ vm.primary_ip.address.ip }}:9100"],
"labels": {
"host": "{{ vm.name }}",
"role": "{{ vm.role }}"
}
}{% if not loop.last %},{% endif %}{% endif %}{% endfor %}
]
Under rendering put application/json for MIME type.
Make sure ‘As attachment’ is unchecked.
Validate your export template by going to this URL /api/virtualization/virtual-machines/?export=prometheus
Configure Prometheus
Job config example:
- job_name: "http_sd_netbox"
http_sd_configs:
- url: http://netbox/api/virtualization/virtual-machines/?export=prometheus
refresh_interval: 15s
authorization:
type: "Token"
credentials: "132123123123132"
Get $200 in cloud credits from DigitalOcean using my link: https://m.do.co/t/909d52b6253a