How format the prometheus vlaue output

39 views
Skip to first unread message

Auggie Yang

unread,
Jan 31, 2021, 3:12:07 AM1/31/21
to Prometheus Users
guys,

Configuration rules.yml with promethues, and alermanger always got some  long vlaue;

just like memory usage: 70.25266596686059, disk usage: 65.58277282;

is there has some good solutions to format prometheus's value with 70.xx or 65.xx, not 70.xxxxxxxx, thanks.

Julius Volz

unread,
Jan 31, 2021, 4:08:06 AM1/31/21
to Auggie Yang, Prometheus Users
In your annotation template, instead of "{{ $value }}", you can use "{{ $value | printf "%.2f" }}" to cut the value off after 2 decimal places. Or you could try "{{ humanize $value }}".

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/5c1766cc-6870-4a41-9480-15a905427dd6n%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com

Julius Volz

unread,
Jan 31, 2021, 4:09:30 AM1/31/21
to Auggie Yang, Prometheus Users

Auggie Yang

unread,
Feb 6, 2021, 8:37:14 AM2/6/21
to Prometheus Users
hello,

made it with "{{ humanize $value }}" in rules.yml.

thank you.
Reply all
Reply to author
Forward
0 new messages