https://github.com/enix/netbox-prometheus-sd
Service discovery for Prometheus using devices from Netbox
https://github.com/enix/netbox-prometheus-sd
Last synced: 8 months ago
JSON representation
Service discovery for Prometheus using devices from Netbox
- Host: GitHub
- URL: https://github.com/enix/netbox-prometheus-sd
- Owner: enix
- License: mit
- Created: 2018-11-06T14:18:08.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-06T09:05:12.000Z (almost 6 years ago)
- Last Synced: 2025-04-05T09:23:23.919Z (9 months ago)
- Language: Python
- Size: 11.7 KB
- Stars: 41
- Watchers: 12
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
Service discovery for [Prometheus](https://prometheus.io/) using devices from [Netbox](https://github.com/digitalocean/netbox).
# Legal
This project is released under MIT license, copyright 2018 ENIX SAS.
# Contribute
Feel free to contribute to this project through Github pull-requests. We also
accept well formatted git patches sent by email to the maintainer.
Current Maintainer: Antoine Millet
# Requirement
This project requires Python 3 and [Pynetbox](https://github.com/digitalocean/pynetbox/).
Also, this project requires a custom field to be created into your Netbox instance.
By default, this custom field is named `prom_labels` and can be created in the
Netbox admin page (Home -> Extras -> Custom fields) with the following settings:
- Objects: select `dcim > device` and `virtualization > virtual machine`
- Type: `Text`
- Name: `prom_labels`
# Usage
```
usage: netbox-prometheus-sd.py [-h] [-p PORT] [-f CUSTOM_FIELD]
url token output
positional arguments:
url URL to Netbox
token Authentication Token
output Output file
optional arguments:
-h, --help show this help message and exit
-p PORT, --port PORT Default target port; Can be overridden using the
__port__ label
-f CUSTOM_FIELD, --custom-field CUSTOM_FIELD
Netbox custom field to use to get the target labels
```
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.
Optionally, you can customize the custom field used to get target labels in Netbox
using the `--custom-field` option. You can also customize the default port on which
the target will point to using the `--port` option. Note that this port can be customized
per target using the `__port__` label set in the custom field.
The output will be generated in the file pointed by the `output` argument.
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'
```