// ALERTS

Simple metric alerts to Slack or a webhook, from one curl

Short answer: send the number from your script to EzStat with one curl, then set a threshold alert on that stat once. When the value crosses the threshold, EzStat posts to your webhook or Slack, and posts again when it recovers. The script never sends the alert itself, so it never needs Slack credentials. Free is $0 with no card, open to the first 250 accounts — 10 stats, 300,000 datapoints a month, 30-day retention, with charts, Ask and MCP. A place is taken when your first datapoint is stored, after you confirm your email. Threshold alerts start on Indie at $19 a month; the full reference is in the API docs.

How it works

There are two pieces, and they are deliberately separate:

  1. Your script records a metric. One HTTPS POST per data point: a counter (failures, retries, orders) or a value (disk usage, queue depth, run time).
  2. EzStat watches the metric. You create an alert once. EzStat checks it against your data and delivers to a webhook or Slack when the condition is met.

Because the script only reports a number, it stays tiny. Change who gets notified, or the threshold, without touching the script.

Step 1: send a metric from your shell script

The v1 write routes take your API key as a Bearer token and answer with real HTTP status codes. A counter:

curl -sS --max-time 5 -X POST https://api.ezstat.dev/api/v1/stats/backup_failures/count \
  -H "Authorization: Bearer $EZSTAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"count": 1}'

A value:

used=$(df --output=pcent / | tail -1 | tr -dc '0-9')
curl -sS --max-time 5 -X POST https://api.ezstat.dev/api/v1/stats/disk_used_pct/value \
  -H "Authorization: Bearer $EZSTAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"value\": $used}"

An accepted point answers {"status":"ok"} with HTTP 200. The stat is created the first time you send it and gets a chart straight away. (df --output is GNU coreutils; on macOS, parse df -P instead.)

Step 2: report failures from a bash script

For a “bash script Slack alert on failure”, count the failure instead of messaging anyone. A trap catches any error in the script:

#!/usr/bin/env bash
set -eEuo pipefail

report() {  # report <stat> <count>; best-effort, never fails the script
  curl -sS --max-time 5 -X POST "https://api.ezstat.dev/api/v1/stats/$1/count" \
    -H "Authorization: Bearer $EZSTAT_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"count\": $2}" > /dev/null || true
}

trap 'report backup_failures 1' ERR   # still the last point at the next check -> alert fires

# --- your work ---
pg_dump mydb | gzip > /backups/mydb-$(date +%F).sql.gz
# -----------------

report backup_runs_ok 1
report backup_failures 0   # last point = 0 -> alert recovers

Run it from cron as usual, with EZSTAT_API_KEY set in the crontab or sourced from a file only the job's user can read. A zero is a real datapoint, not a no-op: it is what lets the alert resolve after a good run. Each check reads the latest point, so this pattern suits hourly or nightly jobs, where a failure is still the latest point when the check runs.

Step 3: create the alert once

Alerts are created with POST /api/v1/alerts, using the same API key you send metrics with. This one fires when backup_failures goes above 0 and posts to your webhook:

curl -sS -X POST https://api.ezstat.dev/api/v1/alerts \
  -H "Authorization: Bearer $EZSTAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stat_name": "backup_failures",
    "condition_type": "above",
    "threshold": 0,
    "window_minutes": 15,
    "channel": "webhook",
    "channel_config": { "webhook_url": "https://your-receiver.example/hook" },
    "cooldown_minutes": 60
  }'

For Slack, create an incoming webhook in Slack, then use the same call with "channel": "slack" and "channel_config": { "webhook_url": "https://hooks.slack.com/services/..." }.

# stat_name       the stat's NAME (not its id); the stat must already exist
# condition_type  above | below | pct_change | heartbeat | missing_data | sustained
# threshold       the line the value must CROSS (comparisons are strict)
# window_minutes  1-43200; required for heartbeat / missing_data, guides the pct_change lookback
# cooldown_minutes  1-1440, default 15; suppresses repeat FIRES only
# consecutive_required  1-20, default 1; N consecutive breaching checks before it fires
# resolve_threshold  optional; a slacker line the value must clear to resolve
# channel         webhook | slack | email (email requires a confirmed double opt-in)
# channel_config  webhook_url (required, absolute https://) and slack_channel (optional)

