// WHAT DID THE JOB DO

Track cron job metrics with one HTTP POST

A heartbeat tells you the job ran. Metrics tell you what it did: how many items it processed, how many times it failed, and how long it took. Add one small wrapper and EzStat charts all three — no agent, no exporter, no Prometheus or Grafana to run.

Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Paid plans are $19, $49 or $99 a month, and every paid plan tracks 10,000 stats. Prices are flat and monthly, in USD, + tax where applicable. /pricing is the source of truth.

Heartbeats versus metrics

A job monitor answers

  • Did it run on schedule?
  • Was it late or missed?
  • Did the ping arrive?

EzStat answers

  • How many items did it process?
  • How long did it take?
  • How often did it fail?

They are different jobs, and you can run both.

A wrapper that records success, failure and duration

Your API key works at once, with one stat and 500 datapoints a day until you confirm your email address; confirm within 7 days to keep sending. The wrapper writes more than one stat, so confirm before you schedule it.

#!/usr/bin/env bash
# /usr/local/bin/nightly-report-metered.sh
# Runs the job, then records one success-or-failure count and the duration in seconds.
set -u

# Load EZSTAT_API_KEY from a file only the job's user can read (chmod 600), not from the crontab.
. /etc/ezstat.env

API="https://api.ezstat.dev/api/v1/stats"
JOB="nightly_report"

record() {  # record <stat> <count|value> <json body>
  curl -fsS -m 10 -X POST "$API/$1/$2" \
    -H "Authorization: Bearer $EZSTAT_API_KEY" \
    -H "Content-Type: application/json" \
    -d "$3" >/dev/null || echo "ezstat: could not record $1" >&2
}

start=$(date +%s)
/usr/local/bin/nightly-report   # your real job
rc=$?
elapsed=$(( $(date +%s) - start ))

if [ "$rc" -eq 0 ]; then
  record "${JOB}_success" count '{"count": 1}'
else
  record "${JOB}_failure" count '{"count": 1}'
fi
record "${JOB}_seconds" value "{\"value\": $elapsed}"

exit "$rc"   # keep cron's own failure handling intact

Then point cron at the wrapper, not at the job:

15 2 * * * /usr/local/bin/nightly-report-metered.sh

/etc/ezstat.env holds one line, EZSTAT_API_KEY=your-key-here, readable only by the user that runs the job. Never put a real key in a crontab line or in a script.

Counters versus gauges

Success and failure are counters; duration is a gauge. They stay separate stats because a stat is one kind or the other. This wrapper uses three stats per job, and the free plan allows 10 stats.

The metric never breaks the job

The call has a ten-second timeout, its failure is logged and ignored, and the wrapper exits with the job's own exit code — so cron still sees a failed job as failed. A timeout leaves the outcome unknown, so retry only with the same explicit timestamp and ikey on every attempt; see the curl page for that form.

What you see, and when you get pinged

One chart per stat, created by the first write. A rising failure count is a job that keeps failing; a rising duration is a job that is slowing down. Export to CSV or JSON any time.

A job that never ran sends nothing at all, so there is no data and no gap to see: EzStat does not detect a missed run on its own. Catching one takes an alert you set yourself on the stat.

Alerts on paid plans, by webhook or Slack, checked periodically — not instant. The two conditions that watch for absence are heartbeat and missing_data: each fires when no data has arrived for longer than the window you set on the alert. They are not schedule-aware — they do not know your cron expression — so a job that was never scheduled to run tonight looks the same as one that silently died. Both need a plan with alerts, which every paid plan has.

The same call elsewhere

A systemd timer runs the same wrapper:

# a systemd timer runs the same wrapper; nothing else changes
[Service]
ExecStart=/usr/local/bin/nightly-report-metered.sh

In CI, the same two calls become one step: /github-actions-metrics. From a script in another language: Python, Node.js, Go. If an agent runs the job, it can record the same numbers through MCP: /ai-agent-metrics. Weighing this against a full observability suite? /datadog-alternative compares the two honestly.

What it costs

Free: 10 stats, 300,000 datapoints a month, no card, open to the first 250 accounts. Ten stats cover about three jobs at three stats each. Paid plans are $19, $49 or $99 a month with every paid plan tracks 10,000 stats; the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale. See the full table.

When a job monitor is the better tool

If the fear is a silently missed schedule, use a job monitor: it knows when a run was due and can page you. EzStat is the right tool for the numbers the job produced, and the two sit side by side without overlap. Not the StatsD wire protocol either — see /statsd.

Questions

How do I track cron job metrics without Prometheus?

Add one HTTPS POST to the end of the script. With EzStat, a curl to https://api.ezstat.dev/api/v1/stats/{name}/count records a success or a failure, and a curl to /value records the duration in seconds; the stats are created on the first call and charted automatically. There is no agent or exporter to run. The free plan allows 10 stats.

Can I chart how long a cron job takes?

Yes. Record the start time, run the job, then POST the elapsed seconds as a value to a stat such as nightly_report_seconds. EzStat draws the series, and the history you can see and export is 30 days on Free and Indie, 1 year on Pro, 3 years on Scale. Send the success and failure counts as separate counter stats, because each stat is either a counter or a gauge.

Is EzStat a cron job monitor?

No. Job monitors watch the schedule and tell you when a run is late or missed. EzStat charts what a job did: counts, durations and values. It does not know your cron expression, and alerts are checked periodically rather than instantly. You can run a job monitor and a metrics tool together.

Does EzStat tell me when a cron job did not run?

No, not on its own. A job that never ran sends nothing, so there is no data and no gap to see: EzStat does not detect a missed run. The only way to catch one is an alert you set yourself on the stat: a heartbeat or missing_data alert fires when no data has arrived for longer than the window you set on it. Both watch the stat rather than your cron expression, so a run that was never scheduled looks the same as one that silently died, and both need a plan with alerts, which every paid plan has.

Will a failed metric call break my cron job?

Not if you handle it. Put a timeout on the call, ignore its failure, and exit with the job's own exit code, as the wrapper on this page does. A timeout leaves the outcome unknown, so a retry without a fixed timestamp and idempotency key can count twice.

How many stats does a cron job use?

The wrapper on this page uses three: a success counter, a failure counter and a duration gauge — the free plan allows 10 stats, so it covers about three jobs; every paid plan allows 10,000 stats.