PluginBench
Skill
Pass
Audit score 90

prometheus

grafana/skills

PromQL queries, alerting rules, and metrics architecture for Prometheus and Grafana Cloud.

What is prometheus?

Comprehensive guide to Prometheus monitoring, PromQL query language, and Grafana Cloud Metrics integration. Use when writing PromQL queries, configuring alerts, setting up recording rules, or designing metrics-based observability.

  • Write PromQL instant and range vector queries with label filtering and regex matching
  • Calculate rates, increases, and aggregations (sum, avg, topk, histogram quantiles)
  • Configure Prometheus alerting rules with severity labels and Alertmanager routing
  • Create recording rules to pre-compute expensive queries for dashboard performance
  • Explore metrics interactively with Grafana Metrics Drilldown (Grafana 12+)
  • Validate rule syntax and reload Prometheus configurations

How to install prometheus

npx skills add https://github.com/grafana/skills --skill prometheus
Prerequisites
  • Prometheus server running and scraping metrics
  • Alertmanager configured for alert routing (if using alerting)
  • Grafana instance with Prometheus data source (for dashboards and Metrics Drilldown)
Claude Code
Cursor
Windsurf
Cline

How to use prometheus

  1. 1.Write PromQL queries using instant selectors (metric name and label filters) and range vectors (rate, increase)
  2. 2.Test aggregations and calculations locally in Prometheus UI or Grafana Explore
  3. 3.Create alerting rules in YAML with expr, for, labels, and annotations fields
  4. 4.Validate rule syntax with promtool check rules and amtool check-config
  5. 5.Deploy rules by adding to prometheus.yml rule_files and reloading with curl -X POST /-/reload
  6. 6.Verify rules are active by querying /api/v1/rules endpoint
  7. 7.Use Grafana Metrics Drilldown app for queryless metric exploration and anomaly detection

Use cases

Good for
  • Monitor API error rates and SLOs using rate() and error ratio calculations
  • Set up critical alerts routed to PagerDuty and warnings to Slack channels
  • Pre-compute expensive percentile queries (p99 latency) as recording rules
  • Predict disk saturation and resource exhaustion with linear extrapolation
  • Drill down metrics by labels to identify anomalies without manual PromQL
Who it's for
  • SRE and DevOps engineers managing Prometheus infrastructure
  • Backend developers writing observability queries and dashboards
  • Platform teams designing metrics architecture and alerting strategies
  • On-call engineers configuring alert routing and escalation policies

prometheus FAQ

What is the difference between rate() and irate()?

rate() calculates the per-second average over a time range (e.g., [5m]), smoothing out spikes. irate() calculates the instant rate using only the last two samples, better for detecting sudden changes but more volatile.

How do I calculate error rate percentage in PromQL?

Divide the sum of error requests by total requests and multiply by 100: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

What are recording rules and when should I use them?

Recording rules pre-compute expensive PromQL expressions at regular intervals (e.g., every 1m) and store results as new metrics. Use them for frequently-queried aggregations, percentiles, and calculations to reduce query load and dashboard latency.

How do I route alerts to different receivers based on severity?

Use Alertmanager routing with match conditions: define routes with match labels (e.g., severity: critical) and assign each route a receiver (PagerDuty, Slack, email). Alerts matching the condition are sent to that receiver.

Can I explore metrics without writing PromQL?

Yes, use Grafana Metrics Drilldown (Grafana 12+) at /a/grafana-metricsdrilldown-app for queryless metric browsing with label breakdown, smart segmentation, and auto-visualization.

Full instructions (SKILL.md)

Source of truth, from grafana/skills.


name: prometheus license: Apache-2.0 description: > Prometheus and Grafana Cloud Metrics overview including PromQL query language, Metrics Drilldown, alerting, recording rules, and integration patterns. Use when working with Prometheus, writing PromQL queries, configuring alerting, or discussing metrics architecture and best practices.

Metrics with Prometheus and Grafana

Docs: https://prometheus.io/docs/ | Grafana Cloud Metrics: https://grafana.com/docs/grafana-cloud/send-data/metrics/

PromQL Quick Reference

Instant Vector Selectors

# By metric name
http_requests_total

# Label filter
http_requests_total{job="api-server"}

# Multiple labels (AND)
http_requests_total{job="api-server", method="GET"}

# Regex
http_requests_total{job=~"api.*", status=~"5.."}

# Negative
http_requests_total{status!="200"}

Range Vectors & Rates

# Per-second rate over 5 minutes
rate(http_requests_total[5m])

# Increase over interval
increase(http_requests_total[1h])

# Instant rate (last two samples)
irate(http_requests_total[5m])

# Offset (5 minutes ago)
rate(http_requests_total[5m] offset 5m)

Aggregations

# Sum by label
sum by (job) (rate(http_requests_total[5m]))

# Average
avg by (instance) (node_cpu_seconds_total)

# Top-K
topk(5, rate(http_requests_total[5m]))

# Histogram quantiles
histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))

# Count distinct
count(up{job="api"})

Common Patterns

# Error rate percentage
sum(rate(http_requests_total{status=~"5.."}[5m]))
  / sum(rate(http_requests_total[5m])) * 100

# Saturation (CPU usage %)
100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)

# Memory usage
node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes

# Predict disk full (linear extrapolation)
predict_linear(node_filesystem_free_bytes[6h], 24*3600) < 0

Alerting Rules

Prometheus Alerting Rule

groups:
  - name: api_alerts
    rules:
      - alert: HighErrorRate
        expr: |
          sum(rate(http_requests_total{status=~"5.."}[5m]))
            / sum(rate(http_requests_total[5m])) > 0.05
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "High 5xx error rate ({{ $value | humanizePercentage }})"

Alertmanager Routing

# alertmanager.yml
route:
  receiver: default
  group_by: [alertname, job]
  group_wait: 30s
  group_interval: 5m
  routes:
    - match:
        severity: critical
      receiver: pagerduty
    - match:
        severity: warning
      receiver: slack

receivers:
  - name: pagerduty
    pagerduty_configs:
      - service_key: "<key>"
  - name: slack
    slack_configs:
      - channel: "#alerts"
        api_url: "<webhook_url>"
  - name: default
    email_configs:
      - to: "oncall@example.com"

Validate Alerting Configuration

promtool check rules rules.yml
amtool check-config alertmanager.yml
amtool config routes test --config.file=alertmanager.yml severity=critical

Recording Rules

Pre-compute expensive PromQL for dashboard performance:

groups:
  - name: api_rules
    interval: 1m
    rules:
      - record: job:http_requests:rate5m
        expr: sum by (job) (rate(http_requests_total[5m]))
      - record: job:http_request_duration_seconds:p99
        expr: histogram_quantile(0.99, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))

Deploy and Verify Recording Rules

# 1. Validate rule syntax
promtool check rules rules/recording.yml

# 2. Reload Prometheus (after adding to rule_files in prometheus.yml)
curl -X POST http://localhost:9090/-/reload

# 3. Verify rules are active
curl -s http://localhost:9090/api/v1/rules | jq '.data.groups[].rules[] | {name, health}'

Metrics Drilldown (Grafana 12+)

Queryless Prometheus exploration — browse metrics without writing PromQL. Navigate to Explore > Metrics Drilldown or use <grafana-url>/a/grafana-metricsdrilldown-app. Provides metric search with label breakdown, smart segmentation for anomaly detection, auto-visualization, and telemetry pivoting from metrics to related logs and traces.

Resources