Git Product home page Git Product logo

netbox-prometheus-sd's Introduction

Service discovery for Prometheus using devices from 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 <antoine.millet at enix.io>

Requirement

This project requires Python 3 and 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'

netbox-prometheus-sd's People

Contributors

naps avatar npdgm avatar rosiak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbox-prometheus-sd's Issues

Empty output file

Hi
so i seem to be seeing an empty output file when i run the script. Is there a specific value that must be set for prom_labels that the script will check in netbox?

Filtering, multiple SNMP exporters

Hey !

Just read your blog post regarding Prometheus and Netbox, thanks, very interesting!
I plan to use your project, and I want to add filtering of retrieved devices (including auto-filtering of the master device of Virtual-Chassis devices) based on any field (tenant, region, ...)

We're using Blackboxes as SNMP exporter on each site location, which means the target_label: __address__ replacement should be dynamic based on the device site. I think there is no other solution than multiple jobs.
I would like to include snmp module selection based on device_type + role instead of __snmp_module__ in Netbox prom_labels field

I was considering using jinja templates before I found your more elegant solution.
And also, I want to have the prometheus jobs config file generated automatically, probably the only way if I want 1 job per site / role

What do you think about this?
I'll share my achievements in the following weeks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.