Add support for dynamic tag_<name> labels in metrics#922
Add support for dynamic tag_<name> labels in metrics#922Zavierazo wants to merge 5 commits intoTykTechnologies:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for dynamic tag_<name> labels in Prometheus custom metrics. Previously, only a fixed set of labels mapped to AnalyticsRecord fields were supported. This enhancement allows users to include tags associated with API requests as metric labels by using the syntax tag_<name>, where tags are matched from the AnalyticsRecord.Tags array.
- Dynamic label support for tags in Prometheus metrics using
tag_<name>syntax - Tag matching logic that extracts values from AnalyticsRecord.Tags array
- Documentation update to include the new label syntax
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pumps/prometheus.go | Implements tag extraction logic in GetLabelsValues to support dynamic tag labels |
| pumps/prometheus_test.go | Adds test cases for valid custom tags and missing tag scenarios |
| README.md | Updates documentation to include tag_<tag-name> in available label values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Hi @Zavierazo, Thanks for submitting this PR - we're looking at this and aiming to bring it, (either directly or as part of a larger addition to functionality) into the product in Q1. Thanks again for the contribution. |
Add support for dynamic tag_ labels in metrics
Description
This change introduces support for dynamic labels in Prometheus custom metrics using the syntax tag_.
Previously, the pump only supported a fixed set of labels mapped to AnalyticsRecord fields. With this enhancement, users can now include tags associated with API requests as metric labels, enabling richer and more contextual Prometheus metrics.
Related Issue
Original ticket: https://support.tyk.io/hc/en-gb/requests/23608
Motivation and Context
This feature allows users to enrich Prometheus metrics with business-specific or contextual metadata already associated with APIs via tags in Tyk Dashboard. It enables dynamic metric segmentation without requiring hardcoded label sets.
How This Has Been Tested
Types of changes
Checklist
fork, don't request your
master!masterbranch (left side). Also, you should startyour branch off our latest
master.go mod tidy && go mod vendorgo fmt -sgo vet