Sub-queries or view replacements - dealing with text mapping lookups

I have Prometheus (but this is not a Prometheus question) scraping large amounts of values out of servers that speak to BGP. I keep counters based on a small set of labels. This leads to things like:

prefix_count{loc=“NYC”,host=“host1”,asn=“3356”} 1201
prefix_count{loc=“LHR”,host=“host4”,asn=“1239”} 2193
. . . etc.

The “asn” value is “autonomous system number” and is an identifier that maps back to a company name via a series of databases. Let’s assume I have that database in whatever format I want, and that ASN 3356 is “Level3” and ASN 1239 is “Sprint” in shortened human-readable form.

I’d like to create graphs in Grafana that show the human-readable form of the ASN value when looking at charts. I could insert that data into Prometheus into each label set for each metric, which seems really REALLY wasteful to move around huge chunks of text for every single scrape when a mapping is all I need even if it is done only at the time of visualization. These values do not change often enough to be concerned about, if that is the next objection. The list is large - many tens of thousands of mappings. The number of items scraped is also very large - tens of thousands every few seconds, and transmitting/storing lots of duplicated data puts un-necessary load on components that have better things to do.

I don’t see a way to do this in Prometheus. It would seem to me that Grafana would be an equally obvious place to do this string replacement but it is not obvious to me if that is possible. Templates almost-sort-of-kinda seem like they might be twisted to work in this manner.

Note that I only am interested in visualization. Any alerts, searches, activities, etc. would occur on the original (numeric) values.

Any insights?

1 Like