How to add units to a timeseries panel with dynamic metrics sourced from DynamoDB

Hi all,

I am using Cloud Hosted Grafana (v13.0) and my data source is DynamoDB.

I have a simple dashboard with a multi-value variable (30 options) where the user can select some metrics to plot on a timeseries chart. This works fine.

I have a separate DynamoDB table which contains a list of all the available metrics and their corresponding units, for example Room_Temperature : degC, Rain_Guage : mm, Wind_Speed : km/h and so on. It’s a ‘lookup table’.

At the moment, when I select some metrics from the drop-down variable I can see all the series on the panel but they are all plotted on the same Y-axis and I don’t have any units displayed. I would like to display the units on the Y-axis, and ideally have a new Y-axis for each unit type.

It sounds so simple but I have had no success. I realise I could add 30 static overrides but this doesn’t seem like a good strategy. I would like to use a transformation (or similar) like the “Config from query results” which I believe can do this but I can’t get it to work. When I add that transformation I have only “A” as my Config Query Option. If I create a 2nd query (B) to fetch the units from DyanmoDB, I can’t see this query in the transformation option.

If anyone has achieved this before I would much appreciate any advice.

Thanks

Mike


Unit show in tooltip when you hover on this (Use add field override property)

Thanks for the reply but this solurtion is not really practical in my situation as described in my post.

Please provide sample data as csv inline here in the forum

metric,value,unit,datetime

or provide schema definitions DDL

Create table unit_types(Id,unitname)
Create table metrics(id,metric,value,unittypeid,datetime)

Grafana can’t automatically create a separate Y-axis for each metric, but you can handle it efficiently by combining your metrics with the unit lookup table. This way, each series knows its unit, and you only need a few overrides, one per unit type instead of one per metric.

  • Keep your main metrics query (Query A)
  • Add a second query for the lookup table (Query B) with metric - unit
  • Use the “Outer join” transformation to merge them on the metric name
  • Create one Y-axis override per unique unit type (°C, mm, km/h, etc.)
  • All metrics sharing the same unit will use the same Y-axis