Help on how to add labels to metrics sent to Prometheus from automatic instrumentation #3692
Unanswered
angelotessaro
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I instrumented my Flask app as you can see below (2nd code), using the automatic instrumentation and pushing the metrics to an AWS Managed Prometheus service. The setup works, I was able to visualize the metrics in Grafana, but they don't have the necessary labels to identify them, like the route (ex: "api/post"), request parameters, headers. I was able to add labels by using the Resource class ( provider.resource = Resource.create(resource_attributes)), but the labels set here will be added to every single metric and will not be request-specific. I want labels to identify the requests and be able to filter them in Grafana by the endpoint for example.
I also was able to add a specific label for service_name using an environment variable (OTEL_SERVICE_NAME=my-service).
I saw that all the attributes are already available in the instrumentation module during the requests, both in the "attributes" and "flask_request_environ" below:
I tried so many different things at this point and I really couldn't crack how to make this work. So my question is, would it be possible to use the already available labels and add them to the metrics being sent to Prometheus? That would help me a lot and I would be unbelievably grateful if someone could help me with that. Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions