HomeBlogHow to Monitor Production Applications with...

Engineering Guide · 9 min read · May 4, 2026

How to Monitor Production Applications with Prometheus and Grafana

Installing node_exporter and a dozen colorful CPU gauges does not tell you when checkout requests hang or background workers fall an hour behind. Here is how to instrument Prometheus around RED metrics and queue age, avoid cardinality explosions, and configure Alertmanager rules that wake engineers only when customer SLOs burn.

Author
Smit Desai
Published
May 4, 2026
Read time
9 min read
Topic
Cloud & DevOps
Services
Custom Web · Mobile Apps · All Services

Nothing erodes engineering morale faster than an on-call rotation drowning in Slack alerts that mean nothing, followed by a real customer outage nobody noticed until support tickets piled up. Most monitoring setups fail because they track machine symptoms ("CPU over 75% for 3 minutes") instead of customer experience ("5% of checkout requests timed out over the last 5 minutes").

When managing 300+ WordPress sites at server level for a Finnish partner alongside multi-tenant APIs across 170+ delivered projects, Prometheus and Grafana consistently proved to be the most reliable observability backbone—provided you discipline your label cardinality and route alerts strictly through actionable SLO thresholds.

Measure What Users Feel: RED Metrics and Queue Age

Before importing fifty community Grafana dashboards, instrument four signals that immediately expose 90% of production incidents:

  • Rate: Requests per second broken down by service and normalized route pattern.
  • Errors: HTTP 5xx responses, failed database transactions, and unhandled worker exceptions.
  • Duration: Request latency histograms (p50, p95, p99), never simple averages (an average hides a broken 12-second tail).
  • Queue oldest-item age: Not just queue length, because 500 fast jobs clear in two seconds while 50 stalled billing jobs mean your workers are deadlocked.

Expose Clean Histograms From Your Application

Use coarse, normalized route templates (/orders/:id, not /orders/89421) and keep histogram buckets aligned with your user-facing latency SLA:

var httpRequestDuration = prometheus.NewHistogramVec(
	prometheus.HistogramOpts{
		Namespace: "api",
		Name:      "http_request_duration_seconds",
		Help:      "HTTP request latency distribution by normalized route and status class.",
		Buckets:   []float64{0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0},
	},
	[]string{"method", "route", "status_class"},
)

Using status_class (2xx, 4xx, 5xx) instead of every individual HTTP code keeps label permutations tiny while giving you immediate error-budget math.

Guard Against Cardinality Explosions

Prometheus stores active time series in an in-memory head block and flushes chunks to disk. If an engineer accidentally attaches tenant_id, email, or full query strings as a metric label across 50,000 customers, active series jump from 10,000 to tens of millions—crashing the Prometheus server right when you need graphs during a spike.

Follow a strict split between telemetry types:

  • Metrics (Prometheus): Bounded labels only (service, route, queue, status_class, region). Keep total combinations per metric under a few thousand.
  • Logs & Traces (Loki / Tempo / OpenTelemetry): High-cardinality context (tenant_id, user_id, request_id, SQL bind parameters).

If you ever need per-tenant metrics for top enterprise accounts, track a synthetic tenant_tier label (enterprise, pro, free) in Prometheus and rely on structured logs for exact tenant attribution.

Configure Reliable Scrape Targets and Exporters

