{"id":13791883,"url":"https://github.com/FlxPeters/netbox-plugin-prometheus-sd","last_synced_at":"2025-05-12T14:31:21.975Z","repository":{"id":36976268,"uuid":"372204644","full_name":"FlxPeters/netbox-plugin-prometheus-sd","owner":"FlxPeters","description":"Provide Prometheus url_sd compatible API Endpoint with data from Netbox","archived":false,"fork":false,"pushed_at":"2025-04-05T00:17:03.000Z","size":612,"stargazers_count":159,"open_issues_count":3,"forks_count":36,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T18:20:19.021Z","etag":null,"topics":["netbox-plugin","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FlxPeters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-30T12:09:10.000Z","updated_at":"2025-04-28T12:44:34.000Z","dependencies_parsed_at":"2023-02-13T23:30:47.156Z","dependency_job_id":"6b15d0e2-fbc5-4b75-ba4d-9b6f12664adf","html_url":"https://github.com/FlxPeters/netbox-plugin-prometheus-sd","commit_stats":{"total_commits":225,"total_committers":21,"mean_commits":"10.714285714285714","dds":0.5777777777777777,"last_synced_commit":"ef2b36cea1374b90db13683ba8c37d87dffe4ee0"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlxPeters%2Fnetbox-plugin-prometheus-sd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlxPeters%2Fnetbox-plugin-prometheus-sd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlxPeters%2Fnetbox-plugin-prometheus-sd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlxPeters%2Fnetbox-plugin-prometheus-sd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlxPeters","download_url":"https://codeload.github.com/FlxPeters/netbox-plugin-prometheus-sd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754967,"owners_count":21958934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["netbox-plugin","prometheus"],"created_at":"2024-08-03T22:01:05.495Z","updated_at":"2025-05-12T14:31:21.558Z","avatar_url":"https://github.com/FlxPeters.png","language":"Python","funding_links":["https://www.buymeacoffee.com/flxpeters"],"categories":["Python","Plugins"],"sub_categories":[],"readme":"# netbox-plugin-prometheus-sd\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/FlxPeters/netbox-plugin-prometheus-sd/workflows/CI/badge.svg?event=push)](https://github.com/FlxPeters/netbox-plugin-prometheus-sd/actions?query=workflow%3ACI)\n[![PyPI](https://img.shields.io/pypi/v/netbox-plugin-prometheus-sd)](https://pypi.org/project/netbox-plugin-prometheus-sd/)\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/flxpeters)\n\nProvide Prometheus `http_sd` compatible API Endpoint with data from Netbox.\n\nHTTP SD is a feature since Prometheus 2.28.0 that allows hosts to be found via a URL instead of just files.\nThis plugin implements API endpoints in Netbox to make devices, services, IPs and virtual machines available to Prometheus.\n\n## Compatibility\n\nWe aim to support the latest major versions of Netbox.\nFor now we support Netbox `\u003e= 4.0` including bugfix versions. Older versions may work, but without any guarantee.\n\nCheck the `.github/workflows/ci.yml` pipeline for the current tested builds.\nOther versions may work, but we do not test them explicitly. All relevant target versions are tested in CI.\n\n## Installation\n\nThe plugin is available as a Python package in pypi and can be installed with pip\n\n```bash\npip install netbox-plugin-prometheus-sd\n```\n\nEnable the plugin in /opt/netbox/netbox/netbox/configuration.py:\n\n```python\n    PLUGINS = ['netbox_prometheus_sd']\n```\n\nThe plugin has not further plugin configuration.\n\n## Usage\n\nThe plugin only provides a new API endpoint on the Netbox API. There is no further action required after installation.\n\n### API\n\nThe plugin reuses Netbox API view sets with new serializers for Prometheus.\nThis means that all filters that can be used on the Netbox API can also be used to filter Prometheus targets.\nPaging is disabled because Prometheus does not support paged results.\n\nThe plugin also reuses the Netbox authentication and permission model.\nDepending on the Netbox configuration, a token with valid object permissions must be passed to Netbox.\n\n```\nGET        /api/plugins/prometheus-sd/devices/              Get a list of devices in a prometheus compatible format\nGET        /api/plugins/prometheus-sd/virtual-machines/     Get a list of vms in a prometheus compatible format\nGET        /api/plugins/prometheus-sd/services/             Get a list of services in a prometheus compatible format\nGET        /api/plugins/prometheus-sd/ip-addresses/         Get a list of ip in a prometheus compatible format\n```\n\n#### Extended services filters\n\nApart from standard Netbox filters, services endpoint also supports `tenant=\u003cslug\u003e` or `tenant_id=\u003cid\u003e` parameters.\nThe lookup is only executed against the `tenant` attribute of the object associated with the service.\n\n### Config context\n\nThe plugin can also discover extra config to inject in the HTTP SD JSON from the config context of the devices/virtual machines.\nIf you have a `prometheus-plugin-prometheus-sd` entry in your config context with the following schema it will be automatically picked up:\n\n```yaml\nprometheus-plugin-prometheus-sd:\n  - metrics_path: /not/metrics\n    port: 4242\n    scheme: https\n  - port: 4243\n```\n\nThis allow you to configure those values directly into netbox instead of doing that inside the Prometheus\nconfig and filtering each scenario by a specific tag for instance.\n\nIf there is only one entry you can also use this form:\n\n```yaml\nprometheus-plugin-prometheus-sd:\n  metrics_path: /not/metrics\n  port: 4242\n  scheme: https\n```\n\n### Example\n\nA working example on how to use this plugin with Prometheus is located at the `example` folder.\nNetbox content is created by using Netbox docker initializers.\n\nThe demo data doesn't make sense, but they are good enough for demonstrating how to configure Prometheus\nand get demo data to Prometheus service discovery.\n\nGo to the `example` folder and run `docker-compose up`. Prometheus should get available on `http://localhost:9090`.\n\nPush some example devices and objects to Netbox using the initializers:\n\n```\ndocker-compose exec  netbox /opt/netbox/netbox/manage.py load_initializer_data --path /opt/netbox/initializers\n```\n\nNetbox content should then be available in the service discovery tab.\n\n## Development\n\nWe use Poetry for dependency management and invoke as task runner.\nAs Netbox plugins cannot be tested standalone, we need invoke to start all code embedded in Netbox Docker containers.\n\nAll code to run in docker is located under `develop`.\nTo start a virtual env managed by poetry run `poetry shell`.\nAll following commands are started inside this environment.\n\nIn order to run tests invoke the test steps\n\n```bash\n# Build Docker images\ninvoke build\n\n# Execute all tests\ninvoke tests\n```\n\nFeatures should be covered by a unit test, but some times it's easier to develop on an running system.\n\n```bash\n# Start a local Netbox with docker\ninvoke start\n\n# Create an user named `admin`\ninvoke create-user\n```\n\nVisit http://localhost:8000 and log in with the new user.\nYou can now define Netbox entities and test around.\n\nAPI endpoints for testing can be found at http://localhost:8000/api/plugins/prometheus-sd/\n\n## Conventional Commits\n\nThis repository follows the Conventional Commits specification for versioning and changelog generation.\nConventional Commits provide a standardized way of writing commit messages to convey semantic meaning\nabout the changes made. Each commit message follows a defined format that includes a type,\nan optional scope, and a message. The types typically include features, fixes, documentation, and more.\nBy adhering to this convention, we ensure clear and automated versioning, release notes, and changelog generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlxPeters%2Fnetbox-plugin-prometheus-sd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFlxPeters%2Fnetbox-plugin-prometheus-sd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlxPeters%2Fnetbox-plugin-prometheus-sd/lists"}