Skip to content

Commit

Permalink
fix typo in responsecode
Browse files Browse the repository at this point in the history
  • Loading branch information
mosajjal committed Nov 12, 2020
1 parent d92160a commit 6a00a3f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions clickhouse/dns_dictionary.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<dictionaries>
<dictionary>
<!-- Dictionary name. The dictionary will be accessed for use by this name. -->
<name>dns_responce</name>
<name>dns_response</name>

<!-- Data source. -->
<source>
<!-- Source is a file in the local file system. -->
<file>
<!-- Path on the local file system. -->
<path>/opt/dictionaries/dns_responce.tsv</path>
<path>/opt/dictionaries/dns_response.tsv</path>
<!-- Which format to use for reading the file. -->
<format>TabSeparated</format>
</file>
Expand Down
8 changes: 4 additions & 4 deletions clickhouse/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS DNS_LOG (
Type UInt16,
Edns0Present UInt8,
DoBit UInt8,
ResponceCode UInt8,
ResponseCode UInt8,
Question String,
Size UInt16
) engine=MergeTree partition by toYYYYMM(DnsDate)
Expand Down Expand Up @@ -59,9 +59,9 @@ ENGINE=SummingMergeTree(DnsDate, (timestamp, Server, Class), 8192, c) AS
SELECT DnsDate, timestamp, Server, Class, count(*) as c FROM DNS_LOG WHERE QR=0 GROUP BY Server, DnsDate, timestamp, Class;

-- View with query responses
CREATE MATERIALIZED VIEW IF NOT EXISTS DNS_RESPONCECODE
ENGINE=SummingMergeTree(DnsDate, (timestamp, Server, ResponceCode), 8192, c) AS
SELECT DnsDate, timestamp, Server, ResponceCode, count(*) as c FROM DNS_LOG WHERE QR=1 GROUP BY Server, DnsDate, timestamp, ResponceCode;
CREATE MATERIALIZED VIEW IF NOT EXISTS DNS_RESPONSECODE
ENGINE=SummingMergeTree(DnsDate, (timestamp, Server, ResponseCode), 8192, c) AS
SELECT DnsDate, timestamp, Server, ResponseCode, count(*) as c FROM DNS_LOG WHERE QR=1 GROUP BY Server, DnsDate, timestamp, ResponseCode;

