'Counting and grouping in Grafana
Grafana noob with simple query results formatted as table:
SELECT "locales" FROM "postgresql" WHERE ("environment" = 'stage') AND $timeFilter
| Time | locales |
|---|---|
| 2022-03-17 15:31:00 | en |
| 2022-03-17 15:31:01 | en-us |
| 2022-03-17 15:32:00 | en |
| 2022-03-17 15:32:01 | en-us |
| 2022-03-17 15:33:00 | en-us |
| 2022-03-17 15:34:00 | en-us |
I'd like to count occurrences and group by locales, like:
| locale | count |
|---|---|
| en | 2 |
| en-us | 4 |
I tried the following:
- Using a transform, I can group by locales, but this does not give me count.
- Adding a transform to count returns a single value of total rows, not individual locale counts.
- Including count and group-by in the query:
SELECT "locales", count("locales") FROM "postgresql" WHERE ("environment" = 'stage') GROUP BY "locales". This gives InfluxDB Error: mixing aggregate and non-aggregate queries is not supported.
I know Grafana is more time-based, but this should be easily doable, no? Thanks in advance for any tips!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
