--- title: "What I Monitor on zyvop.com, and the Alerts Worth Waking Up For" author: "Sanju Singh" published: "2026-11-26T05:34:56.954Z" updated: "2026-11-26T15:01:14.897Z" url: "https://zyvop.com/what-i-monitor-on-zyvop-com-and-the-alerts-worth-waking-up-for-17wfz" canonical: "https://zyvop.com/what-i-monitor-on-zyvop-com-and-the-alerts-worth-waking-up-for-17wfz" tags: ["monitoring","prometheus","alerting","Grafana","DevOps"] --- # What I Monitor on zyvop.com, and the Alerts Worth Waking Up For A Prometheus and Grafana setup built on the four golden signals, with a short alert list, version-tagged metrics, and an automatic post-deploy check. ![Cover image]() The CI/CD pipeline from my last [post]() can tell me a deploy _finished_. It can't tell me the site is still healthy an hour later, or that a slow query is quietly making every page worse. Monitoring fills that gap. I want two things from it: to hear about problems before visitors tell me, and to be woken up only when waking up is worth it. **TL;DR** - I watch four signals: **latency, traffic, errors, saturation**. - The app exports one request histogram labelled by route, status, and **version**. Exporters cover the servers, Postgres, Redis, and an external probe. - I alert on **symptoms visitors feel**. A page has to be urgent and actionable. Everything else becomes a ticket. - Every deploy **watches its own version's** error rate and latency before I trust it. * * * ## The four signals Google's SRE book calls these the four golden signals, and they cover most of what matters for a web service. | Signal | The question | Where it comes from | | --- | --- | --- | | **Latency** | How long do requests take? | Percentiles (p95, p99) from the request histogram | | **Traffic** | How much demand is there? | Request rate from the same histogram | | **Errors** | What share of requests fail? | 5xx ratio from the same histogram, plus an external probe | | **Saturation** | How full is the most constrained resource? | CPU, memory, disk, database connections, Redis memory, event loop lag | I watch percentiles, not averages. A few very slow requests barely move the mean, but they're exactly what unhappy visitors experience. Metrics tell me _that_ something is wrong. Logs tell me _why_, so I keep the centralized logging from my scaling post alongside this. * * * ## The setup ```mermaid flowchart LR V([Visitors]) --> LB[Load balancer] --> APP subgraph TARGETS["Scrape targets"] APP["Node app :9102
(three servers)"] NODE["node_exporter :9100
(three servers)"] PGX["postgres_exporter :9187"] RDX["redis_exporter :9121"] end subgraph MON["Monitoring server (private network)"] P[("Prometheus")] BB["blackbox_exporter :9115"] AM[Alertmanager] G[Grafana] end P -- "scrapes every 15s" --> TARGETS P -- "scrapes probe results" --> BB BB -- "probes /healthz" --> LB P --> AM G --> P AM -- "severity=page" --> PH[Phone alert] AM -- "severity=ticket" --> TK[Ticket channel] ``` - **Prometheus, Alertmanager, and Grafana run on their own small server**, so a problem on the app servers can't take the monitoring down with it. - **None of them face the internet.** Prometheus has no login by default, so I keep all three on the private network or behind a VPN. - Prometheus keeps 15 days of data unless I change the retention setting, which is plenty for diagnosing recent problems. * * * ## Step 1: Instrument the app ```javascript import http from "node:http"; import client from "prom-client"; client.collectDefaultMetrics(); // process_* and nodejs_* metrics, including event loop lag const VERSION = (process.env.APP_VERSION || "dev").slice(0, 7); // short git SHA const httpDuration = new client.Histogram({ name: "http_request_duration_seconds", help: "HTTP request duration in seconds", labelNames: ["method", "route", "status", "version"], buckets: [0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5], }); export function metricsMiddleware(req, res, next) { const stop = httpDuration.startTimer(); res.on("finish", () => { stop({ method: req.method, route: req.route ? (req.baseUrl || "") + req.route.path : "unmatched", status: String(res.statusCode), version: VERSION, }); }); next(); } // A separate internal port, so /metrics is never reachable through the load balancer http .createServer(async (req, res) => { if (req.url === "/metrics") { res.setHeader("Content-Type", client.register.contentType); res.end(await client.register.metrics()); } else { res.statusCode = 404; res.end(); } }) .listen(9102, process.env.METRICS_HOST || "127.0.0.1"); ``` I register `app.use(metricsMiddleware)` before my routes. A few details matter here: - **One histogram is enough.** Its `_count` series is my request counter, so it gives me traffic and error ratios as well as latency. - **Label by route pattern, never by raw URL.** `/users/:id` is one series. `/users/48213` is a new series for every user, and enough of those will overwhelm Prometheus. The same goes for user IDs, emails, and IP addresses. Unmatched requests (404s from scanners) all share the single label `unmatched` so they can't blow up the label count either. - `await register.metrics()`**.** It has returned a promise since prom-client v13, and forgetting the `await` serves `[object Promise]`. - **Set the** `Content-Type`**.** Prometheus 3 fails a scrape when the header is missing or unrecognised, instead of guessing like version 2 did. `register.contentType` is the right value. - `version` **is the 7-character git SHA**, taken from the same `APP_VERSION` the pipeline bakes into the image. That's what lets me compare versions side by side. Each deploy creates a fresh set of series, which is fine at my scale. If I ever deploy many times a day, I'd move the version to a single `app_info` metric and join on it instead. - `METRICS_HOST` is the server's private address. I firewall port 9102 so only the monitoring server can reach it. * * * ## Step 2: Scrape everything | Exporter | Port | What it gives me | | --- | --- | --- | | `node_exporter` (every app server) | 9100 | CPU, memory, disk, network | | `postgres_exporter` | 9187 | `pg_up`, connection counts and limits | | `redis_exporter` | 9121 | `redis_up`, memory used and limit | | `blackbox_exporter` | 9115 | An HTTPS probe of the public site, plus certificate expiry | ```yaml # prometheus.yml global: scrape_interval: 15s evaluation_interval: 15s rule_files: - alerts.yml alerting: alertmanagers: - static_configs: - targets: ["localhost:9093"] scrape_configs: - job_name: zyvop-app static_configs: - targets: ["10.0.1.11:9102", "10.0.1.12:9102", "10.0.1.13:9102"] - job_name: node static_configs: - targets: ["10.0.1.11:9100", "10.0.1.12:9100", "10.0.1.13:9100"] - job_name: postgres static_configs: - targets: ["10.0.1.31:9187"] - job_name: redis static_configs: - targets: ["10.0.1.32:9121"] - job_name: blackbox-http metrics_path: /probe params: module: [http_2xx] static_configs: - targets: ["https://zyvop.com/healthz"] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: localhost:9115 ``` ```yaml # blackbox.yml modules: http_2xx: prober: http timeout: 5s http: method: GET fail_if_not_ssl: true ``` The IPs are placeholders. The probe fetches the real public URL, so it exercises DNS, TLS, the CDN, and the load balancer together, which is what a visitor's request does. It also exposes the certificate's expiry date. I run the probe from a server that doesn't share a network with the app if I can. A probe that lives in the same data center can't see a network problem that cuts the site off from everyone else. * * * ## Step 3: Alerts that earn their place My rules: - **Alert on symptoms, not causes.** "Error rate above 5%" is something visitors feel. "CPU at 85%" might mean nothing. Causes belong on dashboards. - **A page must be urgent, actionable, and real.** If it can wait until morning, it's a ticket. - **Use** `for:` so a ten-second blip doesn't wake me. | Alert | Level | Fires when | | --- | --- | --- | | `SiteDown` | Page | The external probe fails for 2 minutes | | `HighErrorRate` | Page | More than 5% of requests are 5xx for 5 minutes (with a traffic floor) | | `HighLatency` | Page | p95 latency is above 1.5 seconds for 10 minutes | | `InstanceDown` | Ticket | A server stops reporting for 5 minutes | | `DiskFillingUp` | Ticket | A disk is predicted to fill within 24 hours | | `HighCPU` | Ticket | CPU is above 90% for 15 minutes | | `LowMemory` | Ticket | Less than 10% of memory is available for 15 minutes | | `DatabaseDown` | Ticket | Postgres isn't answering the exporter for 2 minutes | | `DatabaseConnectionsHigh` | Ticket | Connections are above 80% of the limit for 10 minutes | | `RedisDown` | Ticket | Redis isn't answering the exporter for 2 minutes | | `RedisMemoryHigh` | Ticket | Redis is above 90% of its `maxmemory` for 10 minutes | | `CertificateExpiringSoon` | Ticket | The certificate expires within 14 days | | `Watchdog` | Heartbeat | Always. It proves the alerting path is alive | `DatabaseDown` and `RedisDown` are tickets because if either goes down, the error-rate page fires anyway. The ticket just tells me why. The thresholds are starting points. I tune them after a week of looking at what normal actually is. ```yaml # alerts.yml groups: - name: zyvop-pages rules: - alert: SiteDown expr: probe_success{job="blackbox-http"} == 0 for: 2m labels: severity: page annotations: summary: "zyvop.com is failing external health checks" - alert: HighErrorRate expr: | ( sum(rate(http_request_duration_seconds_count{status=~"5.."}[5m])) / sum(rate(http_request_duration_seconds_count[5m])) ) > 0.05 and sum(rate(http_request_duration_seconds_count[5m])) > 0.1 for: 5m labels: severity: page annotations: summary: "More than 5% of requests are failing" - alert: HighLatency expr: | histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])) ) > 1.5 for: 10m labels: severity: page annotations: summary: "p95 latency has been above 1.5 seconds" - name: zyvop-tickets rules: - alert: InstanceDown expr: up{job=~"zyvop-app|node"} == 0 for: 5m labels: severity: ticket annotations: summary: "{{ $labels.instance }} ({{ $labels.job }}) has stopped reporting" - alert: DiskFillingUp expr: predict_linear(node_filesystem_avail_bytes{fstype!~"tmpfs|overlay|squashfs"}[6h], 24 * 3600) < 0 for: 30m labels: severity: ticket annotations: summary: "{{ $labels.instance }}:{{ $labels.mountpoint }} is predicted to fill within 24 hours" - alert: HighCPU expr: 1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) > 0.9 for: 15m labels: severity: ticket annotations: summary: "{{ $labels.instance }} CPU has been above 90%" - alert: LowMemory expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.10 for: 15m labels: severity: ticket annotations: summary: "{{ $labels.instance }} has under 10% memory available" - alert: DatabaseDown expr: pg_up == 0 for: 2m labels: severity: ticket annotations: summary: "Postgres is not responding" - alert: DatabaseConnectionsHigh expr: | sum by (instance) (pg_stat_activity_count) / max by (instance) (pg_settings_max_connections) > 0.8 for: 10m labels: severity: ticket annotations: summary: "Postgres connections are above 80% of the limit" - alert: RedisDown expr: redis_up == 0 for: 2m labels: severity: ticket annotations: summary: "Redis is not responding" - alert: RedisMemoryHigh expr: | redis_memory_used_bytes / redis_memory_max_bytes > 0.9 and on (instance) redis_memory_max_bytes > 0 for: 10m labels: severity: ticket annotations: summary: "Redis is above 90% of maxmemory" - alert: CertificateExpiringSoon expr: probe_ssl_earliest_cert_expiry{job="blackbox-http"} - time() < 14 * 24 * 3600 for: 1h labels: severity: ticket annotations: summary: "The TLS certificate expires in less than 14 days" - name: zyvop-watchdog rules: - alert: Watchdog expr: vector(1) labels: severity: heartbeat annotations: summary: "Always firing. If this stops arriving, alerting is broken." ``` Two expressions are worth a second look: - `HighErrorRate` **has a traffic floor** (`> 0.1` requests per second). Without it, two failed requests out of three at 3 a.m. would be a "100% error rate" page. - `RedisMemoryHigh` **has the** `redis_memory_max_bytes > 0` **guard.** When no `maxmemory` is configured, the exporter reports 0, the division returns infinity, and the alert would fire forever. * * * ## Step 4: Route alerts to the right place ```yaml # alertmanager.yml route: receiver: ticket group_by: [alertname] group_wait: 30s group_interval: 5m repeat_interval: 24h routes: - matchers: ['severity="page"'] receiver: page group_wait: 10s repeat_interval: 1h - matchers: ['severity="heartbeat"'] receiver: heartbeat group_wait: 0s repeat_interval: 5m receivers: - name: page webhook_configs: - url: "https://example.com/hooks/page" # my phone-alert service send_resolved: true - name: ticket webhook_configs: - url: "https://example.com/hooks/ticket" # a chat channel or ticket queue send_resolved: true - name: heartbeat webhook_configs: - url: "https://example.com/hooks/heartbeat" # an external heartbeat monitor send_resolved: false ``` The root route has no matchers, so it catches everything that isn't a page or a heartbeat, and those become tickets. Alertmanager recommends `repeat_interval` be a multiple of `group_interval`, which all of mine are. I use webhooks to keep the example short. Alertmanager also has built-in receivers for email, Slack, PagerDuty, and others. * * * ## Step 5: One dashboard I build a single "golden signals" dashboard in Grafana. Alerts wake me up, and the dashboard is where I find out what's wrong. | Panel | PromQL | | --- | --- | | Traffic (requests per second) | `sum(rate(http_request_duration_seconds_count[5m]))` | | Error ratio | `sum(rate(http_request_duration_seconds_count{status=~"5.."}[5m])) / sum(rate(http_request_duration_seconds_count[5m]))` | | Latency p95 | `histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))` | | Error ratio by version | `sum by (version) (rate(http_request_duration_seconds_count{status=~"5.."}[5m])) / sum by (version) (rate(http_request_duration_seconds_count[5m]))` | | Latency p95 by version | `histogram_quantile(0.95, sum by (le, version) (rate(http_request_duration_seconds_bucket[5m])))` | | Five slowest routes | `topk(5, histogram_quantile(0.95, sum by (le, route) (rate(http_request_duration_seconds_bucket[5m]))))` | | CPU used | `1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))` | | Memory available | `node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes` | | Database connections used | `sum by (instance) (pg_stat_activity_count) / max by (instance) (pg_settings_max_connections)` | | Event loop lag | `nodejs_eventloop_lag_seconds` | The two "by version" panels show what a deploy changed. If the error ratio steps up exactly when a new version appears, I know where to look. Grafana can also draw deploy markers, and the pipeline can create one per deploy through Grafana's HTTP API. * * * ## Step 6: Make every deploy watch itself My smoke test checks that the new version is _serving_. This step checks that it's serving _well_: it watches that version's real traffic for a few minutes and fails if the error ratio or latency is bad. ```bash #!/usr/bin/env bash # /srv/zyvop/verify-release.sh # Watch the new version's real traffic for a few minutes. Exit 1 if it looks unhealthy. set -euo pipefail PROM="${PROM_URL:-http://localhost:9090}" VERSION="${1:0:7}" # the app labels its metrics with the 7-character SHA WATCH_SECONDS="${WATCH_SECONDS:-300}" INTERVAL="${INTERVAL:-30}" MIN_REQUESTS="${MIN_REQUESTS:-20}" MAX_ERROR_RATIO="${MAX_ERROR_RATIO:-0.02}" MAX_P95_SECONDS="${MAX_P95_SECONDS:-1.0}" SEL="version=\"$VERSION\"" REQUESTS="sum(increase(http_request_duration_seconds_count{$SEL}[5m]))" ERRORS="(sum(rate(http_request_duration_seconds_count{$SEL,status=~\"5..\"}[5m])) or vector(0)) / sum(rate(http_request_duration_seconds_count{$SEL}[5m]))" P95="histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket{$SEL}[5m])))" query() { # first value of an instant query, or "none" when there is no data curl -fsS --max-time 10 --get "$PROM/api/v1/query" --data-urlencode "query=$1" \ | jq -r '.data.result[0].value[1] // "none"' } is_number() { [[ "$1" =~ ^[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?$ ]]; } greater() { is_number "$1" && awk -v a="$1" -v b="$2" 'BEGIN { exit !(a > b) }'; } at_least() { is_number "$1" && awk -v a="$1" -v b="$2" 'BEGIN { exit !(a >= b) }'; } deadline=$(( $(date +%s) + WATCH_SECONDS )) bad=0 judged=0 while (( $(date +%s) < deadline )); do n=$(query "$REQUESTS") if at_least "$n" "$MIN_REQUESTS"; then judged=1 err=$(query "$ERRORS") p95=$(query "$P95") if greater "$err" "$MAX_ERROR_RATIO" || greater "$p95" "$MAX_P95_SECONDS"; then bad=$((bad + 1)) echo "unhealthy ($bad in a row): error ratio $err, p95 ${p95}s" >&2 if (( bad >= 2 )); then echo "version $VERSION failed verification" >&2 exit 1 fi else bad=0 echo "healthy: $n requests, error ratio $err, p95 ${p95}s" fi else echo "not enough traffic yet for $VERSION (requests in the last 5m: $n)" fi sleep "$INTERVAL" done if (( bad > 0 )); then echo "version $VERSION was still unhealthy at the end of the window" >&2 exit 1 fi if (( judged == 0 )); then echo "warning: $VERSION never reached $MIN_REQUESTS requests, so nothing was judged" >&2 fi echo "verification finished for $VERSION" ``` How it behaves: - **It judges only with enough traffic.** Below `MIN_REQUESTS` in the last five minutes, a single failed request would look like a 50% error rate, so it waits instead. - **It needs two bad checks in a row.** One blip doesn't fail a deploy, but a problem that persists for a minute does. - **No 5xx series at all counts as zero errors.** The `or vector(0)` handles that, because the numerator would otherwise be empty and the whole ratio would return nothing. - **A version that never gets enough traffic is not blamed.** It prints a warning and passes, because the smoke test already confirmed it's serving. - **If Prometheus is unreachable, the script fails.** I'd rather a deploy complain that it can't see the metrics than claim a healthy result it didn't check. - **It needs** `jq` **on the deploy host**, and `PROM_URL` pointing at Prometheus if it isn't running locally. The version comes from the pipeline's entry script, which already requires exactly 40 lowercase hex characters, so nothing unsafe reaches the query. I add one branch to the `case` in `ci-entry.sh`: ```bash verify) valid_sha "$version" || { echo "invalid version" >&2; exit 2; } exec /srv/zyvop/verify-release.sh "$version" ;; ``` And one step at the end of the deploy job in `deploy.yml`: ```yaml - name: Watch the new version's real traffic run: ssh -o BatchMode=yes -o ServerAliveInterval=30 deploy@"$DEPLOY_HOST" "verify $SHA" ``` `ServerAliveInterval` keeps the SSH connection from being dropped while the script waits. The job's 30-minute timeout leaves plenty of room for the five-minute watch. ```mermaid sequenceDiagram participant GH as GitHub Actions participant DH as Deploy host participant P as Prometheus GH->>DH: ssh deploy SHA DH-->>GH: Rolling deploy done GH->>GH: Smoke test checks X-App-Version GH->>DH: ssh verify SHA loop every 30 seconds for 5 minutes DH->>P: Error ratio and p95 for this version P-->>DH: Values end DH-->>GH: Exit 0 if healthy, 1 if not ``` If this step fails, the job goes red and I get notified. Then I decide whether to run the rollback workflow. I don't roll back automatically yet. An automatic rollback has to be built so it can't loop or fight with a human, and I'd rather earn that trust first. * * * ## Who watches the watcher? If Prometheus or Alertmanager dies, silence looks exactly like "everything is fine." Two cheap defenses: - **The** `Watchdog` **alert** always fires. Alertmanager sends it to an external heartbeat service every few minutes, and that service alerts me when the heartbeats _stop_. - **An external uptime check** from a provider outside my infrastructure. It only knows whether the site answers, which is exactly why it keeps working when everything I run myself is down. * * * ## Mistakes I'm trying not to make 1. **Paging on causes.** CPU at 85% isn't an emergency. Visitors getting errors is. 2. **Paging on everything.** After a week of false alarms, I'll start ignoring the real one. 3. **Using averages.** They hide the slow tail. 4. **High-cardinality labels.** Raw URLs, user IDs, and emails will overwhelm Prometheus. 5. **Exposing** `/metrics`**, Prometheus, or Grafana to the internet.** 6. **Copying thresholds without a baseline.** What's normal for someone else isn't normal for zyvop.com. 7. **Never testing the alert path.** I send a test alert through each receiver before I need one. 8. **No heartbeat.** A dead monitoring system doesn't alert. * * * ## My monitoring checklist - The app exports a request histogram labelled by route pattern, status, and short version - `/metrics` is on an internal port, firewalled, with the right `Content-Type` - `node_exporter` on every server, plus Postgres and Redis exporters - External HTTPS probe, ideally from outside my own network - Pages only for `SiteDown`, `HighErrorRate`, and `HighLatency`. Everything else is a ticket - Every alert has a `for:` duration and a summary I'll understand at 3 a.m. - Redis memory alert has its `maxmemory > 0` guard - Alertmanager routes pages, tickets, and the heartbeat separately - Prometheus, Alertmanager, and Grafana are private, on their own server - One golden-signals dashboard, including by-version panels - The deploy pipeline runs the post-deploy verification - A heartbeat and an external uptime check cover the monitoring itself - I've sent a test alert through every receiver * * * ## Final thoughts Good monitoring is mostly restraint: a small set of signals, a short list of alerts that deserve to interrupt me, and one dashboard I actually understand. The part I like most is the by-version labelling, because it turns "did that deploy break something?" from a hunch into a graph. Next in the series is hardening the path that deploys all of this: the SSH keys, firewall rules, and secrets the pipeline depends on. _What's the best alert you've ever had, and the worst false alarm? Tell me in the comments and I'll cover it in a follow-up._