blob: 5819f186afac54e4e14d78dfad819e775e4cedb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/bash
# Verify that epimetheus metrics were successfully ingested into ClickHouse.
# Usage: ./verify-clickhouse.sh [clickhouse_url] [table_name]
# Default: http://localhost:8123, epimetheus_metrics
set -e
CLICKHOUSE_URL="${1:-http://localhost:8123}"
TABLE="${2:-epimetheus_metrics}"
echo "Verifying ClickHouse ingestion..."
echo " URL: $CLICKHOUSE_URL"
echo " Table: $TABLE"
echo ""
# Check connectivity
if ! curl -sS "${CLICKHOUSE_URL}/ping" > /dev/null 2>&1; then
echo "ERROR: Cannot connect to ClickHouse at $CLICKHOUSE_URL"
echo " Make sure ClickHouse is running: sudo systemctl start clickhouse-server"
exit 1
fi
echo "✓ ClickHouse is reachable"
echo ""
# Query 1: Row count
echo "--- Row count ---"
COUNT=$(curl -sS "${CLICKHOUSE_URL}/?query=SELECT%20count()%20FROM%20${TABLE}" 2>/dev/null | tail -1)
if [ -z "$COUNT" ] || [ "$COUNT" = "0" ]; then
echo "ERROR: Table $TABLE is empty or does not exist"
echo " Run: ./epimetheus -mode=watch -file=test-data/watch-clickhouse-test.csv -metric-name=watch_test -clickhouse=$CLICKHOUSE_URL -prometheus="
exit 1
fi
echo "Total rows: $COUNT"
echo ""
# Query 2: Distinct metrics
echo "--- Metrics in table ---"
curl -sS "${CLICKHOUSE_URL}/?query=SELECT%20distinct%20metric%20FROM%20${TABLE}%20ORDER%20BY%20metric%20FORMAT%20PrettyCompact" 2>/dev/null
echo ""
# Query 3: Sample data
echo "--- Sample rows (last 5) ---"
curl -sS "${CLICKHOUSE_URL}/?query=SELECT%20metric%2C%20labels%2C%20value%2C%20timestamp%20FROM%20${TABLE}%20ORDER%20BY%20timestamp%20DESC%20LIMIT%205%20FORMAT%20PrettyCompact" 2>/dev/null
echo ""
# Query 4: Aggregation by metric
echo "--- Rows per metric ---"
curl -sS "${CLICKHOUSE_URL}/?query=SELECT%20metric%2C%20count()%20AS%20cnt%20FROM%20${TABLE}%20GROUP%20BY%20metric%20ORDER%20BY%20cnt%20DESC%20FORMAT%20PrettyCompact" 2>/dev/null
echo ""
echo "✅ ClickHouse verification complete - data is present and queryable"
|