← Home

Grafana - Why is my singlestat panel showing a decimal / float instead of an integer?

A system I’m working on uses JSON logs and then CloudWatch log filters to pull interesting information from the logs and turn them into metrics so I can graph them to see what’s going on.

It looks a bit like this:

{"itemsOrdered":1,"msg":"order placed","orderID":154,"ordersCreated":1,"time":"2018-03-23T15:50:03Z"}

I can see that the metrics are coming out OK, because the values are visible in the AWS console.

However, when I added the metric as a SUM to Grafana, I saw something unexpected:

That’s not right, I’ve asked for a sum of an integer and got a decimal point value…

Fortunately, the great team here at Infinity Works had seen this one before and pointed me at the Options tab has a setting for the Stat value, which has a default of Average. Change that to Total and normality is restored. Phew.