Repository navigation
feat(policies): attributes on every series of a policy - #816
leoparente wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… sets Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tes as none Keys must be non-empty valid UTF-8 starting with an ASCII letter; a null attributes is none; the input node is kept as is without target attributes so YAML errors keep their position; Prometheus names map one _ per code point; the legacy /metrics path carries the policy's attributes. Docs say what an older pktvisor does with target attributes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
AI Code Review — risk tier: Advisory only. A human owns the merge decision. Summary — This is a net-positive change. Policy attributes are plumbed consistently through No findings. 🤖 AI Code Review · run · prompts: |
LCOV of commit
|
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
(Tracked in MON-445.) A policy can now carry
attributes: key/value pairs that pktvisor puts on every series of every handler of that policy, in the OTLP push and in Prometheus output. Netprobe targets can override them per target. The aim is to let a collector attach context such as a NetBox site, tenant or device id to the series a policy produces.What changed
attributesmapping next tokind,input,handlersandconfig.Policy::series_labelsis now the one place the per-handler and merged-handlers export paths build their labels: the policy's attributes, thenpolicyandhandleron top. A policy withoutattributes, or with a null one, exports exactly what it did before. JSON output is unchanged."007"stays007), never throughConfigurable.[A-Za-z0-9_]as_, one per code point (netbox.site.namebecomesnetbox_site_name). The serializer now writes converted names straight into the line, and builds its static-label set only when static labels exist.policy,handler,tap,le,quantile, any static label, and each handler's own labels (StreamHandler::own_label_names).A refused policy rolls back like any other load failure.
input.config.targets.<name>.attributes, laid over the policy's key by key, thentarget. They are read from the policy YAML and kept out of the input's config, so policies that differ only in them share one input. A newAbstractMetricsManager::on_new_buckethook hands the immutable map to each fresh bucket under the bucket lock. Merged buckets carry it throughspecialized_merge./metrics: thedefaultpolicy's attributes are included.device_mapis unchanged.Compatibility
attributes. It reads per-target attributes as input config, so an all-digit value past 2^64 makes it refuse the policy, and policies that differ only in target attributes get separate inputs.\followed by three digits are rewritten by the existing label-value escaping. The docs say so.Tests
src/tests/test_policy_attributes.cpp(policy, target, refusal and rollback, shared input, null, YAML error location), plus additions totest_prometheus_serializer.cpp,test_core_server.cpp,handlers/netprobe/test_net_probe.cppandinputs/netprobe/test_netprobe.cpp.cteston macOS (Debug): 24/25.unit-tests-input-netprobefails on the same two TCP-timeout cases on unchangeddevelopon this machine; the new case in that suite passes.Merge order
src/Policies.cpp. Whichever merges second rebases.🤖 Generated with Claude Code