RousselTMLEARNING

Observability

Machine learning in Elastic: anomaly detection and AIOps

Automatically detect abnormal behaviour: anomaly detection jobs, datafeeds, detectors, influencers, alerts, forecasts, log analysis (AIOps) and data frame analytics.

1. Machine learning features #

Overview.

What Elastic offers #

FeatureQuestionExample
Anomaly detectionwhat is out of the ordinary?drop in requests, unusual latency
Log rate analysiswhy this log spike?the fields that explain the spike
Log pattern analysiswhich kinds of messages?groups millions of lines into patterns
Change point detectionwhen did behaviour change?level shift after a deployment
Data frame analyticsclassify, predict, isolateoutlier detection, regression, classification
Trained modelsunderstand textELSER for semantic search, NER
Good to know: Anomaly detection and data frame analytics require a Platinum or Enterprise licence (or the 30-day trial) and nodes with the ml role.

Licence and trial #

LicenceWhat is available
Basic (free)Data Visualizer, file upload, viewing existing results
Trial (30 days)all machine learning features, as in Platinum / Enterprise
Platinum / Enterpriseanomaly detection, data frame analytics, trained models (NLP, ELSER), AIOps
GET _license                                   # type et date d'expiration
POST _license/start_trial?acknowledge=true     # essai de 30 jours, une seule fois par version majeure
Common mistake: Building production monitoring on the trial: when it expires, the cluster falls back to the Basic licence and anomaly detection jobs stop. Plan the subscription, or use threshold alert rules (free) for critical needs.
Depending on the version: the exact split of features between licences changes over time (AIOps, trained models): check Elastic's Subscriptions page for your version.

2. Creating a job #

Detectors and datafeed.

Concepts #

Indices, datafeed, job, results, alert.
ConceptRole
Detectorfunction + field: count, mean(latency), rare(process.name)…
bucket_spananalysis granularity (15 min by default)
partition_field / by_fieldone model per value (per service, per host)
Influencersfields explaining the anomaly (IP, URL, host)
Datafeedquery feeding the job, continuously or over history
PUT _ml/anomaly_detectors/latence-services
{
  "analysis_config": {
    "bucket_span": "15m",
    "detectors": [ { "function": "high_mean", "field_name": "transaction.duration.us", "partition_field_name": "service.name" } ],
    "influencers": ["service.name", "host.name"]
  },
  "data_description": { "time_field": "@timestamp" }
}
PUT _ml/datafeeds/datafeed-latence-services
{ "job_id": "latence-services", "indices": ["traces-apm*"] }
POST _ml/anomaly_detectors/latence-services/_open
POST _ml/datafeeds/datafeed-latence-services/_start

3. Reading and using results #

Score, explorer, alerts.

In Kibana #

  • Anomaly Explorer: view by influencer and period, colours by score (0 to 100).
  • Single Metric Viewer: the actual curve, the expected-behaviour band, anomalies and forecasts (_forecast).
  • Anomaly detection alert rule: notify above a score (for example 75) through a connector.
GET _ml/anomaly_detectors/latence-services/results/records?sort=record_score&desc=true&size=5
POST _ml/anomaly_detectors/latence-services/_forecast
{ "duration": "1d" }
Good practice: Let the model learn over several cycles (at least two weeks for a weekly rhythm) before alerting, and start with a high threshold.
Common mistake: Partitioning on a very high-cardinality field (session ID, full URL): model memory explodes and results become unreadable. Partition by service or host, and keep the rest as influencers.

4. Ready-made jobs #

Observability and Security.

Wizards #

Observability apps (APM, logs, infrastructure) and Security offer preconfigured jobs: abnormal APM latency, unusual log rate, rare processes on a host. Elastic Security also uses them as machine learning detection rules.

Related articles

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Kibana Maps and Canvas: geographic maps and presentations

Build maps with Kibana Maps (document, aggregation and choropleth layers, ES|QL) and dynamic presentations wi…

Elastic Security: SIEM, detection rules and investigation

Use Elastic Security as a SIEM: ECS data sources, detection rule types (query, EQL, ES|QL, threshold, indicat…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!