-- View with IP Prefix
CREATE MATERIALIZED VIEW IF NOT EXISTS DNS_IP_MASK
Expand Down
10 changes: 5 additions & 5 deletions grafana/panel.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,19 +1108,19 @@
"steppedLine": false,
"targets": [
{
"compiledQuery": "SELECT t, groupArray((dictGetString('dns_responce', 'Name', toUInt64(ResponceCode)), count/2)) FROM (SELECT (intDiv(toUInt32(timestamp), 2) * 2) * 1000 as t, ResponceCode, sum(c) as count FROM DNS_RESPONCECODE WHERE DnsDate >= toDate(1506625902) AND timestamp >= toDateTime(1506625902) AND Server IN('default','valparaiso') group by t, ResponceCode ORDER BY t) group by t\n order by t",
"compiledQuery": "SELECT t, groupArray((dictGetString('dns_response', 'Name', toUInt64(ResponseCode)), count/2)) FROM (SELECT (intDiv(toUInt32(timestamp), 2) * 2) * 1000 as t, ResponseCode, sum(c) as count FROM DNS_RESPONSECODE WHERE DnsDate >= toDate(1506625902) AND timestamp >= toDateTime(1506625902) AND Server IN('default','valparaiso') group by t, ResponseCode ORDER BY t) group by t\n order by t",
"database": "default",
"dateColDataType": "DnsDate",
"dateLoading": false,
"dateTimeColDataType": "timestamp",
"datetimeLoading": false,
"formattedQuery": "<font color=\"darkorange\">SELECT</font> t, <font color=\"navajowhite\">groupArray</font>((<font color=\"navajowhite\">dictGetString</font>(<font color=\"lightgreen\">'dns_responce'</font>, <font color=\"lightgreen\">'Name'</font>, <font color=\"navajowhite\">toUInt64</font>(ResponceCode)), <font color=\"navajowhite\">count</font><font color=\"yellow\">/</font><font color=\"darkcyan\">$interval</font>)) <font color=\"darkorange\">FROM</font> (<font color=\"darkorange\">SELECT</font> <font color=\"darkcyan\">$timeSeries</font> <font color=\"darkorange\">as</font> t, ResponceCode, <font color=\"navajowhite\">sum</font>(c) <font color=\"darkorange\">as</font> <font color=\"navajowhite\">count</font> <font color=\"darkorange\">FROM</font> <font color=\"darkcyan\">$table</font> <font color=\"darkorange\">WHERE</font> <font color=\"darkcyan\">$timeFilter</font> <font color=\"yellow\">AND</font> Server <font color=\"darkorange\">IN</font>(<font color=\"darkcyan\">$ServerName</font>) <font color=\"darkorange\">group by</font> t, ResponceCode <font color=\"darkorange\">ORDER BY</font> t) <font color=\"darkorange\">group by</font> t<br /> <font color=\"darkorange\">order by</font> t",
"formattedQuery": "<font color=\"darkorange\">SELECT</font> t, <font color=\"navajowhite\">groupArray</font>((<font color=\"navajowhite\">dictGetString</font>(<font color=\"lightgreen\">'dns_response'</font>, <font color=\"lightgreen\">'Name'</font>, <font color=\"navajowhite\">toUInt64</font>(ResponseCode)), <font color=\"navajowhite\">count</font><font color=\"yellow\">/</font><font color=\"darkcyan\">$interval</font>)) <font color=\"darkorange\">FROM</font> (<font color=\"darkorange\">SELECT</font> <font color=\"darkcyan\">$timeSeries</font> <font color=\"darkorange\">as</font> t, ResponseCode, <font color=\"navajowhite\">sum</font>(c) <font color=\"darkorange\">as</font> <font color=\"navajowhite\">count</font> <font color=\"darkorange\">FROM</font> <font color=\"darkcyan\">$table</font> <font color=\"darkorange\">WHERE</font> <font color=\"darkcyan\">$timeFilter</font> <font color=\"yellow\">AND</font> Server <font color=\"darkorange\">IN</font>(<font color=\"darkcyan\">$ServerName</font>) <font color=\"darkorange\">group by</font> t, ResponseCode <font color=\"darkorange\">ORDER BY</font> t) <font color=\"darkorange\">group by</font> t<br /> <font color=\"darkorange\">order by</font> t",
"intervalFactor": 1,
"query": "SELECT t, groupArray((dictGetString('dns_responce', 'Name', toUInt64(ResponceCode)), count/$interval)) FROM (SELECT $timeSeries as t, ResponceCode, sum(c) as count FROM DNS_RESPONCECODE WHERE $timeFilter group by t, ResponceCode ORDER BY t) group by t\n order by t",
"rawQuery": "SELECT t, groupArray((dictGetString('dns_responce', 'Name', toUInt64(ResponceCode)), count/2)) FROM (SELECT (intDiv(toUInt32(timestamp), 2) * 2) * 1000 as t, ResponceCode, sum(c) as count FROM default.DNS_RESPONCECODE WHERE DnsDate >= toDate(1506436944) AND timestamp >= toDateTime(1506436944) AND Server IN('valparaiso') group by t, ResponceCode ORDER BY t) group by t order by t",
"query": "SELECT t, groupArray((dictGetString('dns_response', 'Name', toUInt64(ResponseCode)), count/$interval)) FROM (SELECT $timeSeries as t, ResponseCode, sum(c) as count FROM DNS_RESPONSECODE WHERE $timeFilter group by t, ResponseCode ORDER BY t) group by t\n order by t",
"rawQuery": "SELECT t, groupArray((dictGetString('dns_response', 'Name', toUInt64(ResponseCode)), count/2)) FROM (SELECT (intDiv(toUInt32(timestamp), 2) * 2) * 1000 as t, ResponseCode, sum(c) as count FROM default.DNS_RESPONSECODE WHERE DnsDate >= toDate(1506436944) AND timestamp >= toDateTime(1506436944) AND Server IN('valparaiso') group by t, ResponseCode ORDER BY t) group by t order by t",
"refId": "A",
"resultFormat": "time_series",
"table": "DNS_RESPONCECODE",
"table": "DNS_RESPONSECODE",
"tableLoading": false,
"tags": [],
"targetLists": [
Expand Down
2 changes: 1 addition & 1 deletion src/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func SendData(connect clickhouse.Clickhouse, batch []DNSResult, server []byte) e
return err
}

_, err = connect.Prepare("INSERT INTO DNS_LOG (DnsDate, timestamp, Server, IPVersion, IPPrefix, Protocol, QR, OpCode, Class, Type, ResponceCode, Question, Size, Edns0Present, DoBit) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
_, err = connect.Prepare("INSERT INTO DNS_LOG (DnsDate, timestamp, Server, IPVersion, IPPrefix, Protocol, QR, OpCode, Class, Type, ResponseCode, Question, Size, Edns0Present, DoBit) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
if err != nil {
return err
}
Expand Down

0 comments on commit 6a00a3f

Please sign in to comment.