Sign inSign up

flxpeters/prometheus-netbox-sd

By flxpeters

•Updated almost 4 years ago

Image
0

3.1K

flxpeters/prometheus-netbox-sd repository overview

⁠Netbox Prometheus SD

License: MIT CI Dockerhub

File based service discovery script for Prometheus⁠. Make virtual machines, IPs and devices managed from Netbox⁠ available as Prometheus targets with labels.

⁠Requirement

⁠Config

The app is configured with env variables.

    NETBOX_SD_URL: https://netboxdemo.com
    NETBOX_SD_TOKEN:  72830d67beff4ae178b94d8f781842408df8069d
    NETBOX_FILTER: "{\"status\":\"active\",\"site\":\"ds9\"}"
    NETBOX_SD_FILE_PATH: /data/netbox/netbox.json
    NETBOX_SD_LOG_LEVEL: "DEBUG"
    NETBOX_SD_VERIFY_SSL: "FALSE"
    NETBOX_THREADING: "True"
    NETBOX_SD_LOOP_DELAY: "60"
    NETBOX_SD_METRICS_PORT: "8000"
    NETBOX_OBJECTS: "vm device" # space separated list of netbox objects to discover. Currently supported: vm, device and ip_address

Filters are applied as JSON which is mapped to Netbox filter criterias.
See the Netbox for more Details: https://netbox.readthedocs.io/en/stable/rest-api/filtering/⁠

⁠Usage

python3 netbox-prometheus-sd.py

The service discovery script requires the URL to the Netbox instance, an API token that can be generated into the user profile page of Netbox and a path to an output file.

In the Prometheus configuration, declare a new scrape job using the file_sd_configs service discovery:

- job_name: 'netbox'
  file_sd_configs:
  - files:
    - '/path/to/my/output.json'

⁠Example

See example directory for an example on how this service discovery. Currently we use netboxdemo.com for this. This should be changed to a local Docker based Netbox stack.

⁠Thanks & Credits

This project is based on a Script from ENIX SAS:

Tag summary

Content type

Image

Digest

Size

21.7 MB

Last updated

almost 5 years ago

docker pull flxpeters/prometheus-netbox-sd