Skip to content

Commit

Permalink
autobuild fixes
Browse files Browse the repository at this point in the history
changed docker-compose to `docker compose`
updated clickhouse version
updated panel.json to work with new clickhouse version
  • Loading branch information
mosajjal committed Oct 22, 2023
1 parent 7c2a687 commit 63fdcaf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
26 changes: 12 additions & 14 deletions autobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EOF

dockercomposetemplate=$(cat <<EOF
ch:
image: clickhouse/clickhouse-server:22.8.13.20-alpine
image: clickhouse/clickhouse-server:23.8.4.69-alpine
restart: always
ports:
- "8123:8123"
Expand Down Expand Up @@ -74,14 +74,12 @@ dnsmonsteragent=$(cat <<EOF
EOF
)

echo "Starting the DNSMonster AIO Builder using docker-compose."
echo "Starting the DNSMonster AIO Builder using docker compose."
echo "IMPORTANT: this script should be run when you are inside dnsmonster directory (./autobuild.sh). Do NOT run this from another directory"
echo -n "before we begin, make sure to have TCP ports 3000, 8123 and 9000 available in your host machine and press Enter to continue..."
read
echo -n "Checking if docker-compose binary exists.."
which docker-compose
echo -n "Checking to see if Docker binary exists..."
which docker
echo "Checking if docker compose exists.."
docker compose > /dev/null
echo -n "Checking to see if sed exists..."
which sed
echo -n "Checking to see if tr exists..."
Expand Down Expand Up @@ -144,30 +142,30 @@ old_ttl_line="TTL DnsDate + INTERVAL 30 DAY -- DNS_TTL_VARIABLE"
sed -i "s/$old_ttl_line/$new_ttl_line/" ./clickhouse/tables.sql

echo "Starting the containers..."
docker-compose up -d
docker compose up -d

echo "Waiting 20 seconds for Containers to be fully up and running "
sleep 20

echo "Create tables for Clickhouse"
docker-compose exec ch /bin/sh -c 'cat /tmp/tables.sql | clickhouse-client -h 127.0.0.1 --multiquery'
docker compose exec ch /bin/sh -c 'cat /tmp/tables.sql | clickhouse-client -h 127.0.0.1 --multiquery'

echo "downloading latest version of Clickhouse plugin for Grafana"
# docker-compose exec grafana /sbin/curl -L https://github.com/Vertamedia/clickhouse-grafana/releases/download/v2.4.2/vertamedia-clickhouse-datasource-2.4.2.zip -o /tmp/vertamedia-clickhouse-datasource-2.4.2.zip
# docker-compose exec grafana unzip /tmp/vertamedia-clickhouse-datasource-2.4.2.zip -d /var/lib/grafana/plugins/
docker-compose exec grafana grafana-cli plugins install vertamedia-clickhouse-datasource
# docker compose exec grafana /sbin/curl -L https://github.com/Vertamedia/clickhouse-grafana/releases/download/v2.4.2/vertamedia-clickhouse-datasource-2.4.2.zip -o /tmp/vertamedia-clickhouse-datasource-2.4.2.zip
# docker compose exec grafana unzip /tmp/vertamedia-clickhouse-datasource-2.4.2.zip -d /var/lib/grafana/plugins/
docker compose exec grafana grafana-cli plugins install vertamedia-clickhouse-datasource

echo "restarting grafana container after plugin installation"
docker-compose restart grafana
docker compose restart grafana
sleep 10

echo "Adding the datasource to Grafana"
docker-compose exec grafana /sbin/curl -H 'Content-Type:application/json' 'http://admin:[email protected]:3000/api/datasources' --data-raw '{"name":"ClickHouse","type":"vertamedia-clickhouse-datasource","url":"http://ch:8123","access":"proxy"}'
docker compose exec grafana /sbin/curl -H 'Content-Type:application/json' 'http://admin:[email protected]:3000/api/datasources' --data-raw '{"name":"ClickHouse","type":"vertamedia-clickhouse-datasource","url":"http://ch:8123","access":"proxy"}'
echo

echo "Adding the dashboard to Grafana"
dashboard_json=`cat grafana/panel.json | bin/jq '{Dashboard:.} | .Dashboard.id = null'`
docker-compose exec grafana /sbin/curl -H 'Content-Type:application/json' 'http://admin:[email protected]:3000/api/dashboards/db' --data "$dashboard_json"
docker compose exec grafana /sbin/curl -H 'Content-Type:application/json' 'http://admin:[email protected]:3000/api/dashboards/db' --data "$dashboard_json"
echo

echo
Expand Down
6 changes: 3 additions & 3 deletions grafana/panel.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@
"datetimeLoading": false,
"formattedQuery": "<font color=\"darkorange\">SELECT</font> <font color=\"cornflowerblue\">0</font>, <font color=\"navajowhite\">groupArray</font>((IP, total)) <font color=\"darkorange\">FROM</font> (<font color=\"darkorange\">SELECT</font> <font color=\"navajowhite\">IPv4NumToString</font>(toUInt32(SrcIP)) <font color=\"darkorange\">AS</font> IP,<br /><font color=\"navajowhite\">sum</font>(c) <font color=\"darkorange\">as</font> total <font color=\"darkorange\">FROM</font> <font color=\"darkcyan\">$table</font> <font color=\"darkorange\">PREWHERE</font> IPVersion<font color=\"yellow\">=</font><font color=\"cornflowerblue\">4</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> SrcIP <font color=\"darkorange\">order by</font> SrcIP)",
"intervalFactor": 1,
"query": "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)",
"query": "SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(SrcIP) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=4 WHERE $timeFilter GROUP BY SrcIP order by SrcIP desc limit 20)",
"refId": "A",
"resultFormat": "time_series",
"table": "DNS_SRCIP_MASK",
Expand Down Expand Up @@ -796,7 +796,7 @@
"datetimeLoading": false,
"formattedQuery": "<font color=\"darkorange\">SELECT</font> <font color=\"cornflowerblue\">0</font>, <font color=\"navajowhite\">groupArray</font>((IP, total)) <font color=\"darkorange\">FROM</font> (<font color=\"darkorange\">SELECT</font> <font color=\"navajowhite\">IPv6NumToString</font>(<font color=\"navajowhite\">toFixedString</font>(<font color=\"navajowhite\">unhex</font>(<font color=\"navajowhite\">hex</font>(SrcIP)), <font color=\"cornflowerblue\">16</font>)) <font color=\"darkorange\">AS</font> IP,<br /><font color=\"navajowhite\">sum</font>(c) <font color=\"darkorange\">as</font> total <font color=\"darkorange\">FROM</font> <font color=\"darkcyan\">$table</font> <font color=\"darkorange\">PREWHERE</font> IPVersion<font color=\"yellow\">=</font><font color=\"cornflowerblue\">6</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> SrcIP <font color=\"darkorange\">order by</font> SrcIP <font color=\"darkorange\">desc</font> <font color=\"darkorange\">limit</font> <font color=\"cornflowerblue\">20</font>)",
"intervalFactor": 1,
"query": "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)",
"query": "SELECT 0, groupArray((IP, total)) FROM (SELECT IPv6NumToString(SrcIP) AS IP,sum(c) as total FROM DNS_SRCIP_MASK PREWHERE IPVersion=6 WHERE $timeFilter GROUP BY SrcIP order by SrcIP desc limit 20)",
"refId": "A",
"resultFormat": "time_series",
"table": "DNS_SRCIP_MASK",
Expand Down Expand Up @@ -1560,4 +1560,4 @@
"name": "dnsmonster",
"uid": "lyxfOy-Wz",
"version": 19
}
}

0 comments on commit 63fdcaf

Please sign in to comment.