Prometheus and PromQL Cheatsheet

← All cheatsheets
$ kubectl get servicemonitors -A
IntermediateObservabilityUpdated October 2026

Install the kube-prometheus-stack, check scrape targets and rules, and copy the PromQL queries you need most for Kubernetes.

Install and access

helm repo add prometheus-community https://prometheus-community.github.io/helm-chartsAdd the community chart repo
helm install kps prometheus-community/kube-prometheus-stack -n monitoring --create-namespaceInstall Prometheus, Alertmanager and Grafana
kubectl -n monitoring get svcFind the Prometheus and Grafana services
kubectl -n monitoring port-forward svc/kps-kube-prometheus-stack-prometheus 9090Open Prometheus on localhost:9090
kubectl get servicemonitors,podmonitors,prometheusrules -AList scrape and rule objects
promtool check rules rules.yamlValidate alerting and recording rules
promtool check config prometheus.ymlValidate a Prometheus config

Cluster health queries

up == 0Targets that are down
kube_pod_status_phase{phase="Pending"} == 1Pods stuck in Pending
increase(kube_pod_container_status_restarts_total[1h]) > 3Containers restarting often
kube_deployment_status_replicas_available / kube_deployment_spec_replicas < 1Deployments missing replicas
(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100Node memory used, in percent
predict_linear(node_filesystem_avail_bytes[6h], 24*3600) < 0Disks that will fill within a day
kubelet_volume_stats_used_bytes / kubelet_volume_stats_capacity_bytes > 0.8PVCs over 80 percent full

Workload and app queries

sum by (pod) (rate(container_cpu_usage_seconds_total{namespace="prod"}[5m]))CPU per pod
sum by (pod) (container_memory_working_set_bytes{namespace="prod"})Memory per pod
topk(5, sum by (pod) (rate(container_cpu_usage_seconds_total[5m])))Top 5 CPU heavy pods
sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))Error ratio
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))p95 latency

ServiceMonitor example

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: api
  namespace: prod
  labels:
    release: kps
spec:
  selector:
    matchLabels:
      app: api
  endpoints:
  - port: metrics
    interval: 30s
    path: /metrics