VictoriaMetrics / grafana-datasource

Grafana Plugin for VictoriaMetrics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use label values in "Config from query results"

rul-hydro opened this issue · comments

It would be so cool if I could write the unit for each metric into a label value and use it directly in a Grafana dashboard instead of setting the unit manually. This could also be used to set the min/max, color, and a ton of other config parameters.

Maybe I'm just stupid, but so far I could not make it work.

Hi @rul-hydro! According to Prometheus naming convention, the metric's unit should be specified as a suffix. For example, process_cpu_seconds_total means we have a counter (_total) with unit of seconds (_seconds).

I'm not sure if plugin has such a control to automatically apply corresponding unit. Maybe @Loori-R knows

Hi @hagen1778, thanks for the hint. In my case, the Prometheus naming convention would be difficult to adopt, since I am receiving my metrics from an MQTT source without previous knowledge of the topics and contents.
If I understand correctly, the naming convention is not cast in stone, so I can use metrics names and labels any way that fits my use case. My current plan is to use a dummy metric name that is fixed for all series and put the MQTT topic with all its slashes and special characters into a label. Another optional label would carry the unit.
(A bit off-topic: Does it make a difference to VM whether series are distinct by name or by label? - EDIT since I found out myself: name is just a label that looks different from others, so no technical difference)