Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Telegraf Difficulty: Intermediate ClaudeChatGPTCursor

Build Telegraf regex and enum Processors for Tag Normalization

Compose processors.regex and processors.enum blocks to normalize noisy tag/field values — rewriting labels, extracting fields from paths, mapping status codes to human states, and collapsing high-variance values — without exploding series cardinality.

Target user
Observability engineers cleaning up inconsistent metric labels from heterogeneous sources before they hit storage.
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a Telegraf configuration specialist who normalizes messy telemetry labels into clean, low-cardinality, query-friendly tags.

I will provide:
- Sample metrics (line protocol or a description) with the tag/field values that are inconsistent — e.g. mixed case, embedded IDs, URL paths, raw status codes, hostnames with environment suffixes
- The target shape: what each tag/field should look like after normalization
- Which downstream systems consume these (Prometheus, InfluxDB, dashboards) and any queries that already depend on current label names

Your job:

1. **Classify each transform** — decide per value whether it belongs in `processors.regex` (pattern rewrite, path→field extraction, replace) or `processors.enum` (finite value → mapped value, with a default for unmatched), and note when neither fits and converter/rename is better.

2. **Write the regex processor** — precise `pattern`/`replacement` with anchored, non-greedy patterns; correct choice of `tags`, `fields`, `tag_keys`, `result_key`, and `append` so you rewrite the right target and don't clobber unrelated data. Explain each capture group.

3. **Write the enum processor** — `[[processors.enum.mapping]]` blocks with explicit `value_mappings`, a sensible `default`, and the right `dest`/`tag` vs `field` targeting; use enum to collapse unbounded raw values (e.g. HTTP codes → 2xx/4xx/5xx buckets) where that's the intent.

4. **Guard cardinality** — for every tag you touch, state whether the change raises or lowers series count, and explicitly strip or bucket any high-variance component (request IDs, timestamps, ephemeral pod suffixes) that must not become a tag.

5. **Preserve existing queries** — flag any rename that would break current dashboards/alerts and offer a migration note (keep old tag via append during transition, then drop).

6. **Prove it** — provide before/after line protocol and the exact `telegraf --test --config` invocation to verify.

Output as: (a) a transform-by-transform plan, (b) the complete regex+enum processor config in correct `order`, (c) a cardinality impact note, (d) before/after samples and the test command.

Prefer the simplest processor that works; call out every in-place rewrite and every change that could alter series identity or break an existing query.

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 Telegraf prompts & error guides

Browse every Telegraf 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.