NetBox Loki Logs Plugin
Fork from https://github.com/sieteunoseis/netbox-graylog
A NetBox plugin that displays recent Loki logs on Device, VirtualMachine, and optional Endpoint detail pages.
What Changed
This fork replaces the unfinished Graylog integration with a Loki-based implementation:
- Queries Loki via
/loki/api/v1/query_range - Supports optional
X-Scope-OrgID, bearer token, and basic auth - Matches devices by a configurable Loki label such as
routerboard,host, orhostname - Can fall back to a NetBox primary IP when hostname lookup returns no results
- Provides a Loki summary dashboard widget based on LogQL aggregations
Features
- Logs tab on Device and VirtualMachine pages
- Optional Endpoint support when
netbox_endpointsis installed - Time range selector for 5m, 15m, 1h, 4h, 24h, and 7d
- Caching to reduce API load on Loki
- Connection test from the plugin settings page
- Shortname/FQDN matching for label-based hostname lookups
Requirements
- NetBox 4.0 or higher
- Python 3.11+
- Grafana Loki reachable from the NetBox instance
Installation
source /opt/netbox/venv/bin/activate
pip install netbox-loki
or for dev
git clone https://github.com/SerhiiZahuba/netbox-loki.git
cd netbox-graylog
pip install -e .
Configuration
Add the plugin to NetBox:
PLUGINS = [
"netbox_loki",
]
PLUGINS_CONFIG = {
"netbox_loki": {
"loki_url": "http://loki:3100",
"loki_external_url": "https://grafana.example.com/explore",
"loki_tenant": "loki_tenant",
"loki_username": "",
"loki_password": "",
"loki_bearer_token": "",
"loki_job": "syslog",
"device_label": "routerboard",
"stream_selector": "",
"log_limit": 100,
"time_range": 3600,
"timeout": 10,
"cache_timeout": 60,
"verify_tls": True,
"use_regex_matching": True,
"fallback_to_ip": True,
}
}
Loki Query Model
The plugin builds LogQL stream selectors like:
{job="syslog",routerboard=~"^edge-sw01(?:\\..+)?$"}
You can further narrow the stream by setting stream_selector, for example:
"stream_selector": 'site="kyiv",env="prod"'
Notes
device_labelshould point to the Loki label that contains the NetBox object name.- If your labels contain FQDNs while NetBox stores short names, leave
use_regex_matching=True. loki_external_urlis only used for opening the log platform from the UI; API calls still useloki_url.- Authorization in Loki is commonly provided by a reverse proxy or managed service. This plugin supports optional bearer token and basic auth for that case.
Troubleshooting
No logs appear
- Verify the object name in NetBox matches the configured Loki label value.
- Confirm
device_labelpoints to the correct Loki label. - Check
stream_selectorandloki_jobare not overly restrictive. - Enable
fallback_to_ipif your logs are labeled by IP rather than hostname.
Connection test fails
- Verify
loki_urlis reachable from the NetBox host or container. - If Loki uses multi-tenancy, set
loki_tenant. - If TLS is self-signed, set
verify_tls=False. - If access is proxied, configure
loki_bearer_tokenorloki_username/loki_password.
Development
pip install -e ".[dev]"
License
Apache License 2.0 - see LICENSE.
Reference
Metadata
Release files for netbox-loki 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbox_loki-0.0.8.tar.gz | 22.2 kB | With provenance | Details for netbox_loki-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netbox_loki-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for netbox_loki-0.0.8-py3-none-any.whl |
Total release size: 48.7 kB
Release files / netbox_loki-0.0.8.tar.gz
| Download URL | netbox_loki-0.0.8.tar.gz |
|---|---|
| Size | 22.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e6e19e0353ca14c5afa2fba5bdbf6aaf4102c4b81a3281a63ff6af2b1d4c04b
|
|
BLAKE2b-256 checksum How to use checksums |
c6c864ff6f9acbc4c0cad3e8f8ada964e83508dde7f6712370a5d5ece40a55c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logRelease files / netbox_loki-0.0.8-py3-none-any.whl
| Download URL | netbox_loki-0.0.8-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a63a75c27a71f57fe8bd28918fdc441860e2ef919a127df9cb1648c6f47ac1e
|
|
BLAKE2b-256 checksum How to use checksums |
4f5b5591d5e1a4bbf10644e2f762da87c49602b061cb81573f9611da2181c1ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logSecurity for netbox-loki 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for netbox_loki-0.0.8.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.