BXUP Track progress & test yourself — free
DevOps / SRE / Platform · Playbook · Core · ~6 min read
DEVOPS / SRE / PLATFORM · PLAYBOOK · CORE

Telemetry Quality with AI: Log Parsing Rules and OTel Instrumentation

Every AI-SRE capability in this track — triage, investigation, anomaly detection — is bounded by telemetry quality: an AI investigator cannot cite a span that was never emitted, and anomaly detection over unparsed log soup detects nothing.

Tier: Core · Hands-on time: ~75 minutes

This playbook covers the two AI-assisted workflows that raise that floor, both classic tedious-but-verifiable tasks: (1) generating log parsing rules (grok/VRL/ingest pipelines) from sample logs, proven correct by unit tests; (2) generating OpenTelemetry instrumentation that follows semantic conventions, proven correct in a local collector before it ships. In both, the AI writes the tedious artifact and a deterministic harness — not your judgment — verifies it.

When to use

  • A service's logs land as unparsed strings and you need structured fields for querying (pb-22) and alerting (pb-25).
  • Instrumenting a service (or fixing non-semconv instrumentation) so traces/metrics are usable by dashboards (pb-24) and AI investigators (pb-15).
  • Migrating pipelines (Logstash→Vector, homegrown tracing→OTel) where hundreds of small rules need faithful translation.

Skip AI for a single trivial pattern you can write faster than you can prompt — the leverage is in volume, gnarly formats (multiline stack traces, mixed formats on one stream), and convention compliance.

Prerequisites

  • Logs path: 30–100 representative raw log lines per format, including the ugly ones (multiline tracebacks, truncated lines, mixed JSON-and-text); Vector (vector CLI with its native unit-test support — the lab default), Logstash, or an Elastic/Loki ingest pipeline.
  • OTel path: a service you can edit and run locally; OTel SDK for its language; a local collector + Jaeger (docker compose, 5 minutes); the OTel semantic-conventions reference for your domain (HTTP, DB, messaging).
  • Assistant: any capable code assistant (Claude Code/Copilot) or LLM chat.

The workflow

  1. Logs — generate rules AND tests together. Paste the samples:

    Here are 40 raw log lines from service X (note: lines 12-19 are one
    multiline Java stack trace; lines 30+ switch to JSON).
    Write a Vector VRL transform that parses every line into: timestamp
    (RFC3339), level, service, trace_id (nullable), message, plus
    error.class/error.stack for tracebacks. Unparseable lines must route to
    a `parse_failure` output with the raw line preserved — never drop.
    Also write Vector unit tests covering: one normal line of each format,
    the multiline trace, a truncated line, and one line NOT in the samples
    that your rule should reject.
    
  2. Run the harness; iterate on failures, not on vibes. vector test runs the generated tests deterministically. Feed failures back verbatim until green, then — the step that matters — audit the tests before trusting the green: do the expected-output assertions actually check field values (not just "parsing succeeded"), and does the reject case really represent unknown input? AI-generated tests can be sycophantic to AI-generated rules; the test review is your citation check here.

  3. Replay real traffic through the rule. Run a day's worth of raw logs through the transform offline; measure parse rate and inspect the parse_failure stream. Every failure is either a rule gap (iterate) or a genuinely malformed emitter (file a bug upstream — also a win). Ship via PR with the parse-rate number and the test file in the diff.

  4. OTel — instrument against the conventions, not the model's memory. Semconv attribute names are exactly the kind of detail models half-remember (http.status_code vs http.response.status_code changed with semconv stabilization). Paste the current convention tables for your domain into context:

    Instrument this Flask/Express/Go handler with OpenTelemetry using the
    attached semantic conventions VERBATIM. Spans for: inbound HTTP (server),
    the outbound payment call (client), and the DB query — with required
    attributes from the tables. Add span events for retry attempts. Do not
    invent attribute names: every attribute must appear in the attached
    conventions or be namespaced under `app.*` as custom.
    
  5. Verify in a local collector before merge. Run service + collector + Jaeger; exercise the endpoints; then check in Jaeger/collector debug output: spans present with correct kind and parentage, required attributes populated with real values, trace context propagating across the outbound call (one trace, not three orphans). Grep exported spans for attributes NOT in the conventions or app.* — that grep is your automated hallucinated-attribute detector; wire it into CI if you're doing this across a fleet. Merge with the Jaeger screenshot and the attribute-check output in the PR.