The stat has to exist before the alert: a create for a name you have never sent returns 404. Manage alerts with GET /api/v1/alerts (list) and DELETE /api/v1/alerts/:id (delete). An agent can do the same with create_alert on the MCP server, which works on every plan within that plan's limits — creating an alert still needs a plan that includes alerts.

Conditions you can use

  • above / below: the latest value in the window's rollup crosses the threshold. It compares that latest value, not a sum or an average, and the check is strict: above 1000 fires at 1000.01, not at 1000. For a failure counter, send 0 after a good run so the alert can recover.
  • pct_change: the latest point has moved by more than a percentage from the start of the lookback. To alert when a counter spikes, send one total per interval (for example {"count": 37} each minute) and use this or above on that total. Each check reads the latest total, so use a longer interval if your spikes are short. A negative threshold watches for a drop.
  • sustained: the value is above the threshold for N consecutive checks (1 to 20, set with consecutive_required), so one noisy point does not wake you.
  • heartbeat / missing_data: no data has arrived for longer than window_minutes (required for these two). This tells you a stat stopped arriving. It is not schedule-aware, so it does not know your cron timetable.

above and below are allowed on any plan that has alerts at all. pct_change, sustained, heartbeat and missing_data are an integrations-tier capability, so they need Indie or higher. There is no anomaly alert condition; anomaly detection is a separate dashboard feature, not an alert type.

Channels, and what each one needs

The create API has three channels: email, webhook and slack. Here is what each one needs:

  • webhook and slack both need channel_config.webhook_url, an absolute https:// URL; slack_channel is optional and is a note for the human reading the alert. Both are an integrations-tier capability: on a plan without integrations the create is refused with 403 and the message points you at /pricing.
  • email works on any plan that includes alerts and takes no channel_config: it goes to the account's own verified address. The address must have confirmed the double opt-in: until it has, creating the alert is refused (409) and the message names the fix.

Webhook targets must be HTTPS, and private or internal URLs are refused: the send-time guard resolves the host, rejects private, link-local and metadata ranges, and pins the address it connected to.

What arrives at your webhook

Each webhook delivery is a JSON POST with the fields below. Slack gets the same alert as a message, {"text": "…"}.

{
  "alert_id": "…",
  "event": "fired",
  "status": "firing",
  "stat_name": "backup_failures",
  "observed_value": 1,
  "condition": "above",
  "threshold": 0,
  "triggered_at": "2026-08-14T02:00:00Z",
  "message": "…",
  "idempotency_key": "…",
  "incident_key": "…"
}

# event            "fired" | "resolved"  — what just happened
# status           "firing" | "resolved" — the state the alert is now IN
# idempotency_key  same key on every re-send of ONE delivery
# incident_key     SAME on the fire and on its resolve — correlate on this
# also sent as headers: X-EzStat-Idempotency-Key, X-EzStat-Incident-Key

The behaviour is built to avoid alert noise:

  • It fires once per breach, not once per data point, and sends a matching resolved delivery when an observed value comes back on the safe side of the line. Both share an incident_key, so your receiver can close what it opened. A stat that merely stops arriving is not evidence of recovery: the alert holds its state instead of sending a false “recovered”.
  • The cooldown only suppresses repeat fires. It never withholds a resolve. A breach whose re-fire was suppressed notified nobody, so its recovery is silent too.
  • Retries are safe. Deliveries are retried with backoff, and each webhook delivery carries a stable idempotency_key so you can drop duplicates.
  • Deleting an alert is a hard stop: queued deliveries are dropped and no final resolve is sent, because the condition was not observed to clear.

Expect minutes, not seconds. Alerts are not evaluated on the ingest path: a periodic worker checks your alerts against precomputed rollups and then drains the delivery queue, so there is a gap between the breaching point and the delivery — measured at roughly six minutes end to end, and longer if a breach arrives just after a rollup pass. That is right for trend and threshold monitoring, not for paging a human within seconds.

At your plan limit

