feat(netbox): pull DCIM topology into the service topology map - #6635
Open
aditya-786 wants to merge 3 commits into
Open
feat(netbox): pull DCIM topology into the service topology map#6635aditya-786 wants to merge 3 commits into
aditya-786 wants to merge 3 commits into
Conversation
The NetBox provider only received webhook alerts. NetBox is the source of truth for physical infrastructure, so Keep can pull the DCIM inventory and use it for the topology map and topology based correlation. Upgrade the provider to a topology provider: devices become services (primary IP, role, manufacturer, site, tags), cables between two known devices become dependencies, and optionally the devices of a rack are grouped into an application so that alerts from devices sharing a rack can be correlated into a single incident. API access is optional and the provider stays fully backward compatible: without a URL and token, scope validation passes and pull_topology is a no-op, so existing webhook-only installs are unaffected. Pulling paginates the NetBox API with a configurable device cap and supports both the current and the pre-3.3 cable termination format. Rack applications use a stable id derived from tenant, provider and rack, so re-pulls update the application in place. Towards keephq#3931
Contributor
|
No linked issues found. Please add the corresponding issues in the pull request description. |
Scope validation now also reads the DCIM devices endpoint, so a token that authenticates but lacks the object permissions topology pulling needs is caught at connection time rather than silently pulling nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Towards #3931. Users monitoring physical networks (routers, switches) get alerts from tools like Nagios and Graylog, and when a shared failure hits (the issue describes a rack power loss) hundreds of alerts arrive with no way to correlate them by the physical infrastructure they belong to. NetBox is the source of truth for that infrastructure, but the Keep NetBox provider only received webhook alerts.
This upgrades the NetBox provider to a topology provider, so Keep pulls the DCIM inventory and feeds it to the existing topology map and topology based correlation:
TopologyServicecolumns. No migration needed.a_terminations/b_terminations) and pre-3.3 (termination_a/termination_b) cable formats are supported.group_racks_as_applications): devices sharing a rack are grouped into an application named after the rack. With the topology processor enabled (KEEP_TOPOLOGY_PROCESSOR=true), alerts from many devices in the same rack can then be correlated into a single incident, which is the rack power loss scenario from the issue. Application semantics for a physical container is a design choice, which is why it sits behind a flag.Rack applications use a stable id derived from tenant, provider and rack, so re-pulls update the application in place instead of creating a new one on every pull.
Backward compatibility
The API access fields are all optional and existing webhook-only installs are unaffected:
pull_topologyis a silent no-op and scope validation passes, so the topology polling loop does not produce errors for legacy installs._format_alert) is unchanged.process_topologyonly rewrites on non-empty data).Scale
Pulling paginates the NetBox API (
limit/offset, 1000 per page) with a hard cap (max_devices, default 5000, truncation logged) and excludesconfig_contextfrom device payloads to keep responses small. Every request carries a timeout, and the SSL verify switch matches the other on-prem providers.Out of scope (kept for follow-ups)
Checks
tests/providers/netbox_provider/test_netbox_topology.py(17 tests): device and cable mapping (including the legacy cable format and dangling cable ends), rack grouping on and off with stable namespaced application ids, webhook-only no-op with no HTTP calls, pagination,max_devicescap, API error raising, verify wiring, the unchanged webhook alert format, and an end-to-end test throughprocess_topologyproving a re-pull is idempotent (services recreated, the rack application updated in place). Existing topology tests (tests/test_topology.py) stay green, and the docs snippet was regenerated with the provider docs updated.