You whole attempt has a couple flaws:
- If your metric is actually a counter, your query should be
sum by (customer) (increase(requests[1d])). - In Grafana
$__intervalstand for time corresponding to one "column" on time scale. Based on your description, you probably intended to use$__rangeinstead. - To get only last result of the query, and represented as actual table data, and not independent time series, you need to change options Format to Table, and Type to Instant. Those options can be seen underneath the query in your screenshot.
To hide column Time, you can use Transformation Organize field
Answer from markalex on Stack OverflowHow to do a basic summation?
Cumulative sum over time
prometheus - Get Total requests in a period of time - Stack Overflow
Display sum of all gauge's values
What you need is the increase() function, that will calculate the difference between the counter values at the start and at the end of the specified time interval. It also correctly handles counter resets during that time period (if any).
increase(http_requests_total[24h])
If you have multiple counters http_requests_total (e.g. from multiple instances) and you need to get the cumulative count of requests, use the sum() operator:
sum(increase(http_requests_total[24h]))
See also my answer to that part of the question about using Grafana's time range selection in queries.
SO won't let me comment on Yoory's answer so I have to make a new one...
In Grafana 5.3, they introduced $__range for Prometheus that's easier to use:
sum(rate(http_requests_total[$__range]))
This variable represents the range for the current dashboard. It is calculated by to - from
http://docs.grafana.org/features/datasources/prometheus/
Hello,
I have this graph monitoring the bandwidth of a VLAN on a switch every 1m using SNMP Exporter, but I also what to get the total/sum data over time, so if I select the last hour it will show x amount inbound and x amount outbound.
sum by(ifName) (irate(ifHCInOctets{instance=~"192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*"}[1m])) * 8My current graph:
I'd like to duplicate and create a stat panel show how much data in total has passed over what period I choose that's all.
For the metric I'm not sure whether to use bytes(SI) or bytes(IEC), but are similar if I change to either.
Not sure how to calculate this, but I have this created for the past 1 hour.
by copying the PromQL in Grafana and changing to a stat panel and then editing to use this:
Not sure if this is ok as I'm not sure how to calculate it all, maths was never my best subject.
Any help would be great.
I think something like is close: with sum_over_time
sum by(ifName) (sum_over_time(ifHCInOctets{instance=~"192.168.200.10", job="snmp_exporter", ifName=~".*(1001).*"}[1m])) * 8but it comes back as 85.8 Pib when it should be 85.8 TB with my calculations.
EDIT
Observium:
What Grafana shows
I was missing the time precision of milliseconds which was not being shown in the UI, but it was there due to which I couldn't group with the _time column.
truncateTimeColumn(unit: 1s)

from(bucket: "${bucket}")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "RunningSessions")
|> filter(fn: (r) => r["_field"] == "totalSessionsCount")
|> truncateTimeColumn(unit: 1s)
|> aggregateWindow(every: 5s, fn: last, createEmpty: true)
|> group(columns: ["_time"])
|> sum(column: "_value")
|> group()
|> yield(name: "Total VU Load")
I'm not familiar with flux, but you can sum your time series at Grafana.
Go to panel edit mode > Transform:
- Add "Add field from calculation" transformation,
- select
Calculation:Total, - enable option
Replace all fields.