File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Original file line number Diff line number Diff line change @@ -737,6 +737,34 @@ for family in text_string_to_metric_families(u"my_gauge 1.0\n"):
737
737
print (" Name: {0} Labels: {1} Value: {2} " .format(* sample))
738
738
```
739
739
740
+ ## Restricted registry
741
+
742
+ Registries support restriction to only return specific metrics.
743
+ 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.
744
+ If you’re directly using ` generate_latest ` , you can use the function ` restricted_registry() ` .
745
+
746
+ ``` python
747
+ curl -- get -- data- urlencode " name[]=python_gc_objects_collected_total" -- data- urlencode " name[]=python_info" http:// 127.0 .0.1:9200 / metrics
748
+ ```
749
+
750
+ ``` python
751
+ from prometheus_client import generate_latest
752
+
753
+ generate_latest(REGISTRY .restricted_registry([' python_gc_objects_collected_total' , ' python_info' ]))
754
+ ```
755
+
756
+ ``` python
757
+ # HELP python_info Python platform information
758
+ # TYPE python_info gauge
759
+ python_info{implementation=" CPython" ,major=" 3" ,minor=" 9" ,patchlevel=" 3" ,version=" 3.9.3" } 1.0
760
+ # HELP python_gc_objects_collected_total Objects collected during gc
761
+ # TYPE python_gc_objects_collected_total counter
762
+ python_gc_objects_collected_total{generation=" 0" } 73129.0
763
+ python_gc_objects_collected_total{generation=" 1" } 8594.0
764
+ python_gc_objects_collected_total{generation=" 2" } 296.0
765
+ ```
766
+
767
+
740
768
## Links
741
769
742
770
* [ Releases] ( https://github.com/prometheus/client_python/releases ) : The releases page shows the history of the project and acts as a changelog.
You can’t perform that action at this time.
0 commit comments