Possible duplicate of 80782.
-
What Grafana version and what operating system are you using?
v11.6 / Linux -
What are you trying to achieve?
Use a column data as serie name while keeping all metadata columns available:
SELECT ts, val, serie, metadata FROM data_tableto be treated by Grafana as
ts serie 1 … serie N metadata ts1 val1 … NULL metadata1 ts1 NULL … val2 metadata2 … … … … … tsM valX … NULL metadataX -
How are you trying to achieve it?
Currently I’ve come up with only working solution:
- GROUP BY into JSON:
SELECT ts, json_object_agg(serie, val) as obj, metadata FROM data_table GROUP BY ts, metadata- Use
Extract fieldstransformation.
-
What happened?
The downside of the above approach is complication of SQL query - unnecessary
GROUP BYand JSON packing/unpacking.I’ve also tried another transformations, but all of them have their own downsides:
Grouping to matrix- withColumn: serie, Row: ts, Cell value: val- it works and allows to show time series grouped by serie names, but it doesn’t preserve metadata column => if I want to create override to form a link for every point on a graph using metadata column, it is not possible with this transformation.Partition by values- it somehow works and even link could be created, but:- data is no longer in single table when
Inspect -> Datais used. - every serie is prefixed with
valcolumn name, so I seeval serie 1…val serie Nin the legend.
- data is no longer in single table when
-
What did you expect to happen?
Have an option for
Time Seriespanel to auto-group values and metadata by specified column or have transformation that works likeGrouping to matrix, but keeps metadata columns connected with values. -
Did you follow any online instructions? If so, what is the URL?
Time series | Grafana documentation