-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attach Labels to K8s Pod Metrics & Logs Based on Pod Annotations #1154
Comments
Hi Gabriel! Settings labels on pod logs from the pod annotation can be done with:
|
Setting that label on metrics is a little trickier. Give me a minute and I'll type up some ideas there. |
As for metrics, it all depends on where the metrics are coming from. If you're scraping metrics from the pod itself, you can use a relabeling rule to find the annotation and add it to the pod:
However, if you want metrics about the pod, but from some other source, like To do that, what you can do is configure kube-state-metrics to capture pod annotations and report them as a standalone metric: To get those, you'll need to do two changes: Tell ksm to capture those metrics, and tell alloy to include them:
|
@petewall |
Of course! Thanks for the question! |
I’m using the Grafana k8s-monitoring Helm chart to collect Kubernetes pod metrics and logs, and I’d like to attach
labels to these data points based on the value of a specific annotation attached to each pod.
For example, if a pod has an annotation like this:
I want the collected metrics and logs to have a label like:
mycustom_label="team-A"
This would help in filtering, grouping, and querying logs/metrics in Grafana more effectively.
Is there an existing way in the k8s-monitoring Helm chart to achieve this? If not, would you consider adding support for this feature?
Thanks for your help ! 🚀
The text was updated successfully, but these errors were encountered: