Log anomaly detection finds log behavior that differs from an explicit baseline: a new error event, an unusual change in event rate, or an unexpected sequence of otherwise familiar events. An anomaly is a lead for investigation, not a diagnosis or proof that users are affected. The detector must explain what changed, for which service and time window, and whether the log pipeline was complete enough to trust the comparison.
Start with one operational question, such as “Did the checkout service begin failing more requests after this release?” A simple rule may answer it better than a model. Use more complex methods only when they detect a useful pattern that rules and service metrics miss. The broader AI log analysis guide covers retrieval and AI-assisted interpretation; this guide focuses on the detection decision itself.
Choose the anomaly you need to detect
Different log anomalies require different units of analysis. Treating every unusual line as the same problem makes alert quality hard to evaluate.
- Rare event: A previously unseen event name, error code, or field value appears. It may indicate a new failure, but it may also be a normal release, a changed parser, or a first occurrence in a low-traffic service.
- Rate or distribution shift: The number or share of
dependency_timeoutevents changes relative to the same service's eligible traffic. A count can rise only because traffic rose, so compare a numerator with a denominator from the same observation boundary when possible. - Sequence or missing step: A job emits
startedandcheckpoint_writtenbut no expectedcompletedevent before its deadline. This could mean a stuck job, a delayed event, or a collection gap. Ordering by arrival time alone can be misleading.
These are not interchangeable. A frequency detector can miss a one-off security event. A rare-event detector can flag every new deployment. A sequence detector needs a stable unit such as a job or request ID and a documented expectation about which events should occur. Research on log-based anomaly detection shows that grouping, noisy data, class distribution, and evaluation setup materially affect results; a high score on one public dataset is not a production guarantee.
Make the input trustworthy before learning a baseline
Define a small event contract at the source: event time, service and environment, release or version, stable event name, outcome, and a bounded operation or job ID when needed. Preserve the original message as evidence. OpenTelemetry's Logs Data Model distinguishes Timestamp—when the event occurred—from ObservedTimestamp—when the collection system saw it. This distinction matters when a collector buffers records or hosts have skewed clocks.
Text parsing should separate the stable event shape from variable values. For example, payment request 8f2 failed and payment request 91b failed may share one event template rather than form two new event classes. An online parser such as Drain is one researched approach, not a requirement for all pipelines. A producer-defined event name is often simpler when application code is under your control. Version the parser or schema, and inspect unknown events after a release instead of assuming they are incidents.
Before any rate, rarity, or absence calculation, check completeness. Track source-side emission where possible, collector accepted and dropped records, queue depth, export errors, and arrival delay. The OpenTelemetry Collector resiliency guidance documents queues, retries, and their limits; buffering does not promise zero loss or exact ordering. A sudden fall in completed events could be a real service failure—or an unavailable exporter. Suppress neither explanation until the collection path is checked.
Keep records safe for analysis. Remove tokens, passwords, session values, and unnecessary personal data before broad collection; sanitize untrusted text against log injection. Limit who can inspect raw rows and how long they remain stored. Do not make a model's input richer by copying full requests, headers, or private messages into logs. OWASP's logging guidance treats data exclusion, access, and log integrity as part of the design.
Build a baseline for comparable behavior
A baseline is the reference behavior against which a detector judges new observations. It should be scoped narrowly enough to mean something: service, environment, operation, release family, and region when those factors change behavior. Compare a weekday batch with comparable weekdays if the schedule drives volume. Compare a quiet service with its own history, not a high-traffic sibling. Do not split into so many tiny cohorts that each has too little data to estimate anything.
Choose an observation window that matches the event's natural pace. A request error rate can move within minutes; a daily batch has one expected completion per run. State how late data is handled and when a window is final. Retained counts from a sampled or filtered stream are not the original source counts unless the sampling or filtering design supports that inference. Record the baseline's version and training period so a release or schema change does not quietly rewrite what “normal” means.
Do not train indiscriminately on every recent window. If an outage enters the reference set, a persistent fault can become the new normal. New services and changed releases need a cold-start rule: use an explicit known-failure rule, a broader but qualified peer baseline, or human review until enough representative data exists. No fixed history length or threshold works for every service. The detector should be allowed to say insufficient data.
An illustrative job sequence shows why these checks matter:
14:02:00 export_started job_id=demo-42 service=ledger-export
14:02:18 checkpoint_written job_id=demo-42 service=ledger-export
14:07:00 expected completion deadline passes
The candidate anomaly is the missing export_completed event for demo-42. Before paging, verify that the job was eligible to finish by that deadline, check its actual process or output state, and inspect collector freshness and drops. If a completion event arrives late with an earlier event timestamp, the investigation changes. The example is synthetic; it does not imply that one missing log line proves data loss.
Compare rules, statistics, and template-based models
Rules are best for known, high-value conditions: a terminal failure event, a required job completion missing after a deadline, or a forbidden state transition. They are explainable and testable, but miss novel failure shapes and need updating when applications change. Start here when a clear failure contract exists.
Statistical detectors compare counts, rates, or field distributions with a baseline. They can surface a shift without a prewritten error string. They need denominator quality, seasonal context, minimum sample size, and a plan for zeros and missing data. A rate shift is not automatically user impact; an external check or service metric should corroborate a page. Avoid treating a model score as a universal severity level.
Template or sequence models parse text into event types and look for unfamiliar combinations or ordering. They can find a broken workflow that produces only familiar lines. Their cost is schema dependence, parser drift, grouping decisions, and lower explainability. The original Drain paper demonstrates log-template extraction; a later evaluation of deep-learning log detectors found that performance depends strongly on data grouping, noise, and evaluation choices. Use a model only after a simpler baseline has been measured on the same incident set.
An LLM can help summarize candidate events or suggest hypotheses, but generated explanations are not the detector's ground truth. Do not ask it to infer a root cause from a few retrieved rows or to execute a mitigation based on an anomaly score. Keep the raw events, query, baseline version, and score inputs available to the responder.
Validate against incidents and false alarms
Offline accuracy is not enough. Build a review set from known incidents, benign releases, traffic shifts, collection outages, and ordinary low-volume periods. Split by time so training data precedes the evaluated interval; avoid leaking near-duplicate events or a single incident's later rows into both sides. Include cases where the correct output is “unknown because the input is incomplete.”
Measure at least four things:
- Useful detections: Which real incidents or meaningful faults were found, and how early relative to the existing alert path?
- False alerts: Which candidates were benign releases, parser changes, sparse-data artifacts, or collection failures?
- Missed incidents: Which known failures did the detector not surface, including rare failures and silent outages?
- Responder cost: How many distinct investigations and pages did the detector create, and could each be explained from its evidence?
Report these by service, failure class, and severity rather than one blended percentage. Check both precision—the share of raised candidates that matter—and recall—the share of relevant incidents found. Class balance matters: in a mostly normal stream, high accuracy can coexist with poor incident detection. Google's SLO alerting workbook similarly treats detection time, precision, and recall as separate alert qualities, with special caution for low-traffic services.
First run a detector in review-only mode. Record its candidate score, baseline, supporting event IDs, and the responder's disposition without paging. Then compare it with existing user-impact alerts and known missed incidents. Promote only a condition with a named owner, an actionable response, a bounded evidence link, and a rule for missing input. Recheck after parser changes, deployment patterns, and collector changes. A quiet detector is not proof of safety if the collection path or model itself has stopped producing output.
Respond to a candidate without assuming its cause
When a candidate appears, confirm the source and time window, inspect the original rows, check collector health, and compare the pattern with service-level metrics or an external check. Look for recent releases and other affected services. Separate observed deviation, hypothesis, and verified user effect in the incident record. A new event may be a legitimate feature; an old event at a new rate may be the first sign of a real incident.
Page only when the evidence and impact warrant timely human action. Otherwise route the candidate to a review queue or dashboard with an owner. Do not automatically mute the candidate because it appeared during a deployment; the deployment may be the cause. Do not automatically restart a workload or change access controls from an anomaly score. Google's monitoring guidance favors simple, actionable pages and distinguishes symptoms from possible causes.
Fluxtail is a paid Starter/Pro, logs-focused service, not a native anomaly-detection model, ML training system, paging platform, or automated remediation engine. If a supported source delivers the relevant events, its search and filters and Live Tail can help inspect retained rows by time, stream, message, service, severity, and mapped fields. A detector running elsewhere can link an operator to the corresponding evidence; the detector still owns its baseline and alert decision.
Fluxtail's hosted MCP gives an authorized agent account-bound OAuth/PKCE access to read logs, histograms, and facets. It can help retrieve bounded evidence for a candidate, but an agent summary must be checked against raw rows. Its stream and receiver changes require a proposal and short-lived confirmation; those tools do not change production services or turn Fluxtail into an anomaly engine. If no rows match, check active filters and delivery before concluding the event never occurred. For general collection and investigation practice, see log management best practices.