Let’s say I have a Counter – named requests – representing the number of requests my server handles. It has a label named customer indicating which customer made the request.
I want to know "How many requests were made over the past 24 hours, per customer" and I’ve figured out I can get this from Prometheus by querying:
sum by (customer) (sum_over_time(requests[1d]))
Which gives me a moderately readable table that looks like:
{customer="Googley"} | 123
{customer="ApplesAndOranges"} | 256
The problem comes up when I try to get this same table view in Grafana. I’m creating a new Table on a Dashboard, and I plug in the same query from above. But Grafana gives me a time-based display instead of a summary! And it includes at the bottom of the table a selector to choose which customer to show the time series data for.
How can I convince Grafana to show me the summary numbers for the whole time period in a table, similar to how Prometheus does?
>Solution :
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
