In grafana (which uses go templates for Loki line templating), I would like to divide a field (milliseconds) and get a float result.
Here is what I'd like to do :
| logfmt | line_format "{{ .microsec | float64 | div 1000 | printf \"%6.3f\" }}ms"
However, this obviously doesn't work because div is the integer divide function.
The following does work (but does not divide the number) :
| logfmt | line_format "{{ .microsec | float64 | printf \"%8.0f\" }}μs"
How can I get my output in millisecond format ?
EDIT :
There is also a divf function, but the documentation says "Perform integer division". And I get very strange results with it (so I'm not sure how to use it) :
{{ .microsec | float64 | printf \"%8.0f\" }}μs {{ .microsec | float64 | divf 1000 | printf \"%6.3f\" }}ms?divf
6332μs 0.158ms?divf
22959μs 0.044ms?divf
7034μs 0.142ms?divf