devops101 › Cheat sheet'ler › 🔥 Prometheus (PromQL) cheat sheet

🔥 Prometheus (PromQL) cheat sheet

Temel sorgular

upHedef erişilebilir mi (1/0)
up == 0Erişilemeyen hedefler
rate(http_requests_total[5m])Saniyelik istek hızı
increase(http_requests_total[1h])Son 1 saatte artış
sum by (job) (rate(http_requests_total[5m]))Job başına toplam
topk(5, sum by (pod) (rate(x[5m])))En yüksek 5
http_requests_total{status=~"5.."}Regex etiket filtresi
avg_over_time(cpu[10m])Zaman penceresi ortalaması

Sık kullanılanlar

sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))Hata oranı
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))p95 gecikme
100 - (avg(rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)CPU kullanımı %
node_memory_MemAvailable_bytes / node_memory_MemTotal_bytesBoş bellek oranı
predict_linear(node_filesystem_avail_bytes[1h], 4*3600) < 04 saatte disk dolar mı
kube_pod_container_status_restarts_totalPod yeniden başlatmaları

Yapılandırma ve alarm

scrape_configs: - job_name: web static_configs: - targets: ["web:3000"]Hedef tanımı
groups: - name: web rules: - alert: YuksekHata expr: oran > 0.05 for: 10mAlarm kuralı
record: job:http_requests:rate5mRecording rule
promtool check config prometheus.ymlYapılandırma doğrula
promtool check rules kural.ymlKural doğrula

Uygulamada aç ve alıştırmaları çöz →