What happens at your limit: Your plan's monthly datapoint allowance is spread across the month as a limit that resets daily. At the limit, new datapoints are refused until the reset, and the response says “datapoint limit reached”. There are no overage charges and no automatic upgrade. A request that would add a new stat name past your plan's stat count is refused as a whole; as long as you are within that count, writes to stats you already track keep recording. Reaching either limit deletes or hides nothing already stored; your dashboard and the read API keep working.

What it costs

PlanPriceAlertsStatsDatapoints / monthRetention
Free$0, no cardCharts, Ask and MCP; alerts start on Indie10300,00030-day
Indie$19 / monthThreshold and advanced conditions, to a webhook or Slack; Smart Alerts10,0004,500,00030-day
Pro$49 / monthEverything in Indie10,00022,500,0001-year
Scale$99 / monthEverything in Pro10,000150,000,0003-year

Prices are monthly, in USD, excl. tax where applicable. Suggested thresholds (Smart Alerts) need the Indie plan or higher. Each plan also caps how many alerts you can hold; the cap is enforced when you create one and the refusal names your current count. Full comparison: pricing.

Do you need Datadog for simple threshold alerts?

No. If what you need is “tell Slack when this number crosses that line”, a full observability platform is more than the job requires: agents to install and dashboards to build. EzStat does counters and values, charts, export and alerts over plain HTTPS.

This is a question of fit, not of price. EzStat is not a log store, a tracing tool or an APM, and Datadog is genuinely broader — if you need those, it is the right buy. Our own prices are facts on /pricing; the side-by-side for custom metrics is on the Datadog alternative page.

FAQ

How do I get a Slack message when a metric crosses a threshold?
Send the metric to EzStat with one POST (for example POST https://api.ezstat.dev/api/v1/stats/queue_depth/value with {"value": 120}), then create an alert on that stat with condition_type above and channel slack. EzStat posts once when the value crosses the threshold and again when it recovers. Alerts need a plan that includes them: the Indie plan ($19 a month) or higher.
How do I send an alert from a shell script with curl?
Have the script send the number, not the alert: curl -X POST https://api.ezstat.dev/api/v1/stats/backup_failures/count -H "Authorization: Bearer $EZSTAT_API_KEY" -H "Content-Type: application/json" -d '{"count": 1}'. An alert you set once on backup_failures (for example above 0) makes EzStat deliver to your webhook or Slack.
Do I need Datadog for simple threshold alerts?
No. For "notify me when this number crosses a line", a metrics API with threshold alerts is enough. EzStat takes one HTTPS POST per data point and delivers threshold alerts to a webhook or Slack, with no agent to install. It is not a log store, tracing tool or APM — if you need those, a broader platform is the right buy.
How do I alert when a counter spikes?
Send one total per interval, for example {"count": 37} each minute, and set the alert on that stat. Use above to fire when the latest total is over your threshold, or pct_change to fire when the latest total has grown by more than your percentage. Each check reads the latest total, so use a longer interval if your spikes are short.
Can I get alerts on the free plan, or by email?
Alerts start on Indie; the free plan includes charts, Ask and MCP. Email is one of the three alert channels and works on any plan that includes alerts. An email alert goes to the account's own address, which must have confirmed the double opt-in — until then creating the alert is refused and the message names the fix.
Can EzStat alert me when a metric stops arriving?
Yes, on a plan with integrations. Use a heartbeat or missing_data alert with a window_minutes window: it fires when no data has arrived for longer than that window. It is not schedule-aware, so it does not know your cron timetable, and checks run periodically rather than on the ingest path.
How fast does an alert fire, and how many alerts can I create?
Alerts are not evaluated as each point arrives: a periodic worker checks your alerts against precomputed rollups and then drains the delivery queue, measured at roughly six minutes end to end. Each plan caps how many alerts you can hold; the cap is enforced when you create an alert and the refusal names your current count.

Start with one number

Pick the one number you would want a Slack ping about, send it from your script, and add one alert. The API docs cover every endpoint, the metrics API page covers sending metrics from anywhere, and pricing has the plans. Running a StatsD setup today? See the hosted StatsD-style alternative.