Concatenate metrics to display as string

I have a bunch of SNMP devices that report their firmware version as 3 separate metrics as below.
I’m trying to think of a useful way to visualize this data in a Grafana dashboard and I’m feeling stumped. Is there a way to concatenate the values into a single string like 9.5.0?

I’d also like to get a count of how many devices in the fleet are on each version, and perhaps display it as a pie chart. As it now, I could make 3 separate pie charts, that wouldn’t make any sense.

firmwareMajorVersion{instance="10.91.77.94", room="Roma"} 9
firmwareMinorVersion{instance="10.91.77.94", room="Roma"} 5
firmwareBuildVersion{instance="10.91.77.94", room="Roma"} 0

If I could apply each of these 3 values as labels on a single metric then I think I could achieve the result with this query:

label_join(firmwareMajorVersion, "full_version", ".", "major", "minor", "build")

I found a way to apply one value as a label, but I don’t know how to do this for all 3.

count_values without () ("major", firmwareMajorVersion)

Maybe you could try regex?

I don’t know if it’s possible to do what you are trying to do. You essentially are looking to join three log lines, which to my knowledge is currently not possible in logql.

I would propose tackling this from ingestion:

  1. Querying your devices using a script and output to Loki is one solution.
  2. You can also use some sort of intermediary tool to parse the logs as they come in. This depends on how you are currently shipping logs from your devices to Loki.

You can also write a simple Python script that executes on a schedule, look for firmware version log lines for the past X minutes, combine it based on instance IP, then write back into Loki.

This is Prometheus, not Loki.

Ah, my apologies.