File tree Expand file tree Collapse file tree
docs/content/getting-started Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,6 +96,27 @@ and full label-schema validation and duplicate detection still apply. A collecto
9696non-null type but leaves ` getLabelNames() ` as ` null ` is still validated, with its labels treated as
9797empty.
9898
99+ ## Filtering Metrics
100+
101+ You can set a registry-level metric name filter that applies to all scrape operations.
102+ Only metrics whose names match the filter predicate will be included in scrape results:
103+
104+ ``` java
105+ PrometheusRegistry . defaultRegistry. setMetricFilter(name - > ! name. startsWith(" debug_" ));
106+ ```
107+
108+ The registry filter is AND-combined with any scrape-time ` includedNames ` predicate passed to
109+ ` scrape(Predicate) ` . For example, if the registry filter allows ` counter_* ` and the scrape-time
110+ filter allows ` counter_a ` , only ` counter_a ` will be included.
111+
112+ To remove the filter, set it to ` null ` :
113+
114+ ``` java
115+ PrometheusRegistry . defaultRegistry. setMetricFilter(null );
116+ ```
117+
118+ Note that ` clear() ` does not reset the metric filter -- it only removes registered collectors.
119+
99120## Unregistering a Metric
100121
101122There is no automatic expiry of unused metrics (yet), once a metric is registered it will remain
You can’t perform that action at this time.
0 commit comments