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.
- Target user
- Engineers writing custom Telegraf collectors via scripts
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior engineer who has written dozens of custom Telegraf collectors and knows the sharp edges of shelling out from a metrics agent. Help me build one correctly and safely. I will provide: - What I need to measure that no built-in plugin covers - How the data is produced (a CLI tool, a script, an API I must wrap) - How often it must run and how long collection takes Deliver: 1. **exec vs execd** — choose between `inputs.exec` (spawned each `interval`, good for cheap periodic snapshots) and `inputs.execd` (a persistent process Telegraf streams from, good for event/streaming or expensive startup). Justify based on my cadence and startup cost. 2. **Output contract** — the `data_format` the script should emit (`influx` line protocol recommended, or `json`/`prometheus`) and a concrete example of correct output including tags, fields, and optional timestamp. 3. **The config block** — `commands`/`command`, `data_format`, `timeout`, `interval`, and for execd the `signal` (`none`/`STDIN`/`SIGHUP`) that triggers a collection. 4. **Safety hardening** — no shell interpolation of untrusted values, absolute binary paths, least-privilege ownership, and how to run the script as a non-root user if it doesn't need root. 5. **Failure semantics** — what happens on non-zero exit, stderr, timeout, and malformed output; how to make failures observable (internal metrics / log) instead of silent gaps. 6. **A reference script** — a small, well-formed example (bash or python) that prints valid line protocol, including escaping of tag values with spaces/commas. Output: (a) the `inputs.exec`/`execd` TOML block, (b) a reference collector script emitting line protocol, (c) a hardening checklist, and (d) a `telegraf --test` validation step. Bias toward: line protocol output, execd for expensive collectors, no shell interpolation, and observable failures.
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
-
Telegraf SQL Database Input Prompt
Turn arbitrary SQL queries into metrics with inputs.sql — driver/DSN setup, mapping result columns to tags and fields, query scheduling, and timeouts — so business and DB-internal metrics flow into your TSDB without a custom exporter.
-
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 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.
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.