Repository navigation
feat(policies): attributes on every series of a policy - #815
Closed
leoparente wants to merge 7 commits into
Closed
leoparente wants to merge 7 commits into
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 — Net-positive change. Policy-level and per-target 🤖 AI Code Review · run · prompts: |
LCOV of commit
|
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.
(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