How to use query count("field"),"field2"?

Hi Everyone !

I have setup logging fluentd to influxdb
This my database sample below :slight_smile:

name: api.api-infra-0-0-1
time                 code data  ip
----                 ---- ----  --
2020-07-02T02:12:10Z 200  true  172.20.17.27
2020-07-02T02:12:19Z 200  false 172.20.17.27
2020-07-02T02:12:35Z 200  false 172.20.23.51
2020-07-02T02:12:37Z 200  false 172.20.17.27
2020-07-02T02:12:42Z 200  false 172.20.17.27
2020-07-02T02:12:53Z 200  false 172.20.17.27
2020-07-02T02:13:34Z 200  false 172.20.23.51
2020-07-02T02:13:40Z 200  false 172.20.17.27
2020-07-02T02:13:54Z 200  false 172.20.23.51
2020-07-02T02:14:19Z 200  false 172.20.23.51

How to count true, false group by ip ?

i have tried

SELECT count("data"),"ip" FROM "api.api-infra-0-0-1" where "data" = 'false' GROUP BY "ip"
SELECT count("data"),"ip" FROM "api.api-infra-0-0-1" where "data" = 'true' GROUP BY "ip"

response :slight_smile:
—> mixing aggregate and non-aggregate queries is not supported

Anyone suggest me solutions for that ?
i have use visuallize on grafana !

Thanks

Your query already gets multiple series by “ip” so you can leave that “ip” out of the fields to extract (it is already included in the response). In Grafana, you group by tag(ip) to get multiple series in your chart.
If you use a “single stat” in Grafana, it will produce a separate chart for each series.

1 Like