Why NetBox as a Prometheus target source keeps scrape lists accurate
If your Prometheus targets live in spreadsheets or hand-edited files while NetBox already holds the device and service inventory, you have two copies of the same facts and one of them is going stale. The fix is to let Prometheus read its targets from NetBox, so that adding, retiring or re-addressing a device in NetBox changes what gets scraped. The Prometheus integrations page lists two supported routes: a NetBox plugin and a guide on using NetBox export templates, both used for HTTP service discovery, with file-based service discovery as the fallback for anything the HTTP route cannot serve. HTTP service discovery fetches targets from an HTTP endpoint, and file-based discovery is the general interface for mechanisms Prometheus does not support natively.
Prometheus does not check whether a target is correct. It pulls from whatever targets discovery returns, so a stale status, a missing primary address or a service tagged with the wrong role in NetBox becomes a scrape job that silently monitors the wrong thing or nothing. That makes the real work mostly data quality and label design: agree which NetBox fields are authoritative (device status, primary IP, site, role, tags or custom fields), decide which of them become Prometheus labels through relabeling, and decide which devices are excluded from scraping. Confirm with your NetBox owners how often inventory is updated and who is responsible for each field before choosing between the plugin and an export template.
Treat the discovery endpoint as an access path. It should be reachable only from the Prometheus servers, authenticated, and limited to the data Prometheus needs, because the scrape list reveals your internal topology to anyone who can read it. Plan the fallback before you need it: keep a file-based configuration that can be generated from the same NetBox data so monitoring keeps running if the discovery endpoint is unavailable, and confirm the exact plugin and template versions against your NetBox release in your own environment before you build on them.
What you need before connecting Prometheus to NetBox
Connecting Prometheus to NetBox moves the scrape list out of hand-edited files and into the source of truth for your inventory. Before that happens, the Prometheus version, the NetBox side, the credentials, the network path, the certificates and the inventory data each need to be settled, because discovery copies whatever NetBox says into your monitoring.
Prometheus version and LTS line
Target the current LTS line, 3.13, which is supported until July 31, 2027, rather than a minor release that stops receiving bug fixes six weeks after its cycle begins. Confirm the exact patch level you will deploy against the release notes before the build starts, and plan the next upgrade window now so discovery settings are tested on the version you will run for the life of the LTS line. Confirm the patch level with your own change process.
Release cycle docsNetBox version and discovery approach
Confirm your NetBox version and whether the NetBox Prometheus plugin or an export template fits your setup, since the two approaches depend on different NetBox features and upgrade paths. Check this against the plugin's own compatibility notes and your NetBox release notes, not against memory. Decide early which approach you will support, because the other approach then becomes the fallback path.
Prometheus integrationsRead-only API token
Create a dedicated NetBox account and token with read-only scope limited to the objects Prometheus needs, such as devices, interfaces, IP addresses and tags. Do not reuse an administrator token, and store the token in a file or secret store that Prometheus can read without exposing it in the configuration repository. Ask your NetBox team how tokens are rotated and who can revoke them.
Network path from Prometheus to NetBox
Prometheus must reach the NetBox API over a path you have documented and permitted, usually a specific host and port through your firewall or proxy. Check whether NetBox sits in a different network zone from the Prometheus servers, and confirm that the path stays up during the scrape interval. Test the path from the exact host that runs Prometheus, not from an administrator workstation.
TLS certificates and trust
Serve the NetBox API over TLS with a certificate that Prometheus trusts, and confirm the certificate chain includes any internal certificate authority used in your environment. Prometheus supports TLS and client certificate authentication with TLS 1.2 as the minimum, so check that NetBox and any proxy in front of it meet that floor. Plan certificate renewal, because an expired certificate stops discovery without an obvious error in NetBox.
Inventory data that must be correct
Discovery only as good as the fields it reads. Before you trust it, verify that IP addresses are current and assigned to the right interfaces, that device roles and tags mark what should be scraped, and that custom fields holding ports, paths or scrape groups are filled consistently. Stale devices that remain in NetBox will generate targets that never answer, so agree an owner and a review step for inventory changes.
- Core field groups
- 3
How to configure NetBox discovery in Prometheus step by step
This sequence connects Prometheus to NetBox so scrape targets come from the inventory of record, with a file-based fallback and checks at each stage. Each step closes with a result you can confirm before moving on.
Create a read-only NetBox API token
A NetBox administrator creates a dedicated service account in NetBox, assigns it a group or permission set that allows reading only the object types Prometheus needs, such as devices, interfaces, IP addresses and the tags or custom fields used for scrape roles, and generates an API token for that account. Store the token in your secrets system rather than in a shared configuration file. The step is done when a request to the NetBox API with the token returns the expected devices and the same request with a write method is refused. Confirm the exact permission model and token format against the NetBox version you run.
Choose the discovery endpoint to serve targets
Decide whether the target list comes from a NetBox plugin that exposes an HTTP service discovery endpoint or from an export template that renders the Prometheus target JSON from NetBox data. The Prometheus integrations page lists both options for HTTP service discovery. Compare them on how they handle filtering, how they map NetBox fields to labels, who maintains the code, and whether it runs under the NetBox version you operate. The step is done when you have a written choice and a test URL that returns a JSON array of targets with a
targetslist and alabelsmap for one sample device.Deploy the endpoint and filter the inventory
The NetBox team installs the chosen plugin or saves the export template in NetBox, then limits the output with filters on site, role, status or tags so that only devices meant to be monitored appear. Add the job or environment labels here as fixed values in the template or plugin settings. Check that the endpoint is reachable from the Prometheus server over the network path you intend to use, and that it rejects requests without the token. The step is done when the endpoint returns only the filtered set and an unauthenticated request fails.
Define http_sd_configs with refresh and authorization
On the Prometheus server, the team adds an
http_sd_configsblock under the relevant scrape job inprometheus.yml, setting the endpoint URL, therefresh_intervalthat controls how often Prometheus re-fetches the list, and anauthorizationsection that reads the token from a file path that only the Prometheus service account can read. Usetls_configif NetBox is served over an internal certificate authority. Add arelabel_configssection to map NetBox fields such as site, role or device name into labels that dashboards and alert rules can use. The step is done when the configuration loads without errors after a reload and Prometheus shows the discovered target count in the service discovery view.Set up file-based discovery as a fallback
Because HTTP discovery depends on NetBox being reachable, configure a second job that uses
file_sd_configsto read a JSON target file that a scheduled job writes from the same NetBox data. Prometheus keeps the last successful list in the file, so scraping continues when the NetBox endpoint is unavailable. The export job should write to a temporary file and move it into place atomically so Prometheus never reads a partial file. Setrefresh_intervalon the file configuration to match how often the export runs. The step is done when the fallback file exists, Prometheus lists its targets under the fallback job, and you can stop the NetBox endpoint in a test environment without losing those targets.Validate configuration and target files with promtool
Before any reload, run
promtool check configagainst theprometheus.ymlfile so syntax, relabeling rules and discovery blocks are checked. Run the same check after each change to the file that the fallback job writes, using the JSON validation your team chooses, and confirm that the target file contains the expected labels for a sample device. Keep the configuration in version control so each change has a reviewable diff. The step is done when promtool reports no errors and the labels in the output match the relabeling you designed.Confirm targets on the Prometheus targets page
Reload Prometheus through the mechanism your deployment allows, then open the targets page in the web UI and check each discovery job. Confirm that the expected devices appear, that their state is up for reachable exporters, and that the labels produced by relabeling are present and correct. Remove one device from NetBox in a test environment and confirm it disappears after the next refresh, and that a device with an unreachable exporter shows as down rather than vanishing. The step is done when the target count, labels and state match your NetBox inventory and the removal test behaves as designed.
How HTTP service discovery and file fallback fit together
HTTP service discovery is the primary path, and it works as a poll loop. Prometheus requests the endpoint on its refresh interval, receives a list of target groups, each with a set of targets and labels, and merges them into its scrape configuration. If a later request fails, Prometheus keeps the last good result, so a short NetBox outage does not drop every target from the scrape set. That behavior has a limit: a prolonged outage leaves the target list frozen, and a device decommissioned in NetBox during that window keeps being scraped. Confirm the refresh interval, the timeout and the behavior on an empty or malformed response against the version you deploy, and add an alert on failed discovery requests so a stale list is visible rather than silent.
File-based discovery is the fallback, not a second source of truth. The integrations page describes file-based discovery as the interface for mechanisms Prometheus does not support natively, which is the situation when the HTTP path is unavailable, when the endpoint sits behind a network boundary that Prometheus cannot reach, or when a team wants a reviewable snapshot of what was scraped. A scheduled job can query NetBox, write the targets to a file such as targets.json in the format Prometheus expects, and validate the file before replacing the previous one, so a failed run leaves the old file in place. Keep the job's credentials read-only, and decide which of the two paths is authoritative for each job so that the same host is never discovered twice.
Export template output must match the format Prometheus parses. A NetBox export template is free text until it is checked, so a stray comma, an unescaped quote or a missing label block produces targets Prometheus cannot use. Treat the template as code: keep it in version control, render it against a sample of real devices and parse the result with the same JSON or YAML parser Prometheus uses before it is deployed. The field names used in the template (for example, the labels the template emits from device roles, sites or tags) should be agreed with the team that writes relabeling rules, because a renamed field in NetBox silently changes the labels every downstream alert and dashboard depends on.
How NetBox feeds targets into Prometheus
The diagram starts with NetBox as the source of truth, where devices, interfaces and services are recorded. An export endpoint, either the NetBox plugin or an export template, publishes those records over HTTP. Prometheus HTTP service discovery fetches the list and applies relabeling to turn NetBox fields into labels before scraping. A file-based path, shown as the fallback, writes the same list to disk for mechanisms HTTP discovery does not cover. Check that the endpoint sits behind the trust boundary and that every scrape target is intended.
Targets flow from NetBox through discovery and relabeling into scraping.
Mapping NetBox fields to Prometheus labels
This table shows how each common NetBox field should be handled when it feeds Prometheus target lists: used as the address, renamed into a label, kept as a low-cardinality label, or dropped. Read it as a starting point for your relabel_configs, then confirm field names and export output against your own NetBox version and template.
| NetBox field | Handling | Prometheus result | Notes |
|---|---|---|---|
| Primary IP | Use as the target address | __address__ with the scrape port | Strip the prefix length in the template or relabel step. Confirm which IP family your devices report. |
| Device name | Rename to a label | instance or device label | Useful for humans and alert routing. Keep names unique in NetBox so series do not collide. |
| Site | Rename to a label | site label | Low cardinality for most estates. Good for grouping dashboards and alerts by location. |
| Region | Rename to a label | region label | Use only if regions are stable. Region is often derived from site, so keep one source of truth. |
| Role | Rename to a label | role label | Strong candidate for job-style grouping, for example separating switches from firewalls in alert rules. |
| Tenant | Keep only if needed | tenant label, optional | Include when teams need per-customer views. Confirm that tenant access rules in your Prometheus frontend match. |
| Platform | Rename to a label | platform label | Helps select the right exporter or dashboard. Confirm the slug values NetBox exports for your platforms. |
| Status | Filter, then drop | Not stored as a label | Filter out planned, offline, decommissioning and failed devices before they become targets. Do not rely on a dashboard to hide them. |
| Tags | Keep a few, filter on others | Selected tag labels | Use tags for scrape intent, such as a monitoring tag. Avoid free-form tags as labels because values vary widely. |
| Serial number, asset tag, comments, custom text fields | Drop | Not exported as labels | Unique or free-text values create high cardinality and expose data that does not help queries or alerts. |
Securing the NetBox to Prometheus connection
NetBox holds the inventory that decides what Prometheus scrapes, so the connection between them needs the same care as any other credential path. The cards below cover the token, the transport, the fields it can read, and the Prometheus endpoints and probe exporters that sit downstream of discovery.
Read-only token outside the config
Give Prometheus a NetBox API token that can only read the objects it needs, and keep that token out of the main configuration file where practical. Store it in a file readable only by the Prometheus service account and reference it from the discovery settings, so the value does not appear in version control or in rendered configs shared with other teams. Ask who can rotate the token and how a revoked token is detected when targets go missing.
TLS with certificate verification
Connect to NetBox over HTTPS and keep certificate verification on. If NetBox sits behind an internal certificate authority, add that CA to the trust store Prometheus uses rather than disabling verification. A target list fetched over an unverified connection can be altered in transit, which would redirect scrapes and probes to hosts you never inventoried. Confirm the certificate chain with the same tooling your platform team uses for other internal services.
Limit fields and objects the token reads
Scope the token to the NetBox objects that define scrape targets, such as devices, virtual machines and services with the monitoring tags you use. Exclude secrets, custom fields holding credentials and tenant data that Prometheus does not need. Export templates expose only what the template outputs, but the token's permissions still decide what the API returns, so check both layers. Test the scoped token against the exact endpoint the template calls.
Lock down the Prometheus admin endpoints
Keep the admin API disabled, which is the default, and enable reload only where your deployment pipeline needs it. The --web.enable-admin-api flag unlocks destructive operations, and --web.enable-lifecycle enables reload and shutdown endpoints. Restrict network access to the web port so that an unauthenticated caller cannot trigger a reload that picks up a changed target file.
Security modelAuthenticate the UI and API at a proxy
Prometheus has no built-in single sign-on, and its security model notes there is no built-in CSRF protection on mutating endpoints. Place an authenticating reverse proxy in front of the web UI and API so that operators sign in through your identity provider. Confirm which paths the proxy protects and that the scrape and health endpoints your collectors use still work after the change.
Probe exporters fed by discovered targets
When discovered targets feed the Blackbox or SNMP exporters, the target value arrives as a URL parameter. The security model warns that anyone with HTTP access to these exporters can make them send requests to arbitrary endpoints. Restrict who can reach the exporter, limit its modules to the hosts you intend to probe, and review NetBox writes so that an edited record cannot turn a probe into a request to an unintended address.
Security modelCommon NetBox discovery failures and how to fix them
This table lists the failures teams most often hit when Prometheus pulls targets from NetBox, with the likely cause, the check to run and the fix for each. Read it as a triage guide: start from the symptom you see in Prometheus, then confirm the cause before changing the NetBox token, template or labels.
| Failure | Likely cause | Check | Fix |
|---|---|---|---|
| Discovery returns 401 or 403 | The API token has expired, was revoked, or is scoped too narrowly to read devices, interfaces or IP addresses | Call the NetBox API with the same token from the Prometheus host and compare the response with the objects the template needs | Issue a read-only token scoped to the required object types, store it as a secret file, and rotate it on a set schedule |
| TLS verification errors on the discovery endpoint | NetBox sits behind an internal certificate authority that the Prometheus host does not trust, or the certificate name does not match the host | Check Prometheus logs for x509 errors and confirm the CA bundle path in the scrape or discovery configuration | Add the internal CA to the Prometheus trust store or reference it explicitly, and avoid disabling verification |
| Empty target groups after a template change | The export template renders no output because a field name changed, a filter excludes all objects, or the template contains a syntax error | Fetch the template output directly from NetBox and confirm the JSON or file structure matches what Prometheus expects | Correct the template or filter, validate it against a known device, and keep the previous template version for rollback |
| Stale targets after a device is decommissioned | The device is still in NetBox with an active status, or Prometheus keeps the last successful discovery result when the source stops answering | Compare the discovered target list with NetBox device statuses and check the discovery refresh interval | Set decommissioned devices to a status the template excludes, and alert on discovery failures so stale lists do not persist silently |
| Duplicate targets from multiple sources | The same host is defined in a static configuration, a file-based list and the NetBox discovery at once | Search the active targets page for repeated addresses and review every job that can match the host | Choose one source of truth per job, remove the static entries, and deduplicate with relabeling or distinct job names |
| Wrong primary IP selected | A device has several addresses, and the template uses the first one returned, or the primary IP field is unset | Inspect the device's primary IPv4 and IPv6 fields in NetBox and compare them with the address in the generated target | Set the primary IP in NetBox as part of onboarding, and make the template fail loudly when the field is empty |
| Labels that explode cardinality | Templates copy high-variance fields such as serial numbers, free-text comments, timestamps or interface descriptions into labels | Review label names and count distinct values per label in the Prometheus series data | Keep only stable identifiers such as site, role, tenant and device type as labels, and drop volatile fields during relabeling |
Questions teams ask before connecting NetBox to Prometheus
How much effort does connecting NetBox to Prometheus take?
Effort depends mostly on how well NetBox already describes your devices and services, not on Prometheus itself. The main drivers are the number of devices and services to represent, the number of sites, how consistently roles, tags, custom fields and IP addresses are filled in, and how much label design you need. A small estate with clean NetBox data is a short exercise. An estate where device roles are inconsistent or hosts have no primary IP usually needs a cleanup pass first. Ask any partner to size the work by inspecting a sample of your NetBox data and listing the export templates and relabeling rules the target list requires.
Can our in-house team connect NetBox to Prometheus without a partner?
Often yes, if you already run NetBox and Prometheus and have someone comfortable with both. The work is configuration rather than custom software: an HTTP service discovery endpoint or a file-based target list, relabeling rules, and a token with read access. The harder parts are usually data governance (agreeing which NetBox fields mean what), testing that targets appear and relabel correctly, and documenting who changes what. Teams that lack Prometheus or NetBox depth, or that need the change reviewed for security, often bring in outside help for the design and review stages only.
What do we need to provide before the work starts?
Plan for four things. First, NetBox admin access, or an admin who can create a read-only API token, review export templates and confirm which objects are in scope. Second, a named Prometheus owner who can approve scrape configuration changes and reload or restart the server. Third, a change window for the first rollout, because a bad target list can drop series or flood the server with probes. Fourth, a list of the teams that own the hosts being added, so that new targets are not scraped without an owner to respond to alerts. Ask the partner to confirm this list in writing as part of the scope.
Is the NetBox integration a one-time project or ongoing work?
Both. The initial build (templates, relabeling, validation and rollout) is one-time work. After that, some tasks recur: rotating the NetBox API token on a schedule, updating export templates when NetBox fields or roles change, reviewing relabeling rules when new device types arrive, and upgrading NetBox and Prometheus as their releases move on. Prometheus publishes minor releases every 6 weeks and long-term support lines, so the upgrade effort depends on which line you run. Ask whether a retainer or internal ownership covers these tasks before you sign off on the build.
When is file-based discovery a better choice than HTTP service discovery?
File-based discovery is the better choice when you need a fallback, when NetBox is not reachable from the Prometheus server, or when you want a reviewable change path. Prometheus reads target files from disk, so a generated file can be checked into version control, validated in CI and reviewed before it goes live. HTTP service discovery fetches targets from an endpoint on each refresh, which removes the file generation step but makes the NetBox endpoint a runtime dependency. Many teams use HTTP discovery as the primary source and keep file-based discovery as a last-known-good fallback. Confirm the current behavior of each discovery mechanism against the Prometheus integrations documentation before you choose.
What data quality problems break NetBox-driven scrape targets?
The usual failures are missing or duplicate primary IP addresses, devices without a role or site, services recorded under the wrong host, and stale objects that were decommissioned in the field but never removed in NetBox. Each one produces either targets that never respond, scrapes that fail silently, or series with wrong site and role labels that route alerts to the wrong team. Before connecting anything, export a list of devices with missing fields and agree who fixes them. Treat NetBox as the source of truth only after that cleanup, and add a check that flags targets with no data for a set period.
Does connecting NetBox expose extra security risk to Prometheus?
It adds a credential and a network path, so it deserves review. The integration needs a NetBox API token, which should be read-only, scoped as narrowly as NetBox allows, stored as a secret and rotated on a schedule. Prometheus needs network access to NetBox, so restrict that path to the Prometheus server. Also note that Prometheus admin and lifecycle endpoints are disabled by default, and the Prometheus security model says that exporters taking targets from URL parameters can be abused by anyone with HTTP access to them, so a broader target list increases what those exporters can reach. Have your security team review the token scope and network rules as part of the change.
Official Prometheus and NetBox integration references
The Prometheus integrations page is the first place to check what the official project supports for NetBox. It lists NetBox under file-based service discovery and, for HTTP service discovery, points to a NetBox plugin and a guide on using NetBox export templates. Read it before you choose a method, because the two paths have different moving parts: the plugin and export templates produce an HTTP endpoint that Prometheus polls, while file-based discovery means a separate job writes target files that Prometheus reloads. The page is the right source for confirming which NetBox plugin and template guide match your NetBox version, and for checking whether the integration is listed as supported or only described.
The Prometheus configuration reference covers the settings you will write into prometheus.yml, including the http_sd_configs and file_sd_configs blocks, refresh intervals, authorization options and how relabeling rules are applied to discovered targets. Use it to confirm exact key names and defaults for the Prometheus version you run, since discovery options have changed across releases and the Prometheus upgrade planning pages list breaking changes. Pair it with the NetBox documentation for the API fields your export templates read, so that the labels you derive from device roles, sites or tags match fields that exist in your NetBox data model. Confirm both sources against your own versions before you rely on them in production.
How DeployOpen scopes and delivers a NetBox to Prometheus integration
DeployOpen treats NetBox as a Prometheus target source as a scoped integration inside your own infrastructure. We agree which NetBox objects become scrape targets, how their fields map to labels, and how file-based discovery covers failure cases, then build and test the pipeline before handing it over with documentation.
How we scope
- Inventory which NetBox objects, roles and tags should become Prometheus scrape targets
- Agree the field-to-label mapping, including which fields stay out of labels to limit cardinality
- Confirm the NetBox version, plugin or export template approach and where the endpoint runs
- Document the written scope, deliverables and timeline before any work starts, as fixed-scope engagements
How we build
- Configure HTTP service discovery against the NetBox endpoint with authentication and TLS settings
- Write relabeling rules that turn site, role, tenant and status fields into consistent labels
- Build a file-based discovery fallback so Prometheus keeps scraping known targets if NetBox is unreachable
- Test target lists, label output and removal of decommissioned devices in a staging Prometheus first
How we hand over
- Deliver the Prometheus configuration, export template or plugin settings and relabeling rules as versioned files
- Document how a NetBox change reaches a target, with a worked example for adding a new device
- Provide runbooks for diagnosing targets that disappear from discovery or stop reporting
- Walk your platform and network teams through the setup so they can review and operate it
How we support
- Retest discovery and relabeling after NetBox or Prometheus upgrades within the agreed scope
- Offer ongoing support, upgrades and continuous testing as a retainer if your team wants them
- Review label changes and scrape configuration when new device types or sites are added
- Confirm the support boundary, response expectations and ownership of NetBox data in the written scope

