Skip to content

zelfix/netbox-prometheus-sd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netbox-prometheus-sd

Provide Prometheus http_sd compatible API Endpoint with data from Netbox.

HTTP SD is a new feature in Prometheus 2.28.0 that allows hosts to be found via a URL instead of just files. This plugin implements API endpoints in Netbox to make devices, IPs and virtual machines available to Prometheus.

Installation and configuration

  1. The plugin is available as a Python package in pypi and can be installed with pip
pip install netbox-prometheus-sd
  1. Create a boolean custom field in the netbox, which will be used to determine if the device is to be in prometheus targets list. Bind this custom field to the device objects. In this case we use 'monitored' custom field.

  2. Enable the plugin in /opt/netbox/netbox/netbox/configuration.py:

PLUGINS = ['netbox_prometheus_sd']
  1. In the plugin settings, specify a name of boolean custom field which is used for monitoring and target port.
PLUGINS_CONFIG = {
    'netbox_prometheus_sd': {
        'custom_field_name': 'monitored',
        'target_port': 5909,
        'gnmic_target_port': 32767,
    }
}

Usage

The plugin only provides a new API endpoint on the Netbox API. There is no further action required after installation and configuration.

API

The plugin reuses Netbox API view sets with new serializers for Prometheus and gnmic. This means that all filters that can be used on the Netbox api can also be used to filter targets. Paging is disabled because Prometheus does not support paged results.

The plugin also reuses the Netbox authentication and permission model. Depending on the Netbox configuration, a token with valid object permissions must be passed to Netbox.

GET        /api/plugins/prometheus-sd/devices/              Get a list of devices in a prometheus compatible format
GET        /api/plugins/prometheus-sd/gnmic-devices/        Get a list of devices in a gnmic compatible format

About

Provide Prometheus url_sd compatible API Endpoint with data from Netbox

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%