Combine white-box application metrics with targeted infrastructure exporters in prometheus.yml:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - /etc/prometheus/rules/*.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets: ["alertmanager.internal:9093"]

scrape_configs:
  - job_name: "saas-api"
    metrics_path: /metrics
    scrape_timeout: 10s
    static_configs:
      - targets: ["api-1.internal:9100", "api-2.internal:9100"]

  - job_name: "postgres-exporter"
    static_configs:
      - targets: ["db-primary.internal:9187"]

  - job_name: "redis-exporter"
    static_configs:
      - targets: ["redis-1.internal:9121"]

Pair this with pg_stat_statements on PostgreSQL and queue depth metrics from Redis—see our scaling background jobs and queues guide for the exact queue metrics worth exporting—plus backup freshness timestamps from automated PostgreSQL backups.

Write Symptom-Based Alerts That Respect Engineers' Sleep

Every page sent to an engineer at 2:30 AM must require immediate human intervention and link directly to a runbook. Put everything else on a morning ticket or dashboard.

Alert Condition Page On-Call Immediately? Better Routing
CPU > 85% for 2 minutes No Informative dashboard panel only
5xx error ratio burns > 2% of monthly SLO in 1 hour Yes High-severity page (PagerDuty / Opsgenie)
Critical queue oldest job > 10 minutes Yes High-severity page + worker restart runbook
Disk usage > 80% (projected full in < 48h) Business hours Slack/ticket to infra channel
Backup job failed or > 26 hours since last WAL Business hours (or urgent if primary) Infra alert with restore-drill check

Multi-Window Error Budget Burn Rules

Instead of fragile static thresholds that miss slow leaks or flap during brief blips, define PromQL recording and alerting rules against your monthly availability target (for example, 99.9% = 0.001 error budget):

groups:
  - name: api_slo_alerts
    rules:
      - record: job:http_errors_ratio:rate5m
        expr: |
          sum(rate(api_http_requests_total{status_class="5xx"}[5m]))
          /
          sum(rate(api_http_requests_total[5m]))

      - alert: ApiErrorBudgetFastBurn
        expr: |
          job:http_errors_ratio:rate5m > (14.4 * 0.001)
          and
          sum(rate(api_http_requests_total{status_class="5xx"}[1h]))
          /
          sum(rate(api_http_requests_total[1h])) > (14.4 * 0.001)
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "API 5xx error rate burning 30-day SLO at 14.4x pace"
          runbook: "https://internal.example.com/runbooks/api-5xx-burn"

Requiring both a 5-minute window and a 1-hour window to breach the threshold guarantees you catch catastrophic outages within minutes while suppressing 30-second transient blips automatically. You can study more cloud-native observability patterns from the CNCF blog and GitHub Engineering.

Design Grafana Dashboards for 60-Second Triage

A useful Grafana dashboard answers two questions in under one minute during an outage: is the problem inside our code, our database, or an external vendor—and did a recent deploy trigger it?

Structure your main service board top-to-bottom as a triage funnel:

  1. Row 1 (Impact): Overall request rate, 5xx error percentage, and p95/p99 latency with Git deploy annotations overlaid vertically.
  2. Row 2 (Dependencies): PostgreSQL active connections vs max_connections, lock waits, Redis hit ratio and memory fragmentation, and outbound third-party API latency/429 rates.
  3. Row 3 (Background Capacity): Queue oldest-job age, retry rate, and dead-letter queue count.

Overlaying deploy markers directly on latency and error panels immediately removes guesswork: when p99 triples at 14:22 and a deploy annotation sits at 14:21, you roll back first and debug afterward.

Putting Production Observability in Place With SmitDev

Whether you are a CTO replacing blind server logs ahead of an enterprise audit or stabilizing an existing system through our upgrade old software practice, SmitDev implements production Prometheus, Grafana, and Alertmanager stacks cleanly via Terraform and Ansible. You can bring on senior engineering capacity at $55/day for 8–9 hours of dedicated engineering work or $1,999/month for dedicated delivery, or engage us through remote software engineering.

Ready to stop finding out about outages from customer emails? Contact us with your current hosting setup and critical SLAs, and we will map out a practical monitoring rollout.

Written by Smit Desai · Principal Full-Stack & FDSE

8+ years shipping production systems · 171 case studies · 300+ WordPress servers managed for Finland partners.

Next Steps and Recommended Resources

Next Steps · Recommended Resources

Pillar 1 · Infrastructure Proof

300+ WordPress & Cloud Server Fleet

From server-level management of 300+ WordPress sites for a Finland client to PostgreSQL query tuning (3,982 -> 52 queries).

Pillar 2 · Legacy Rescue

Upgrade Old Software (10 Hrs Free)

Audit bottlenecks, eliminate security vulnerabilities, and stabilize production servers—starting with 10 free engineering hours.

01 — Frequently asked questions

cloud & devops

What is the biggest mistake teams make when adopting Prometheus?

Putting unbounded values like user_id, order_id, request UUID, or raw URL paths into metric labels. Each unique label combination creates a new time series in memory, quickly causing Prometheus RAM exhaustion and query timeouts.

Why alert on SLO burn rate instead of CPU or memory percentages?

High CPU during a batch import might not affect any user, whereas a database deadlock can tank checkout availability while server CPU sits at 15%. Symptom-based burn-rate alerts fire on error rate or latency impacting users, eliminating alert fatigue.

Should Prometheus scrape short-lived cron jobs or workers directly?

Use Prometheus scraping for long-running workers and exporters, and reserve the Pushgateway strictly for brief batch jobs that exit faster than your scrape interval—remembering to clear stale metrics or expose last-success timestamps so dead jobs are still detected.

How long should you retain metrics inside local Prometheus storage?

Local Prometheus TSDB handles 15 to 30 days efficiently on fast SSD storage for operational troubleshooting. When compliance or capacity planning requires 12+ months of history, forward samples via remote_write to VictoriaMetrics, Thanos, or Mimir.

03 — Have an engineering need?

hire the right expertise

Let's talk tech.

Deciding between an embedded forward deployed engineer or a senior full stack developer? Share your technical context and timeline.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.