Filter Prometheus metrics
Run the example
prometheus.relabel component is used to drop, add, or filter metrics. Run the following:
curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets/runt.sh -O && bash ./runt.sh relabel.river.
runt.sh script does:
- Downloads the configs necessary for Mimir, Grafana and the Grafana Agent.
- Downloads the docker image for Grafana Agent explicitly.
- Runs the docker-compose up command to bring all the services up.
Allow the Grafana Agent to run for two minutes, then navigate to Grafana page and the
service label will be there with the
- The Prometheus scraper is sending the metrics to the filter.
- The filter is adding a new label named
servicewith the value
- The filter is then sending metrics to the remote_write endpoint.
Update the service value
relabel.river file that was downloaded and change the name of the service to
api_server_v2, then run
bash ./runt.sh relabel.river. Allow the Grafana Agent to run for two minutes, then navigate to Grafana page, and the new label will be updated. The old value
api_server may still show up in the graph but hovering over the lines will show that that value stopped being scraped and was replaced with