onboarding
Onboard an Elastic Cloud organization: configure the `elastic` CLI's Cloud context and API key, establish a default region, then…
Explain Elasticsearch ML anomaly detection scores, model behavior, and result interpretation. Use when the user asks why a score is high or low, how the model learns, what the numbers mean, or how to troubleshoot unexpected anomaly scores.
$ npx -y skills add elastic/agent-skills --skill elasticsearch-anomaly-detection-explainer --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/elasticsearch-anomaly-detection-explainerContext preview
The summary Claude sees to decide when to auto-load this skill.
Explain Elasticsearch ML anomaly detection scores, model behavior, and result interpretation. Use when the user asks why a score is high or low, how the model learns, what the numbers mean, or how to troubleshoot unexpected anomaly scores.
name: elasticsearch-anomaly-detection-explainer description: > Explain Elasticsearch ML anomaly detection scores, model behavior, and result interpretation. Use when the user asks why a score is high or low, how the model learns, what the numbers mean, or how to troubleshoot unexpected anomaly scores. compatibility: > Requires Elasticsearch 8.x+ or Elastic Cloud Serverless with ML anomaly detection. Uses the ML REST API and the standard _search API against .ml-anomalies-* — no ES|QL. User needs monitor_ml privilege for ML APIs. metadata: author: elastic version: 0.3.0 universal: true
Explain anomaly scores, model behavior, and why results look the way they do. Use the **ML REST API** for job config and the **standard `_search` API** against `.ml-anomalies-*` for results — no ES|QL, fully compatible with Elastic Serverless. For job lifecycle (create, start, stop), use the `elasticsearch-anomaly-detection` skill.
<!-- begin-partial: preamble -->
This skill executes Elasticsearch operations through the `elastic` CLI. If the [`elastic` CLI](https://github.com/elastic/cli#configuration) is not installed, tell the user what it is needed for. Do not guess credentials, call the HTTP API directly, or attempt other workarounds.
This skill references operations in HTTP-shorthand form (e.g., `GET /`, `GET /_cat/indices`, `GET /{index}/_mapping`, `GET /{index}/_settings/index.mode`, `POST /_query`). The [Operations](#operations) table at the end of this document maps each shorthand to the equivalent `elastic` CLI command — always use the CLI rather than calling the HTTP API directly.
<!-- end-partial: preamble -->
> **Prerequisite:** ML anomaly detection requires a Platinum-equivalent license on self-managed clusters. Serverless > projects include ML. The caller needs `monitor_ml` to read job config and anomaly results. > > **Serverless note:** The `_ml/.../results/*` REST endpoints return HTTP 410 in Elastic Serverless. Always use > `POST /.ml-anomalies-*/_search` for result queries instead — fully supported everywhere this skill runs.
1. **Decide whether to fetch data or interpret what the user supplied.** If the user embeds an anomaly record (or job config) in the prompt, interpret it directly using the domain knowledge below — do not call APIs to re-fetch fields already present. If the job ID, time range, or record is missing, retrieve it from the cluster.
The decision: proceed with judgment-only explanation when the record contains `record_score`, `initial_record_score`, `actual`, `typical`, and `function`; otherwise fetch the missing pieces before explaining.
2. **Verify connectivity when calling the cluster.** Call `GET /`. If the call fails, stop and surface the connection error — do not guess endpoints or credentials.
3. **Resolve the job ID and load config.** When the job ID is unknown, call `GET /_ml/anomaly_detectors` to list candidates. Call `GET /_ml/anomaly_detectors/{job_id}` for full `analysis_config` (bucket_span, detectors, custom_rules, use_null, model_plot_config) and `GET /_ml/anomaly_detectors/{job_id}/_stats` for `state`, `model_size_stats.memory_status`, and data counts.
The decision: confirm detector function and direction match the user's question before interpreting scores. A `low_count` job legitimately fires on drops; a `high_count` job does not.
4. **Retrieve anomaly records for the time range.** Call `POST /.ml-anomalies-*/_search` with `result_type: record`, the job ID, a timestamp range, and optional `record_score` filter. Read `initial_record_score`, `record_score`, `actual`, `typical`, `function`, `multi_bucket_impact`, and `anomaly_score_explanation`.
Always show **both** `initial_record_score` and `record_score`. The gap is the renormalization story.
5. **Classify the score pattern before speculating on causes.**
record downward. This is expected, healthy model behavior — not a broken model or reason to distrust the detection. Use `initial_record_score` for alerting severity; show both scores and explain the gap explicitly.
legitimate — the job detected an outage, pipeline stall, or service failure. This is **not** a false positive. Recommend incident investigation, not score tuning.
**Only cite `anomaly_score_explanation` factors present in the record.** If `high_variance_penalty` is `false`, do not blame variance. If a factor is absent, note that it was not returned — do not invent it.
6. **Quantify renormalization across the job (optional).** Re-query `POST /.ml-anomalies-*/_search` for records in the time range sorted by `timestamp` ascending. Compute `score_drift = initial_record_score − record_score` per record and filter to `|score_drift| ≥ 20`. Large negative drift (initial >> record) confirms renormalization after a more extreme anomaly appeared later.
7. **Add context when the user asks "what caused this?" or "why so low/high?"**
`result_type: model_plot` for the same job and time range. Compare `actual` to `model_lower` / `model_upper`.
sort by `influencer_score` descending.
Elastic Agent Skills — built by the people who built Elastic — deliver native platform expertise directly to your AI coding agent.
Onboard an Elastic Cloud organization: configure the `elastic` CLI's Cloud context and API key, establish a default region, then…
Provision and operate Elastic Cloud infrastructure: create, connect to, update, and delete Serverless projects (Elasticsearch,…
Create and manage Elastic ML anomaly detection jobs via the API. Use when setting up jobs on an index or data stream, configuring…
Diagnose a non-green Elasticsearch cluster and surface the single most likely cause with remediation. Use when an operator…
Execute ES|QL (Elasticsearch Query Language) queries, use when the user wants to query Elasticsearch data, analyze logs,…
Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields,…