Format float to 2 decimal places in Alert summary

I am trying to format a float inside an alert summary.
This is what I have:
{{ $labels.device_name }} has a zone temperature of {{printf “%.2f” $values.ZONETEMP }}°F with a setpoint of {{$values.EFFECTIVESP}}°F for the last hour. Please inspect unit for proper operation.

But the result is confusing:

ROW1 has a zone temperature of map[%!f(string=de):%!f(string=SS)] 79.60°F with a setpoint of 70°F for the last hour. Please inspect unit for proper operation.

Any help?

Try this: {{ $labels.device_name }} has a zone temperature of {{printf "%.2f" $values.ZONETEMP.Value }}°F with a setpoint of {{$values.EFFECTIVESP}}°F for the last hour. Please inspect unit for proper operation.

It seems everything below $values is a map type. If you want to apply a filter on it, you have to make it more precise. Oh and make sure you are using Grafana version >= 8.2 due to this issue: Using {{ $value }} doesnt return value · Issue #37393 · grafana/grafana · GitHub

1 Like

This worked great! Thank you very much!