AIOps: AI for IT Operations · Module 02
Telemetry for AI
Getting operational data into a shape models can use: pulling metrics, logs and traces into Python, turning logs into templates, joining signals, and checking quality and privacy before anything reaches a model.
Học xong bạn làm được
- Pull metrics, logs and traces into pandas or DuckDB through the Prometheus, Loki and Tempo APIs
- Turn raw logs into templates with Drain and spot new templates after a deploy
- Join signals by service, trace id and time window
- Check telemetry quality and redact PII and secrets before training or prompting
Bài học
- Pulling telemetry into Python
Prometheus, Loki and Tempo each have an HTTP API that returns JSON - query_range for metric series, query_range for log lines, search and trace-by-id for traces. A few lines of Python turn each answer into a pandas DataFrame, DuckDB queries the frames with SQL, and a Parquet snapshot freezes an incident's data so models and evaluations can be rerun on exactly the same input.
- Log templates with Drain
Most log lines are a fixed message with a few changing values. Structured logs keep the values in fields; for the rest, Drain (the Drain3 library) learns templates online by replacing variable tokens with <*>. Counting lines per template turns a flood of text into a small table, and a template that appears for the first time after a deploy is one of the strongest signals in an incident.
- Joining signals
Signals are joined on four keys - resource attributes (service.name and friends, the same on every signal from one service), the trace id (in spans and, through the SDK, in logs), exemplars (a trace id attached to a metric sample) and time windows (for everything else, such as a deploy before a spike). Each join answers a question no single signal can.
- Quality and privacy of telemetry
Before telemetry reaches a model, check four quality problems - gaps (missing samples look like zeros or flat lines), cardinality (labels with too many values), clock skew (timestamps that disagree across sources) and sampling bias (traces kept are not a fair sample) - and redact PII and secrets, because whatever goes into a prompt or a training set may come back out.