Replies: 1 comment 1 reply
-
|
Hi! I was wondering if we can get any update on this topic? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Issues #3652 (Jul 2025) and #3826 (Mar 2026) both request
k8s_ns_name/k8s_pod_nameas labels onfalcosecurity_falco_rules_matches_total. PR #3839 attempted this but was correctly rejected: it hardcoded"n/a"as placeholder values for both labels, which provides no useful information and violates Prometheus best practices — labels should distinguish time series, not carry constant values.In the review of #3839, @leogr diagnosed the root cause and proposed a concrete design direction:
This discussion is to work through that design before a PR is submitted.
Proposed design
Config (
falco.yaml, undermetrics):When non-empty and
rules_counters_enabled: true, the listed Falco output field names are promoted to additional Prometheus label dimensions onrules_matches_total. Label names are sanitized from Falco dot-notation to underscores (e.g.k8s.ns.name→k8s_ns_name) for compatibility with tooling that enforces the[a-zA-Z_][a-zA-Z0-9_]*label name convention.Event capture point
At match time in
falco_engine::process_event()/falco_outputs::handle_event(), wheresinsp_evt*is available and output fields are already resolved into amap<string, string>, extract the values for the configured extra label fields and pass them alongside the rule reference tostats_manager.stats_managerchangeChange the rule counter map from per-rule to per-(rule, label-values-tuple):
The label names (keys) are fixed at startup from config; the label values are captured per-event. When
rules_counters_extra_labelsis empty the behaviour is identical to today.Prometheus exposition
falco_metrics.cppemits one series per unique(rule_name, label_values_tuple). The extra label names and values appear alongside the existingrule_name,priority, andsourcelabels.Open questions
Cardinality and stale series. A pod that triggers a rule match and is then terminated leaves a stale series in the counter map until Falco restarts. This behaviour is common in the Prometheus ecosystem (e.g. kube-state-metrics produces series for resources that no longer exist until the next scrape cycle completes). Is accepting stale series reasonable here, or should the implementation include a TTL/eviction mechanism? If eviction, what form — bounded LRU map, periodic sweep on a configurable TTL, or none for the initial implementation with a future follow-up?
Label name sanitization. Falco output field names use dots (
k8s.ns.name). The Prometheus data model recommends label names match[a-zA-Z_][a-zA-Z0-9_]*for best compatibility with tooling. Proposed: replace.with_at exposition time. Are there field names where this produces collisions or ambiguity?Field availability. Some Falco output fields may resolve to
<NA>when the relevant plugin (e.g. the container plugin) is not loaded or when metadata is not yet available for a given process. Should events where a requested extra-label field resolves to<NA>or empty string be counted under that value as a distinct label, skipped entirely, or cause a validation warning at startup?Scope of accepted fields. Should
rules_counters_extra_labelsaccept any output field name, or should there be validation at startup against the set of fields resolvable by the loaded plugins? Accepting arbitrary names with no validation could lead to silently empty labels if a field is misspelled or its plugin is not loaded.References
cc @falcosecurity/core-maintainers
Beta Was this translation helpful? Give feedback.
All reactions