-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-queries.sh
More file actions
executable file
·32 lines (27 loc) · 1.06 KB
/
test-queries.sh
File metadata and controls
executable file
·32 lines (27 loc) · 1.06 KB
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
#!/bin/bash
# Test all Prometheus queries for OpsAI
echo "🔍 Testing all Prometheus queries..."
PROMETHEUS_URL="http://localhost:9090"
queries=(
"opsai_requests_total"
"rate(opsai_requests_total[5m])"
"sum by (endpoint) (opsai_requests_total)"
"sum by (http_status) (opsai_requests_total)"
"histogram_quantile(0.95, rate(opsai_request_latency_seconds_bucket[5m]))"
"process_resident_memory_bytes{job=\"opsai_api\"}"
"rate(process_cpu_seconds_total{job=\"opsai_api\"}[5m])"
"time() - process_start_time_seconds{job=\"opsai_api\"}"
"up{job=\"opsai_api\"}"
"python_gc_objects_collected_total{job=\"opsai_api\"}"
)
for query in "${queries[@]}"; do
echo "Testing: $query"
result=$(curl -s "$PROMETHEUS_URL/api/v1/query?query=$(echo "$query" | sed 's/ /%20/g' | sed 's/{/%7B/g' | sed 's/}/%7D/g' | sed 's/=/%3D/g' | sed 's/"/%22/g')" | jq '.data.result | length')
if [ "$result" -gt 0 ]; then
echo " ✅ Working ($result series)"
else
echo " ❌ No data"
fi
echo
done
echo "🎉 Query testing complete!"