Key Takeaway:

Both halves share one design: the AI produces the artifact, a deterministic harness (unit tests, collector output) produces the evidence, and the human audits the harness — verify the verifier, then let it work for you.

Tool variants

  • Vector (lab default): VRL + vector test gives the tightest generate-test loop in the logs ecosystem; its remap errors are excellent feedback to paste back to the model.
  • Logstash/grok or Elastic ingest pipelines: same workflow; use the grok debugger or simulate API as the harness. Grok's regex dialect is well known to models, but backtracking-heavy generated patterns can be slow — load-test rules on a big file before shipping.
  • Loki/promtail pipelines: lighter parsing at scrape time; keep the parse_failure-preservation principle even when the tooling makes dropping easier.
  • OTel with Claude Code/Copilot in-repo: agentic assistants can run the collector loop themselves (edit → run → check Jaeger API) — let them iterate, but the semconv-verbatim rule and the final attribute grep remain yours.

Verification

  • Log rules: generated tests audited by a human for real assertions, vector test green, replay parse rate reported (target: >99% with all failures explained), zero silent drops — the parse_failure route is present and monitored.
  • OTel: every emitted attribute traced to a line in the attached semconv tables or an approved app.* namespace — this is the citation check, run as a grep over actual collector output, not over the source code the model wrote.
  • Trace-context propagation confirmed end-to-end in Jaeger (single trace ID across service boundaries) with a screenshot in the PR.
  • Downstream consumer check: one pb-22 query and one pb-24 dashboard panel run against the new telemetry and return sensible values — telemetry is only "quality" if the things that consume it work.

Pitfalls

  • Regex overfitting to the samples. Rules that parse your 40 samples and nothing else. The reject-case test and the full-day replay are the antidotes; parse rate on unseen traffic is the honest metric.
  • Stale semconv from model memory. Models trained on pre-stabilization OTel confidently emit deprecated attribute names, which silently break semconv-aware dashboards and vendor features. Always attach current conventions; never let the model recall them.
  • Cardinality bombs. Generated instrumentation loves putting user IDs and full URLs into attributes/labels. Review every attribute for cardinality before merge — your metrics bill and Prometheus memory are the blast radius.
  • Secrets structured into fields. A parsing rule that dutifully extracts password=... into a queryable field has industrialized a leak. Add redaction transforms in the same PR as parsing, and test them like any rule.

Restricted-environment variant

  • Raw logs are the most PII-dense artifact in this track. Under client MSAs: sample logs for prompting must pass a scripted redaction (emails, tokens, IDs → placeholders) first, or run the whole loop with a local model — rule generation from samples is well within local-model capability, and the harness (vector test, collector) is identical regardless of which model wrote the rule.
  • The verification harnesses run entirely inside the boundary: vector test, replay, and the local collector need no egress — in restricted shops, lean even harder on harness evidence precisely because model choice is constrained.
  • OTel semconv references are public; attaching them to a local model closes most of the quality gap with frontier hosted models for this task.
Warning

Telemetry pipelines are production infrastructure — a bad transform deployed fleet-wide can blind you during the next incident. Parse rules ship through the same PR-plus-replay-evidence gate as alert rules (pb-25), no exceptions for "just a parsing tweak."

Success criteria

  • A previously unparsed log stream is structured, with committed unit tests, >99% replayed parse rate, monitored parse_failure route, and redaction in place — done in under half a day.
  • A service emits semconv-correct traces verified in a local collector, with the attribute-grep check automated for the next service.
  • One pb-22 query and one pb-24 panel now work against telemetry that didn't exist last week — show them.
  • The instrumentation-gap list (MISSING panels from pb-24, parse failures from replay) is shrinking release over release, and your AI incident tooling (pb-14/pb-15) visibly cites the new telemetry.
This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in