
elasticsearch-anomaly-detection-explainer
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.
- Installs
- 1K
- Last 24h
- +20
- Trending rank
- #5764
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/elastic/agent-skills --skill elasticsearch-anomaly-detection-explainer- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads elasticsearch-anomaly-detection-explainer automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Anomaly Detection Score Explainer
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.
Environment Configuration
This skill executes Elasticsearch operations through the elastic CLI. If the
elastic CLI 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 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.
Prerequisite: ML anomaly detection requires a Platinum-equivalent license on self-managed clusters. Serverless projects include ML. The caller needs
monitor_mlto read job config and anomaly results.Serverless note: The
_ml/.../results/*REST endpoints return HTTP 410 in Elastic Serverless. Always usePOST /.ml-anomalies-*/_searchfor result queries instead — fully supported everywhere this skill runs.
Process
-
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, andfunction; otherwise fetch the missing pieces before explaining. -
Verify connectivity when calling the cluster. Call
GET /. If the call fails, stop and surface the connection error — do not guess endpoints or credentials. -
Resolve the job ID and load config. When the job ID is unknown, call
GET /_ml/anomaly_detectorsto list candidates. CallGET /_ml/anomaly_detectors/{job_id}for fullanalysis_config(bucket_span, detectors, custom_rules, use_null, model_plot_config) andGET /_ml/anomaly_detectors/{job_id}/_statsforstate,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_countjob legitimately fires on drops; ahigh_countjob does not. -
Retrieve anomaly records for the time range. Call
POST /.ml-anomalies-*/_searchwithresult_type: record, the job ID, a timestamp range, and optionalrecord_scorefilter. Readinitial_record_score,record_score,actual,typical,function,multi_bucket_impact, andanomaly_score_explanation.Always show both
initial_record_scoreandrecord_score. The gap is the renormalization story. -
Classify the score pattern before speculating on causes.
initial_record_score>>record_score— Renormalization. A later, more extreme anomaly rescale this record downward. This is expected, healthy model behavior — not a broken model or reason to distrust the detection. Useinitial_record_scorefor alerting severity; show both scores and explain the gap explicitly.initial_record_score==record_score— No renormalization has occurred since detection.actual<<typicalwithlow_count,count, orlow_mean— Absence / drop anomaly. A high score is legitimate — the job detected an outage, pipeline stall, or service failure. This is not a false positive. Recommend incident investigation, not score tuning.actual>>typicalwithhigh_countorhigh_mean— Spike anomaly; confirm withsingle_bucket_impact.
Only cite
anomaly_score_explanationfactors present in the record. Ifhigh_variance_penaltyisfalse, do not blame variance. If a factor is absent, note that it was not returned — do not invent it. -
Quantify renormalization across the job (optional). Re-query
POST /.ml-anomalies-*/_searchfor records in the time range sorted bytimestampascending. Computescore_drift = initial_record_score − record_scoreper record and filter to|score_drift| ≥ 20. Large negative drift (initial >> record) confirms renormalization after a more extreme anomaly appeared later. -
Add context when the user asks "what caused this?" or "why so low/high?"
- Model bounds — If
model_plot_config.enabledis true, callPOST /.ml-anomalies-*/_searchwithresult_type: model_plotfor the same job and time range. Compareactualtomodel_lower/model_upper. - Influencers — Call
POST /.ml-anomalies-*/_searchwithresult_type: influencerfor the bucket time range; sort byinfluencer_scoredescending. - Categorization jobs — Call
POST /.ml-anomalies-*/_searchwithresult_type: category_definitionto list learned log patterns (terms,regex,examplespercategory_id).
For aggregations, cross-job queries, bucket-level results, or custom filters beyond score and time, see references/explainer-reference.md.
- Model bounds — If
Common multi-step workflows
| Task | Steps (in order) |
|---|---|
| Explain a specific anomaly | job config → records (job + exact time) → show initial_record_score vs record_score + score factors. |
| Why is my score low? | job config → records → renormalization check → model plot (if enabled) → explain score factors. |
| Why is my score high? | job config → records → check function direction, insufficient history, use_null, cardinality. |
| Renormalization drift | records (timestamp sort) → compute score_drift → list records where initial >> record. |
| Which entities contributed? | influencers (job + time range) → sort by influencer_score. |
| Visualize model bounds | model plot (job + time range) → compare model_lower/model_upper vs actual. |
| Categorization job patterns | category_definition (job_id) → terms, regex, examples per category. |
Critical principles
- Retrieve the record first (or use the one the user supplied). Never explain scores without
initial_record_score,record_score,actual,typical, andfunction. - Renormalization is healthy. When
initial_record_score >> record_score, a more extreme anomaly appeared later and lowered this score — expected behavior, not a model failure. - Direction matters.
low_countfires when values drop;high_countfires on spikes. A high score on a traffic stop withlow_countis correct detection, not a false positive. - Explain factors before speculating. Read
anomaly_score_explanationfrom the record. Only address factors that are present and relevant. - Job config is essential.
bucket_span, detector function,custom_rules,use_null, and memory status all affect scores. Inspect job config when a score is surprising. - Model plot is the most visual explanation. When enabled, show model bounds to illustrate where the actual value falls relative to the expected range.
- For job health ("missing documents", "memory limit", "datafeed not running") use the
elasticsearch-anomaly-detectionskill.
Domain knowledge
Score types
| Term | Meaning |
|---|---|
| record_score | Normalized 0–100 for a single anomaly record; updated by renormalization. >75 critical. |
| initial_record_score | Score assigned at detection time, before renormalization. Use for alerting. |
| anomaly_score | Bucket-level severity aggregated across all detectors in a job. |
| influencer_score | How unusual a specific entity (host, user, service) is in a bucket; high = likely cause. |
| multi_bucket_impact | 0–5; how much sustained, multi-bucket behavior raised the score. ≥3 = behavioral shift. |
anomaly_score_explanation factors
The anomaly_score_explanation field on each record breaks the score into components:
| Factor | Direction | Meaning |
|---|---|---|
| anomaly_length | Raises | Number of consecutive buckets the anomaly spans. Longer → higher score. |
| single_bucket_impact | Raises | Extremity of this single bucket. Lower probability → higher impact. |
| multi_bucket_impact | Raises | Contribution of sustained multi-bucket pattern. |
| anomaly_characteristics_impact | Raises | Whether the anomaly is a mean shift vs. variance change. |
| high_variance_penalty | Lowers | Noisy data or early training → wide confidence bounds → score reduced. |
| incomplete_bucket_penalty | Lowers | Bucket had less data than expected (delayed data, sparse events). |
Why a score might be unexpectedly low
- high_variance_penalty: The metric is historically noisy — wide confidence bounds absorb the spike.
- Renormalization: A more extreme anomaly appeared later and pushed this score down (
initial_record_score>>record_score). - Insufficient training history: Need ≥3 weeks for weekly seasonality, ≥2 full cycles for any detected period.
- bucket_span too large: Short-duration spikes get smoothed. Use a smaller
bucket_spanfor high-frequency events. - Detector function mismatch:
meanvshigh_mean,countvshigh_count— only one direction fires. - incomplete_bucket_penalty: Bucket received less data than expected (ingest latency or gaps).
- custom_rules: A detector filter may be suppressing the anomaly.
Why a score might be unexpectedly high
- Insufficient history: Model hasn't learned the normal pattern yet — early anomalies are unreliable.
- Model split thin: High-cardinality
partition_fieldorby_field→ very few points per entity → unreliable probabilities. - use_null: If
use_null: true, missing entities produce "null" anomalies that may not be meaningful. - Absence / drop detection: With
low_countorlow_mean,actual << typicalproduces a legitimately high score — treat as a real incident, not a false positive.
Model behavior concepts
| Concept | Meaning |
|---|---|
| actual | Observed value. typical is what the model expected. The direction matters. |
| Absence anomaly | actual << typical with count, low_count, or low_mean → outage, pipeline stop, service failure. |
| by_field | Independent baseline per entity (e.g., per host). Each entity compared to its own history. |
| over_field | Population analysis — entity compared to its peer group in the same bucket, not its own history. |
| partition_field | Fully independent sub-models with separate score normalization per partition. |
Model plot and categories
- Model plot: Shows the model's learned upper and lower bounds at each time point. If
actualis within bounds, no anomaly; if outside, the score depends on the distance from bounds. Only available whenmodel_plot_configis enabled on the job. Query viaPOST /.ml-anomalies-*/_searchwithresult_type: model_plot. - Categories: For jobs with a
categorization_field_name, queryresult_type: category_definitionto show log message patterns (terms, regex, examples percategory_id). Anomaly records useby_field_value = <category_id>.
Score troubleshooting protocol
- List jobs — Call
GET /_ml/anomaly_detectorswhen the job ID is unknown. - Get job config and stats — Call
GET /_ml/anomaly_detectors/{job_id}andGET /_ml/anomaly_detectors/{job_id}/_stats. Verifybucket_span, detector function,custom_rules,use_null, job state (opened/closed/failed), andmodel_size_stats.memory_status. - Retrieve the record — Call
POST /.ml-anomalies-*/_searchwithresult_type: record, the job ID, time range, and optional minimumrecord_score. Inspectinitial_record_score,record_score,actual,typical,function,multi_bucket_impact, andanomaly_score_explanation. - Check renormalization — Compare
initial_record_scorevsrecord_score. If initial >> record, re-query records sorted by timestamp and computescore_driftto quantify renormalization across the job. - Visualize model bounds — If
model_plot_configis enabled, queryresult_type: model_plotand show where the actual value fell relative tomodel_lowerandmodel_upper. - Influencers — Query
result_type: influencerfor the anomaly bucket time range; sort byinfluencer_score. - Explain factors — From the record's
anomaly_score_explanation, address each present relevant factor:high_variance_penalty,incomplete_bucket_penalty,anomaly_length,single_bucket_impact,multi_bucket_impact. Do not cite factors absent from the record.
Examples
- "Why is my anomaly score only 15 when the spike looks huge?" → Check renormalization:
initial_record_score(~92) >>record_score(~15). The spike was real; the current score was rescaled down. Use the initial score for alerting. - "Traffic stopped and I got a HIGH score — false positive?" → No.
low_countwithactualfar belowtypicalis legitimate absence detection. Investigate the outage. - "Which entities contributed most to the anomalies in job X last night?" → Query influencers for the time range.
- "Show me the model bounds for this job." → Query model plot when
model_plot_configis enabled. - "List records where the score was renormalized down a lot." → Records sorted by timestamp; filter large
initial_record_score − record_score.
Guidelines
- Report only what the API or the user-supplied record contains; do not invent scores, timestamps, entity values, or explanation factors.
- Always show both
initial_record_scoreandrecord_scorewhen explaining a record; state explicitly whether renormalization occurred. - When a score factor is missing from the record, do not assert it; note that the field was not returned.
- Do not attribute low scores to
high_variance_penaltyorincomplete_bucket_penaltywhen those flags arefalseor absent in the record. - For investigation ("what caused this?", "which service is responsible?") query influencers or construct cross-job searches via references/explainer-reference.md.
- For job health use the
elasticsearch-anomaly-detectionskill.
Operations
| HTTP API (shorthand) | elastic CLI command |
|---|---|
GET / | elastic es info |
GET /_ml/anomaly_detectors | elastic es ml get-jobs |
GET /_ml/anomaly_detectors/{job_id} | elastic es ml get-jobs --job-id '<job_id>' |
GET /_ml/anomaly_detectors/{job_id}/_stats | elastic es ml get-job-stats --job-id '<job_id>' |
POST /.ml-anomalies-*/_search | elastic es search --index '.ml-anomalies-*' --input-file '<search-body.json>' |
Query body shapes for each result_type (record, influencer, model_plot, category_definition) are documented in
references/explainer-reference.md.
FAQ
What does the elasticsearch-anomaly-detection-explainer skill do?
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.
How do I install elasticsearch-anomaly-detection-explainer?
Run npx skills add https://github.com/elastic/agent-skills --skill elasticsearch-anomaly-detection-explainer in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/elasticsearch-anomaly-detection-explainer/ (personal) or .claude/skills/elasticsearch-anomaly-detection-explainer/ (project).
Which AI agents can use elasticsearch-anomaly-detection-explainer?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is elasticsearch-anomaly-detection-explainer safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains elasticsearch-anomaly-detection-explainer?
It is published by elastic in elastic/agent-skills. It has 1,034 recorded installs.
More from elastic/agent-skills
elasticsearch-esql
elastic/agent-skills
Execute ESQL (Elasticsearch Query Language) queries, use when the user wants to query Elasticsearch data, analyze logs, aggregate metrics, explore data, or create charts and dashboards from ESQL results.
elasticsearch-onboarding
elastic/agent-skills
Help developers new to Elasticsearch get from zero to a working search experience. Guide them through understanding their intent, mapping their data, and building a search experience with best practices baked in. Use this when the user shows intent to build search-related functionality, asks about Elasticsearch-related concepts for their use case, or expresses the need for help getting started with Elasticsearch.
kibana-dashboards
elastic/agent-skills
Create and manage Kibana Dashboards and Lens visualizations. Use when you need to define dashboards and visualizations declaratively, version control them, or automate their deployment.
security-case-management
elastic/agent-skills
Create, search, update, and manage SOC cases via the Kibana Cases API. Use when tracking incidents, linking alerts to cases, adding investigation notes, or managing triage output.
kibana-alerting-rules
elastic/agent-skills
Create and manage Kibana alerting rules. Use when creating, updating, or managing rule lifecycle (enable, disable, mute, snooze), choosing metric threshold rule types and params, or read-only find/list with tag filters.
kibana-agent-builder
elastic/agent-skills
Create and manage Kibana Agent Builder agents and custom tools. Use when asked to create, update, delete, test, or inspect agents or tools in Agent Builder, or when the user wants to understand what agents or tools already exist.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available