diff --git a/console_libraries/prom.lib b/console_libraries/prom.lib index f2f0d7f2c..ac8638f7f 100644 --- a/console_libraries/prom.lib +++ b/console_libraries/prom.lib @@ -28,6 +28,7 @@ {{ define "humanizeNoSmallPrefix" }}{{ if and (lt . 1.0) (gt . -1.0) }}{{ printf "%.3g" . }}{{ else }}{{ humanize . }}{{ end }}{{ end }} {{ define "humanize1024" }}{{ humanize1024 . }}{{ end }} {{ define "humanizeDuration" }}{{ humanizeDuration . }}{{ end }} +{{ define "printf.1f" }}{{ printf "%.1f" . }}{{ end }} {{ define "printf.3g" }}{{ printf "%.3g" . }}{{ end }} {{/* prom_query_drilldown (args expr suffix? renderTemplate?) diff --git a/consoles/node-cpu.html b/consoles/node-cpu.html index 58305d194..3f2eee00a 100644 --- a/consoles/node-cpu.html +++ b/consoles/node-cpu.html @@ -1,11 +1,13 @@ {{ template "head" . }} {{ template "prom_right_table_head" }} - CPU + + CPU(s): {{ template "prom_query_drilldown" (args (printf "scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance)) }} + {{ range printf "sum by (mode)(rate(node_cpu{job='node',instance='%s'}[5m])) * 100 / scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance .Params.instance | query | sortByLabel "mode" }} {{ .Labels.mode | title }} CPU - {{ .Value | printf "%.3g" }}% + {{ .Value | printf "%.1f" }}% {{ end }} Misc diff --git a/consoles/node-disk.html b/consoles/node-disk.html index 5110af839..64fefa9be 100644 --- a/consoles/node-disk.html +++ b/consoles/node-disk.html @@ -7,7 +7,7 @@ {{ .Labels.device }} Utilization - {{ template "prom_query_drilldown" (args (printf "rate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.3g") }} + {{ template "prom_query_drilldown" (args (printf "rate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.1f") }} Throughput @@ -25,7 +25,7 @@ Filesystem Fullness {{ define "roughlyNearZero" }} -{{ if gt .1 . }}~0{{ else }}{{ printf "%.3g" . }}{{ end }} +{{ if gt .1 . }}~0{{ else }}{{ printf "%.1f" . }}{{ end }} {{ end }} {{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem" }} diff --git a/consoles/node-overview.html b/consoles/node-overview.html index 3187a1ed1..87bef018b 100644 --- a/consoles/node-overview.html +++ b/consoles/node-overview.html @@ -4,11 +4,11 @@ Overview User CPU - {{ template "prom_query_drilldown" (args (printf "sum(rate(node_cpu{job='node',instance='%s',mode='user'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.3g") }} + {{ template "prom_query_drilldown" (args (printf "sum(rate(node_cpu{job='node',instance='%s',mode='user'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }} System CPU - {{ template "prom_query_drilldown" (args (printf "sum(rate(node_cpu{job='node',instance='%s',mode='system'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.3g") }} + {{ template "prom_query_drilldown" (args (printf "sum(rate(node_cpu{job='node',instance='%s',mode='system'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }} Memory Total @@ -38,7 +38,7 @@ {{ range printf "node_disk_io_time_ms{job='node',instance='%s',device!~'^(md\\d+$|dm-)'}" .Params.instance | query | sortByLabel "device" }} {{ .Labels.device }} Utilization - {{ template "prom_query_drilldown" (args (printf "rate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.3g") }} + {{ template "prom_query_drilldown" (args (printf "rate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.1f") }} {{ end }} {{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device" }} @@ -51,7 +51,7 @@ Filesystem Fullness {{ define "roughlyNearZero" }} -{{ if gt .1 . }}~0{{ else }}{{ printf "%.3g" . }}{{ end }} +{{ if gt .1 . }}~0{{ else }}{{ printf "%.1f" . }}{{ end }} {{ end }} {{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "filesystem" }} diff --git a/consoles/node.html b/consoles/node.html index f47ef67d5..cb8eeb8e7 100644 --- a/consoles/node.html +++ b/consoles/node.html @@ -21,7 +21,7 @@ {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Labels.instance }} Yes{{ else }} class="alert-danger">No{{ end }} - {{ template "prom_query_drilldown" (args (printf "100 * (1 - avg by(instance)(rate(node_cpu{job='node',mode='idle',instance='%s'}[5m])))" .Labels.instance) "%" "printf.3g") }} + {{ template "prom_query_drilldown" (args (printf "100 * (1 - avg by(instance)(rate(node_cpu{job='node',mode='idle',instance='%s'}[5m])))" .Labels.instance) "%" "printf.1f") }} {{ template "prom_query_drilldown" (args (printf "node_memory_MemFree{job='node',instance='%s'} + node_memory_Cached{job='node',instance='%s'} + node_memory_Buffers{job='node',instance='%s'}" .Labels.instance .Labels.instance .Labels.instance) "B" "humanize1024") }} {{ else }}