cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

cat/module-path
012 / scripts / stress / clickhouse-load.sh
clickhouse-load.sh 1.6K executable
1#!/usr/bin/env bash2# clickhouse-load.sh - load the stress run records (runs.jsonl) into the3# observability stack's ClickHouse, table stress.results, for Grafana.4# Loading the same runs again is harmless: the table deduplicates, and5# queries read it with FINAL. make stress runs this when the stack is up.6set -euo pipefail78root=$(cd "$(dirname "$0")/../.." && pwd)9results=${RESULTS:-"$root/.deps/stress/results/runs.jsonl"}10url=${CLICKHOUSE_URL:-http://localhost:8123}11auth="${CLICKHOUSE_USER:-o12}:${CLICKHOUSE_PASSWORD:-o12}"12compose="$root/deploy/observability/docker-compose.yml"1314if [ ! -s "$results" ]; then15 echo "stress-load: no results in $results; run make stress first" >&216 exit 117fi18if ! curl -fsS -o /dev/null "$url/ping"; then19 echo "stress-load: ClickHouse isn't answering at $url; run make obs-up" >&220 exit 121fi2223# The schema is created when the stack first starts; this keeps an older24# volume current.25docker compose -f "$compose" exec -T clickhouse \26 clickhouse-client --user "${auth%%:*}" --password "${auth#*:}" --multiquery \27 <"$root/deploy/observability/clickhouse/init.sql"2829query='INSERT INTO stress.results SETTINGS date_time_input_format = '\''best_effort'\'' FORMAT JSONEachRow'30# The body is the query, then the rows.31{ echo "$query"; cat "$results"; } | curl -fsS -u "$auth" --data-binary @- -o /dev/null "$url/"32runs=$(curl -fsS -u "$auth" --get --data-urlencode "query=SELECT uniqExact(run_id), count() FROM stress.results FINAL FORMAT TSV" "$url/")33echo "stress-load: ClickHouse stress.results now holds $(echo "$runs" | cut -f1) runs, $(echo "$runs" | cut -f2) rows"