Heya. After searching far and wide, I’ve fallen short with this, apparently not very common, problem. I’d like to map certain label values, as I have labels with IDs I’l like to map to a proper name.
I am already doing something similar for my template variables, as I have a simple JSON API where I can post the IDs and get the mappings as response, so I am able to use a variable with the query label_values(some_metric)
as a base for another variable which maps via the JSON API.
However, I cannot figure out a way to do this without the use of template variables. Given a metric some_metric{someLabel="someId"}
I’d like it mapped to some_metric{someLabel="someName"}
(could also be a new label), preferably using some datasource.
I want to do this in order to avoid adding a lot of IDs or names as labels. My data can be related to objects in a hierarchy, and I could potentially have 10-20 labels in order to include the entire tree with both IDs and names.
I wonder if a variable can be combined with one or more label_replace.
I’ve discovered that for Prometheus it is possible to utilize series calculations and join labels this way, e.g. multiplying with a constant 1 series on the ID and grab the corresponding Name at the same time.
For Grafana Loki, I can do a mixed datasource with Loki and my REST API, which will automatically merge the data as long as it has a single field name overlapping. I do have to add two transforms though: Turn Labels into Fields and Filter by Value (to remove unmatched data from my metadata).