github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/metrics-export/README.md (about) 1 # Exporting Metrics 2 3 Pyroscope Server offers a way to export values of a particular stack trace sample from your profiles as a Prometheus 4 metric. You can find more details on how to use exporting in our [documentation](http://pyroscope.io/docs/metrics-export). 5 6 The directory contains example setup consisting of: 7 - Two instances of sample Go application: one with `env=prod` tag and another one with `env=staging`. 8 - [Pyroscope Server](http://localhost:4040) 9 - [Prometheus](http://localhost:9090) 10 - [Grafana](http://localhost:3000) 11 12 In the example, Pyroscope Server is configured to export sampled values gathered with pyroscope agent: 13 14 ```yaml 15 metrics-export-rules: 16 17 # The metrics is a sum of all observed CPU samples of 'slowFunction' 18 # of production app instance. 19 app_slow_function_prod_cpu_seconds_total: 20 expr: simple.golang.app.cpu{env="prod"} 21 node: slowFunction 22 23 # The metrics is a sum of all observed CPU samples of 'slowFunction' 24 # with break down by 'env' tag. 25 app_slow_function_env_cpu_seconds_total: 26 expr: simple.golang.app.cpu 27 node: slowFunction 28 group_by: [ env ] 29 30 # The metrics below are listed for demonstration purpose. 31 # It's better to collect them via runtime instrumentation, 32 # for example, using Prometheus. 33 34 app_cpu_seconds_total: 35 expr: simple.golang.app.cpu 36 37 app_alloc_space_bytes: 38 expr: simple.golang.app.alloc_space 39 40 app_alloc_objects_total: 41 expr: simple.golang.app.alloc_objects 42 43 app_inuse_space_bytes: 44 expr: simple.golang.app.inuse_space 45 46 app_inuse_objects_total: 47 expr: simple.golang.app.inuse_objects 48 49 ``` 50 51 To run the example execute the following command: 52 53 ```shell 54 docker-compose up 55 ``` 56 57 Now you should be able to open sample Grafana [dashboard](http://localhost:3000) with exported metrics: 58 59 ![image](https://user-images.githubusercontent.com/12090599/137328239-a56caea7-496b-4997-9a65-e7878597f83b.png) 60