- Remove m3coordinator LoadBalancer service (was using deprecated AutoSSL) - Add Traefik ingress controller with Let's Encrypt ACME - Add basic auth middleware for external access - Update test scripts with auth support and fixed protobuf encoding - Add multi-tenancy documentation (label-based isolation) - Update README with Traefik deployment instructions
94 lines
3.2 KiB
Bash
Executable File
94 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Simple M3DB connectivity test
|
|
# Usage: ./test-metrics.sh <BASE_URL> [USERNAME] [PASSWORD]
|
|
#
|
|
# Examples:
|
|
# ./test-metrics.sh https://m3db.vultrlabs.dev example example
|
|
# ./test-metrics.sh http://192.168.1.100:7201
|
|
#
|
|
|
|
set -e
|
|
|
|
BASE_URL="${1:-}"
|
|
USERNAME="${2:-}"
|
|
PASSWORD="${3:-}"
|
|
|
|
if [ -z "$BASE_URL" ]; then
|
|
echo "Usage: $0 <BASE_URL> [USERNAME] [PASSWORD]"
|
|
echo "Example: $0 https://m3db.vultrlabs.dev example example"
|
|
echo " $0 http://192.168.1.100:7201"
|
|
exit 1
|
|
fi
|
|
|
|
# Remove trailing slash if present
|
|
BASE_URL="${BASE_URL%/}"
|
|
|
|
# Build auth flag if credentials provided
|
|
AUTH_FLAG=""
|
|
if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then
|
|
AUTH_FLAG="-u ${USERNAME}:${PASSWORD}"
|
|
fi
|
|
|
|
echo "=== M3DB Connectivity Test ==="
|
|
echo "Target: ${BASE_URL}"
|
|
if [ -n "$AUTH_FLAG" ]; then
|
|
echo "Auth: ${USERNAME}:***"
|
|
fi
|
|
echo ""
|
|
|
|
# Health check
|
|
echo "1. Coordinator Health"
|
|
if curl -sf $AUTH_FLAG "${BASE_URL}/health" > /dev/null 2>&1; then
|
|
echo " ✓ Healthy"
|
|
else
|
|
echo " ✗ Unhealthy or unreachable"
|
|
exit 1
|
|
fi
|
|
|
|
# Placement
|
|
echo ""
|
|
echo "2. Placement (cluster topology)"
|
|
PLACEMENT=$(curl -sf $AUTH_FLAG "${BASE_URL}/api/v1/services/m3db/placement" 2>/dev/null || echo '{}')
|
|
INSTANCE_COUNT=$(echo "$PLACEMENT" | python3 -c "import sys,json; d=json.load(sys.stdin).get('placement',{}).get('instances',{}); print(len(d))" 2>/dev/null || echo "0")
|
|
if [ "$INSTANCE_COUNT" -gt 0 ]; then
|
|
echo " ✓ $INSTANCE_COUNT instances in placement"
|
|
echo "$PLACEMENT" | python3 -c "import sys,json; d=json.load(sys.stdin).get('placement',{}).get('instances',{}); [print(f' - {k}') for k in d.keys()]" 2>/dev/null || true
|
|
else
|
|
echo " ✗ No placement configured (run init job)"
|
|
fi
|
|
|
|
# Namespaces
|
|
echo ""
|
|
echo "3. Namespaces (retention policies)"
|
|
NAMESPACES=$(curl -sf $AUTH_FLAG "${BASE_URL}/api/v1/services/m3db/namespace" 2>/dev/null || echo '{}')
|
|
NS_COUNT=$(echo "$NAMESPACES" | python3 -c "import sys,json; d=json.load(sys.stdin).get('registry',{}).get('namespaces',{}); print(len(d))" 2>/dev/null || echo "0")
|
|
if [ "$NS_COUNT" -gt 0 ]; then
|
|
echo " ✓ $NS_COUNT namespaces configured"
|
|
echo "$NAMESPACES" | python3 -c "import sys,json; d=json.load(sys.stdin).get('registry',{}).get('namespaces',{}); [print(f' - {k}') for k in d.keys()]" 2>/dev/null || true
|
|
else
|
|
echo " ✗ No namespaces configured (run init job)"
|
|
fi
|
|
|
|
# Query test
|
|
echo ""
|
|
echo "4. Query Test (PromQL)"
|
|
QUERY_RESULT=$(curl -sf $AUTH_FLAG "${BASE_URL}/api/v1/query?query=up" 2>/dev/null || echo '{"status":"error"}')
|
|
STATUS=$(echo "$QUERY_RESULT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status','error'))" 2>/dev/null || echo "error")
|
|
if [ "$STATUS" = "success" ]; then
|
|
RESULT_COUNT=$(echo "$QUERY_RESULT" | python3 -c "import sys,json; print(len(json.load(sys.stdin).get('data',{}).get('result',[])))" 2>/dev/null || echo "0")
|
|
echo " ✓ Query returned: $RESULT_COUNT series"
|
|
else
|
|
echo " ✗ Query failed"
|
|
fi
|
|
|
|
# Write test (requires protobuf + snappy, so just note it)
|
|
echo ""
|
|
echo "5. Write Test"
|
|
echo " Note: Prometheus remote_write requires protobuf + snappy encoding."
|
|
echo " Use test-metrics.py for full write/read verification."
|
|
echo " Install: pip install python-snappy requests"
|
|
|
|
echo ""
|
|
echo "=== Test Complete ==="
|