Debian Codegraph @

docs/content/restricted-registry/_index.md

raw symbols SCIP
1 ---
2 title: Restricted registry
3 weight: 7
4 ---
5
6 Registries support restriction to only return specific metrics.
7 If you’re using the built-in HTTP server, you can use the GET parameter "name[]", since it’s an array it can be used multiple times.
8 If you’re directly using `generate_latest`, you can use the function `restricted_registry()`.
9
10 ```python
11 curl --get --data-urlencode "name[]=python_gc_objects_collected_total" --data-urlencode "name[]=python_info" http://127.0.0.1:9200/metrics
12 ```
13
14 ```python
15 from prometheus_client import generate_latest
16
17 generate_latest(REGISTRY.restricted_registry(['python_gc_objects_collected_total', 'python_info']))
18 ```
19
20 ```python
21 # HELP python_info Python platform information
22 # TYPE python_info gauge
23 python_info{implementation="CPython",major="3",minor="9",patchlevel="3",version="3.9.3"} 1.0
24 # HELP python_gc_objects_collected_total Objects collected during gc
25 # TYPE python_gc_objects_collected_total counter
26 python_gc_objects_collected_total{generation="0"} 73129.0
27 python_gc_objects_collected_total{generation="1"} 8594.0
28 python_gc_objects_collected_total{generation="2"} 296.0
29 ```