Newbie guage question - too many transformations?

  • What Grafana version and what operating system are you using?
    grafana v10.1.2 in a docker container.

  • What are you trying to achieve?
    Trying to show a gauge to show number of devices available from a static data source.
    Some devices are borrowed and some are currently not enabled.
    If they are borrowed, or not enabled, they are not available, and I would like to visualise that.

For example, I have set up a static data source that contains the necessary data.
https://play.grafana.org/d/eb3124ef-4d1d-4716-a42d-3e028fb0825a/availability?orgId=1

  • How are you trying to achieve it?
    Converting boolean type to number and several (9) transformations for calculations, to sum number of boards borrowed and enabled, and other transformations to subtract these from the total count.

  • What did you expect to happen?
    I expected fewer transformations. If I had the information in a database, I could write SQL to easily produce a number.
    Reduce Row to in sum the converted numeric fields, which would minimise the number of transformations

  • Can you copy/paste the configuration(s) that you are having problems with?
    Grafana

EDIT: I removed references to JSON as I think I may have caused some confusion. The JSON data is on a VPN, so I set up a Static datasource to demonstrate.

1 Like

Hello @roobrien

Welcome to the forum. Could you please post a sample json data

Hi yosiasz, there is sample data in the panel, from Static data source. Is that not accessible to others?

The data for the panel is:

Blockquote
"id",“name”,“borrowed”,“enabled”
alice,alice,true,true
bob,bob,true,true
anne,anne,false,false
barry,barry,false,true
oisin,oisin,false,false

I think what you have is good, there seems like there is no other way around that. if your true data source is json you could use infinity plugin with jsonata to do calculations.

Check out the jsonata part here.

https://try.jsonata.org/dlc5Z9GU7

1 Like

That really looks so much cleaner; easier to read and understand.
I will try that out in work on Monday.

1 Like

yours is also clean, the jsonata method is just in one pane easier to manage. transformations are good for a simple transform but fancier calculations should really be done at data source level. I try to avoid transformation if at all possible