Telegraf HTTP JSON Input Design Prompt
Poll REST/JSON HTTP endpoints with inputs.http and parse the response with json_v2 — mapping nested fields, arrays, and objects into well-tagged metrics with correct auth, timeouts, and failure handling.
- Target user
- Engineers scraping app/vendor JSON APIs into metrics with Telegraf
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who routinely turns arbitrary JSON APIs into clean metrics with Telegraf's `inputs.http` + `json_v2` parser, including gnarly nested and array-heavy payloads. Help me map one.
I will provide:
- The endpoint URL(s), method, and required headers/auth
- A sample JSON response (possibly nested with arrays of objects)
- Which values are metrics, which identify the series, and the units/timestamps involved
Deliver:
1. **Request config** — `urls`, `method`, `headers`, auth (bearer/basic) sourced from `${ENV}`/secretstore, `timeout`, and `interval`. Include `success_status_codes` and how non-200 responses are handled.
2. **json_v2 mapping** — the `[[inputs.http.json_v2]]` blocks: `measurement_name`, `[[...json_v2.field]]`/`object` with GJSON `path`s for nested keys and arrays, `timestamp_path`/`timestamp_format` if the payload carries its own time.
3. **Tags vs fields** — which paths become `tags` (region, service, node) via `object.tags` and which become numeric fields; flag any array whose length is unbounded so it doesn't explode series.
4. **Type handling** — coercing string-encoded numbers, booleans, and enums; and `object.disable_prepend_keys`/renaming to keep field names sane.
5. **Multiple endpoints & pagination** — whether to use multiple `urls`, several `[[inputs.http]]` blocks, or note where pagination means this plugin isn't the right tool.
6. **Resilience** — behavior on timeouts, retries, and partial JSON, plus how to avoid alert flaps when the API blips.
Output: (a) a commented `inputs.http` + `json_v2` TOML block, (b) the path→tag/field mapping table, (c) a cardinality warning per array/tag, and (d) a `telegraf --test` command to validate against the sample payload.
Bias toward: secret injection, bounded arrays/tags, parsing the payload's own timestamp, and explicit non-200 handling.
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
-
Choose and Design the Right Telegraf Input Plugin for a Source
Pick the best Telegraf input plugin for a given data source (an app, host, API, log, queue, or device) and produce a production-ready inputs configuration with the right tags, fields, interval, and parser — instead of guessing between exec, http, prometheus, and a native plugin.
-
Telegraf Docker Input Metrics Collection Prompt
Configure inputs.docker to collect per-container CPU, memory, network, and blkio metrics with the right label mapping, container filtering, and socket permissions — without drowning your TSDB in ephemeral-container cardinality.
-
Telegraf Exec & Execd Custom Input Prompt
Build custom metric collectors with inputs.exec (run a script per interval) and inputs.execd (long-running streaming process) — choosing the right one, picking a data_format, and handling stdout/stderr, exit codes, and timeouts safely.
-
Telegraf IPMI Hardware Metrics Prompt
Collect bare-metal health with inputs.ipmi_sensor — temperatures, fan speeds, voltages, PSU and chassis status from BMCs over local or LAN interfaces — with safe credentials, sane intervals, and tag mapping for fleet dashboards.
More Telegraf prompts & error guides
Browse every Telegraf prompt and troubleshooting guide in one place.
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.