Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flxpeters/netbox-prometheus-sd
Service discovery for VMs, IPs and devices in Netbox
https://github.com/flxpeters/netbox-prometheus-sd
netbox prometheus service-discovery
Last synced: about 2 months ago
JSON representation
Service discovery for VMs, IPs and devices in Netbox
- Host: GitHub
- URL: https://github.com/flxpeters/netbox-prometheus-sd
- Owner: FlxPeters
- License: mit
- Created: 2021-02-11T20:40:19.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T04:58:11.000Z (over 1 year ago)
- Last Synced: 2024-10-14T03:25:51.766Z (2 months ago)
- Topics: netbox, prometheus, service-discovery
- Language: Python
- Homepage:
- Size: 306 KB
- Stars: 42
- Watchers: 3
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Netbox Prometheus SD
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/FlxPeters/netbox-prometheus-sd/workflows/CI/badge.svg?event=push)](https://github.com/FlxPeters/netbox-prometheus-sd/actions?query=workflow%3ACI)
[![Dockerhub](https://img.shields.io/docker/pulls/flxpeters/prometheus-netbox-sd.svg)](https://hub.docker.com/r/flxpeters/prometheus-netbox-sd)File based service discovery script for [Prometheus](https://prometheus.io/).
Make virtual machines, IPs and devices managed from [Netbox](https://github.com/netbox-community/netbox) available as Prometheus targets with labels.> **Deprecation** This project got obsolet since Prometheus supports HTTP based service discovery. Use https://github.com/FlxPeters/netbox-plugin-prometheus-sd as Netbox plugin to directly connect Prometheus with Netbox. I will still maintain this project based on the dependabot updates, but there will be no further feature development.
## Requirement
- Python >= 3.7
- [Pynetbox](https://github.com/netbox-community/pynetbox).## Config
The app is configured with env variables.
```yaml
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:
* https://github.com/enix/netbox-prometheus-sd
* https://enix.io/fr/blog/service-discovery-avec-netbox-et-prometheus/