Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boolean to text mapping in Grafana

Tags:

grafana

I have a single stat view that displays true or false based on the last value correctly from the data. However, I wish to map this to the text as follows:

  • false -> Radiator Off
  • true -> Radiator On

I've tried the values 0, 0.0, true and false in the value mappings and nothing seems to change what is on screen. If I have a null mapping and do something such as average the values this correctly displays the text. I've also listed my data in a table view and this shows 0.0 and 1.0 for the true/false states.

Does Grafana text mapping work with boolean values? There is nothing in the help that mentions anything about booleans.

like image 564
Ajaxharg Avatar asked Mar 13 '20 11:03

Ajaxharg


1 Answers

I think because we're using Grafana to visualize time series data, therefore values should only in numeric or null.

Grafana don't have text mapping, I think you're referring Value Mappings.

You can convert boolean values from your query to numeric, such as true to 1 and false to 0, Value Mappings will work.

I've tried on https://play.grafana.org/ for mapping from 0 to Off and 1 to On, it worked well :D

Thanks for reading !!

enter image description here

like image 138
Ha. Huynh Avatar answered Oct 17 '22 10:10

Ha. Huynh