summaryrefslogtreecommitdiff
path: root/scripts/verify-clickhouse.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/verify-clickhouse.sh')
-rw-r--r--scripts/verify-clickhouse.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/verify-clickhouse.sh b/scripts/verify-clickhouse.sh
new file mode 100644
index 0000000..a9c3233
--- /dev/null
+++ b/scripts/verify-clickhouse.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Verify that epimetheus metrics were successfully ingested into ClickHouse.
+# Usage: ./scripts/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"