Found wrong sql in grafana example panel.json
wthahaha opened this issue · 2 comments
wthahaha commented
When I use grafana panel.json (https://github.com/mosajjal/dnsmonster/blob/main/grafana/panel.json), I found 2 cahrt that grafana can't draw:
,
Then I found that two SQL statements encountered errors while executing.
SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=4 WHERE $timeFilter GROUP BY SrcIP order by SrcIP desc limit 20);
SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=6 WHERE $timeFilter GROUP BY SrcIP order by SrcIP desc limit 20)
After converting to regular SQL statements and executing them in ClickHouse, the following error is displayed below:
SELECT
0,
groupArray((IP, total))
FROM
(
SELECT
IPv6NumToString(toFixedString(SrcIP, 16)) AS IP,
sum(c) AS total
FROM DNS_SRCIP_MASK
PREWHERE IPVersion = 4
WHERE (DnsDate >= toDate(1697869430)) AND (DnsDate <= toDate(1697880230)) AND (timestamp >= toDateTime(1697869430)) AND (timestamp <= toDateTime(1697880230))
GROUP BY SrcIP
ORDER BY SrcIP DESC
LIMIT 20
Query id: 82ad98fe-6377-4980-9325-a9ca63682f27
0 rows in set. Elapsed: 0.002 sec.
Received exception from server (version 23.3.14):
Code: 48. DB::Exception: Received from localhost:9000. DB::Exception: toFixedString is only implemented for types String and FixedString: While processing IPv6NumToString(toFixedString(SrcIP, 16)) AS IP, sum(c) AS total. (NOT_IMPLEMENTED)
)
7a3c86218e97 :) select * from DNS_SRCIP_MASK
SELECT *
FROM DNS_SRCIP_MASK
Query id: a0453307-81e5-4347-a840-e5cd9381946b
┌────DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP─────────────────┬───c─┐
│ 2023-10-21 │ 2023-10-21 06:51:18 │ default │ 4 │ ::ffff:172.23.160.1 │ 136 │
│ 2023-10-21 │ 2023-10-21 06:51:18 │ default │ 4 │ ::ffff:172.23.162.110 │ 126 │
└────────────┴─────────────────────┴─────────┴───────────┴───────────────────────┴─────┘
┌────DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP───────────────┬─c─┐
│ 2023-10-21 │ 2023-10-21 09:18:32 │ default │ 4 │ ::ffff:172.23.160.1 │ 1 │
└────────────┴─────────────────────┴─────────┴───────────┴─────────────────────┴───┘
┌────DnsDate─┬───────────timestamp─┬─Server──┬─IPVersion─┬─SrcIP─────────────────┬─c─┐
│ 2023-10-21 │ 2023-10-21 09:18:32 │ default │ 4 │ ::ffff:172.23.162.110 │ 1 │
└────────────┴─────────────────────┴─────────┴───────────┴───────────────────────┴───┘
mosajjal commented
which version of the ClickHouse you're using? I just ran ./autobuild.sh
on a fresh VM and the charts showed up properly. it might be because ClickHouse removed some features?
mosajjal commented
fixed in main