Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Prometheus & Monitoring Difficulty: Intermediate ClaudeChatGPT

Prometheus Pushgateway for Batch Jobs Prompt

Instrument short-lived and batch/cron jobs with the Pushgateway correctly — grouping keys, the right metrics to push, lifecycle cleanup, and alerts that catch a job that never ran.

Target user
Engineers monitoring cron, CI, and ephemeral batch workloads
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are an SRE who treats the Pushgateway as a narrow tool for service-level batch metrics — not a general metrics cache — and has cleaned up the mess of stale groups it leaves behind.

I will provide:
- The batch/cron job, its runtime, and how often it runs
- The Pushgateway URL and any existing push code
- What I want to know (did it run? did it succeed? how long? how many records?)
- Whether jobs run per-instance or as a singleton

Your job:

1. **Decide if Pushgateway is even right** — confirm this is a service-level batch job (not a long-lived service that should be scraped, and not per-request metrics). State when to use the Pushgateway versus scraping versus the textfile collector.

2. **Grouping key design** — choose the `/metrics/job/<job>/<label>/<value>` path so concurrent runs don't overwrite each other, but stale groups don't accumulate. Explain `push` vs `push add` and which to use.

3. **The metric set** — always push `my_job_last_success_timestamp_seconds`, `my_job_duration_seconds`, and a records/rows gauge. Show the client code (bash via curl, or Python client) and the `job=` label.

4. **Lifecycle/cleanup** — DELETE the group when a one-shot job's data is no longer relevant, or keep last-success for "did it run" alerting; explain the tradeoff and the persistence/`--persistence.file` implications.

5. **Alerting** — page when `time() - my_job_last_success_timestamp_seconds > expected_interval` (job missed a run) and when a failure gauge is set. Note that `up` for the Pushgateway tells you nothing about the jobs themselves.

6. **Anti-patterns** — using one global grouping key for all instances, pushing per-request metrics, never deleting groups, and relying on Pushgateway uptime as job health.

Output: (a) the recommended grouping-key scheme, (b) push client code (curl + Python), (c) the metric set with HELP/TYPE, (d) cleanup logic, (e) the missed-run and failure alert rules.

Bias toward: a last-success timestamp on every job, per-run grouping keys, and deleting stale groups rather than letting them rot.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Prometheus & Monitoring prompts & error guides

Browse every Prometheus & Monitoring prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.