From f08abdb48bf44b4922751da7c148c6f5a78846fb Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Fri, 9 Oct 2015 17:58:43 +0100 Subject: [PATCH] promql: Add irate() function irate is a rate function that only looks at the most recent two data points, and calucaltes a per-second value from that. This produces much more granular graphs for fast moving data, and works sanely across many scrape intervals. It doesn't do so well for slowly moving data. --- console_libraries/prom.lib | 2 +- consoles/cassandra.html | 12 ++++---- consoles/cloudwatch.html | 2 +- consoles/haproxy-backend.html | 14 +++++----- consoles/haproxy-backends.html | 2 +- consoles/haproxy-frontend.html | 10 +++---- consoles/haproxy-frontends.html | 2 +- consoles/haproxy.html | 14 +++++----- consoles/node-cpu.html | 10 +++---- consoles/node-disk.html | 10 +++---- consoles/node-overview.html | 16 +++++------ consoles/node.html | 2 +- consoles/prometheus-overview.html | 14 +++++----- consoles/prometheus.html | 2 +- consoles/snmp-overview.html | 8 +++--- consoles/snmp.html | 8 +++--- promql/functions.go | 46 +++++++++++++++++++++++++++++++ promql/testdata/functions.test | 15 ++++++++++ 18 files changed, 125 insertions(+), 64 deletions(-) diff --git a/console_libraries/prom.lib b/console_libraries/prom.lib index 32975dbb7..aa4c11d21 100644 --- a/console_libraries/prom.lib +++ b/console_libraries/prom.lib @@ -62,7 +62,7 @@ renderTemplate is the name of the template to use to render the value. CPU - {{ template "prom_query_drilldown" (args (printf "avg by(job)(rate(process_cpu_seconds_total{job='%s'}[5m]))" .) "s/s" "humanizeNoSmallPrefix") }} + {{ template "prom_query_drilldown" (args (printf "avg by(job)(irate(process_cpu_seconds_total{job='%s'}[5m]))" .) "s/s" "humanizeNoSmallPrefix") }} Memory diff --git a/consoles/cassandra.html b/consoles/cassandra.html index 6ea6b865e..b87a0937a 100644 --- a/consoles/cassandra.html +++ b/consoles/cassandra.html @@ -4,15 +4,15 @@ {{ template "prom_right_table_job_head" "cassandra" }} Queries - {{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "/s" "humanizeNoSmallPrefix") }} + {{ template "prom_query_drilldown" (args "sum by (job)(irate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "/s" "humanizeNoSmallPrefix") }} Timeout Ratio - {{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_timeouts{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }} + {{ template "prom_query_drilldown" (args "sum by (job)(irate(cassandra_clientrequest_timeouts{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }} Unavailable Ratio - {{ template "prom_query_drilldown" (args "sum by (job)(rate(cassandra_clientrequest_unavailables{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }} + {{ template "prom_query_drilldown" (args "sum by (job)(irate(cassandra_clientrequest_unavailables{job='cassandra'}[5m])) / sum by (job)(rate(cassandra_clientrequest_latency{job='cassandra'}[5m]))" "" "humanizeNoSmallPrefix") }} Internals @@ -26,7 +26,7 @@ Average Node Disk Compacted - {{ template "prom_query_drilldown" (args "avg by (job)(rate(cassandra_compaction_bytescompacted{job='cassandra'}[5m]))" "B/s" "humanize1024") }} + {{ template "prom_query_drilldown" (args "avg by (job)(irate(cassandra_compaction_bytescompacted{job='cassandra'}[5m]))" "B/s" "humanize1024") }} Live CF @@ -50,7 +50,7 @@