kibana-anomaly-detection
Skill583 starsChanged 58 days agoApache-2.0View on GitHub
Elastic ML anomaly detection — investigation/RCA, score explanation, job lifecycle troubleshooting, and job operations. Use when answering "what broke?"/"which entity?"/RCA, "why is score high/low?"/renormalization, "datafeed stopped"/"memory limit"/hard_limit, or configuring ML anomaly detection jobs. Reads results from `.ml-anomalies-*` and job state from ML REST APIs.
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 3 are distinctive, and 22 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
22
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
When a question spans modes: Investigate → Explain → Troubleshoot.
- Very specific: line 68
Treat .ml-anomalies-* as layered result types via result_type in search queries:
- Distinctive: line 78
Read scores this way:
- Very specific: line 85
Read multi_bucket_impact (-5 to +5) to separate single-bucket spikes from sustained trends.
- Very specific: line 95
Discover jobs: Call GET /_ml/anomaly_detectors when the job ID is unknown.
- Very specific: line 100
Scope the incident window: Call POST /.ml-anomalies-*/_search with result_type: bucket, a time range, and optional minimum anomaly_score.
- Very specific: line 115
Drill into records: Call POST /.ml-anomalies-*/_search with result_type: record, exact job ID, entity filters (partition_field_value, …
- Very specific: line 120
Confirm with source evidence: Call POST /{index}/_search on the datafeed source index for the suspect entity and time window.
- Very specific: line 145
Decide fetch vs interpret: If the user supplies a record with record_score, initial_record_score, actual, and typical, interpret directly.
- Very specific: line 162
Only cite anomaly_score_explanation factors present in the record.
- Very specific: line 167
Add visual context when needed: If model_plot_config.enabled, query result_type: model_plot and compare actual to model_lower/model_upper.
- Very specific: line 170
Check job health when scores look wrong persistently: Call GET /_ml/anomaly_detectors/{job_id}/_stats — model_size_stats.memory_status of …
- Very specific: line 201
Load job and datafeed state: Call GET /_ml/anomaly_detectors/{job_id}/_stats and GET /_ml/datafeeds/datafeed-{job_id}/_stats.
- Very specific: line 213
When memory_status is hard_limit and model_bytes equals model_bytes_memory_limit, the model hit its memory ceiling — it stops learning new …
- Very specific: line 223
Diagnose missing documents / query timing: After memory is healthy, inspect datafeed query_delay and delayed_data_check_config via GET …
- Very specific: line 227
Read job messages: Search .ml-notifications-* for the job ID when errors are unclear.
- Very specific: line 229
Recover corrupted model state: Call POST /_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_revert to revert to a known-good …
- Very specific: line 265
Verify target index: Call GET /{index}/_mapping — confirm time field and detector fields exist.
- Very specific: line 266
Create job: Call PUT /_ml/anomaly_detectors/{job_id} with analysis_config (detectors, bucket_span, influencers) and …
- Very specific: line 268
Create datafeed: Call PUT /_ml/datafeeds/datafeed-{job_id} with indices, query, and query_delay.
- Very specific: line 269
Open and start: Call POST /_ml/anomaly_detectors/{job_id}/_open, then POST /_ml/datafeeds/datafeed-{job_id}/_start.
- Very specific: line 271
Confirm: Call GET /_ml/anomaly_detectors/{job_id}/_stats and GET /_ml/datafeeds/datafeed-{job_id}/_stats.
- Distinctive: line 306
Pick a mode first: Don't blend RCA logic with score-explanation logic in one response.
- Very specific: line 308
For lifecycle failures read
memory_status: before recommending datafeed restarts. - Very specific: line 339
Search body shapes for each result_type and troubleshooting queries are documented in references/investigation-queries.md and …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Elastic ML Anomaly Detection
Expert process for ML anomaly detection: attribute incidents to entities, explain scores and model behavior, diagnose
job lifecycle failures, and manage jobs. Read anomaly results from POST /.ml-anomalies-*/_search (Serverless-safe)
and job/datafeed state from ML REST APIs. When the user embeds fixture evidence (influencer rows, job stats) in the
prompt, apply the judgment below directly — do not re-fetch fields already supplied.
<!-- begin-partial: preamble -->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.
<!-- end-partial: preamble -->Mode selector
| User intent | Mode |
| "What broke?" / RCA / cross-job / blast radius / influencers / log categories | Investigate |
| "Why score high/low?" / renormalization / model bounds / forecasts | Explain |
| Missing docs / memory limit / datafeed stopped / lifecycle / calendars | Troubleshoot |
| Create a job / configure a datafeed / start analysis / retrieve results | Manage |
| Security framing (attack chains, MITRE, exfil) | Investigate + references/security-anomaly-expert.md |
| Observability/SRE framing (degradation, capacity, deployment regression) | Investigate + references/observability-anomaly-expert.md |
When a question spans modes: Investigate → Explain → Troubleshoot. Finish one mode before blending logic.
Serverless note: Legacy
/_ml/anomaly_detectors/{job_id}/results/*endpoints return HTTP 410 in Serverless. Always query.ml-anomalies-*viaPOST /.ml-anomalies-*/_searchwithresult_typefilters.
Score quick reference
record_scorebands: >75 critical · 50–75 warning · 25–50 minor · <25 informationalmulti_bucket_impact ≥ 3→ sustained shift (not a transient spike)initial_record_score >> record_score→ renormalization (model saw worse anomalies later)actual << typicalwithcount/low_count/low_mean→ absence/outage, not just a low value- Low scores across many jobs > one high score — composite cross-job signal often beats single-detector severity
Full score definitions, renormalization mechanics, and
anomaly_score_explanationcomponents: references/score-reference.md.
Core concepts
Treat .ml-anomalies-* as layered result types via result_type in search queries:
result_type | Scope | Key fields |
bucket | Time window | anomaly_score, initial_anomaly_score, timestamp |
record | Detector row | record_score, initial_record_score, actual, typical, anomaly_score_explanation |
influencer | Entity × bucket | influencer_field_name, influencer_field_value, influencer_score |
model_plot | Bounds | model_lower, model_upper, actual |
category_definition | Log patterns | category_id, terms, regex, examples |
Read scores this way:
anomaly_score/record_score= current normalized values (move as the model sees new extremes).initial_anomaly_score/initial_record_score= immutable snapshots from detection time.influencer_scoreranks entity responsibility within a bucket — the highest score is the primary suspect, not the bucket-levelanomaly_scorealone.- Map entities via
partition_field_value/by_field_value/over_field_value. - Read
multi_bucket_impact(-5 to +5) to separate single-bucket spikes from sustained trends.
Mode: Investigate — RCA
When: "what broke?", "which entity caused this?", cross-job correlation, blast radius, attack/cascade chains.
Process
- Discover jobs. Call
GET /_ml/anomaly_detectorswhen the job ID is unknown. CallGET /_ml/anomaly_detectors/{job_id}andGET /_ml/datafeeds/datafeed-{job_id}to learn source indices, entity fields (by_field_name,over_field_name,partition_field_name), andbucket_span. The decision: identify the related job group — jobs sharing a datafeed index or entity field monitor the same system from different angles. - Scope the incident window. Call
POST /.ml-anomalies-*/_searchwithresult_type: bucket, a time range, and optional minimumanomaly_score. The decision: fix the incident start/end and count how many jobs co-fire in that window. Low scores across many jobs simultaneously often indicate a systemic root cause. - Attribute to entities (critical for RCA). For the anomalous bucket timestamp, call
POST /.ml-anomalies-*/_searchwithresult_type: influencer, the job ID(s), and the bucket time range. Sort byinfluencer_scoredescending. The decision: name the entity with the highestinfluencer_scoreas the likely cause — it ranks how unusual each entity is in that bucket. Do not restate only the bucketanomaly_scorewithout attributing responsibility. Recommend drilling into that entity's records next. - Cross-job confirmation. Re-query influencers (or bucket records) across related job IDs for the same entity values and time window. Entities anomalous in 2+ jobs are prime suspects (resource fault or systemic failure); single-job entities are often downstream victims. See references/protocols/investigation.md.
- Drill into records. Call
POST /.ml-anomalies-*/_searchwithresult_type: record, exact job ID, entity filters (partition_field_value,by_field_value), and low minimumrecord_score(25 or lower). Readmulti_bucket_impact ≥ 3as sustained behavioral shift. Readactualvstypicalfor fault class (spike vs absence/outage). - Confirm with source evidence. Call
POST /{index}/_searchon the datafeed source index for the suspect entity and time window. Raw source documents are ground truth — never close an RCA without them. - Synthesize. Report: root cause entity · affected jobs · temporal progression · fault class · severity · recommended actions. Worked walkthrough: references/worked-example.md. Query templates: references/investigation-queries.md.
Rules
- Rank by
influencer_score, notanomaly_score, for "which entity?" — bucket score is aggregate; influencer score attributes cause. - Multi-job entities are prime suspects; single-job entities are usually victims.
- Earliest anomaly timestamp wins — reconstruct chronology from record timestamps across jobs.
multi_bucket_impact ≥ 3= sustained behavioral shift, weight higher than transient spikes.- Use low score thresholds (25 or lower) for influencer/record queries — high thresholds miss correlated entities.
- Never close an RCA without source evidence from the datafeed index.
Mode: Explain — Score / model behavior
When: "why is my score 30/90?", "score dropped overnight", "what is renormalization?", "why wasn't this detected?".
Process
- Decide fetch vs interpret. If the user supplies a record with
record_score,initial_record_score,actual, andtypical, interpret directly. Otherwise load config withGET /_ml/anomaly_detectors/{job_id}and records withPOST /.ml-anomalies-*/_search(result_type: record). - Always show both
initial_record_scoreandrecord_score. The gap is the renormalization story. Large positive drift (initial_record_score >> record_score) means a later, more extreme anomaly rescale this record downward — expected healthy behavior, not a broken model. Classify the pattern before speculating.
Pattern Interpretation initial_record_score >> record_scoreRenormalization — explain before suggesting config changes actual << typicalwithlow_count/count/low_meanAbsence/outage anomaly — investigate the outage, not score tuning high_variance_penalty: trueinanomaly_score_explanationNoisy metric — wide bounds absorbed the spike incomplete_bucket_penalty: trueIngest lag or sparse bucket — score legitimately reduced Only cite
anomaly_score_explanationfactors present in the record.- Quantify renormalization (optional). Re-query records sorted by
timestamp; computescore_drift = initial_record_score - record_scoreand flag large drift. - Add visual context when needed. If
model_plot_config.enabled, queryresult_type: model_plotand compareactualtomodel_lower/model_upper. For categorization jobs, queryresult_type: category_definition. - Check job health when scores look wrong persistently. Call
GET /_ml/anomaly_detectors/{job_id}/_stats—model_size_stats.memory_statusofhard_limitcorrupts learning and can invalidate scores. Escalate to Troubleshoot mode.
anomaly_score_explanation components
| Component | Effect | What it means |
anomaly_length | ↑ score | More consecutive anomalous buckets |
single_bucket_impact | ↑ score | Lower probability → higher impact |
multi_bucket_impact | ↑ score | Sustained pattern contribution |
anomaly_characteristics_impact | ↑ score | Mean shift vs. variance change |
high_variance_penalty | ↓ score | Noisy data → wide bounds → anomaly less surprising |
incomplete_bucket_penalty | ↓ score | Bucket has less data than expected (ingest lag, sparse data) |
Rules
- Explain renormalization before diagnosing config — score drift is the most common "score dropped" cause.
actual << typicalwith count/low_count is an absence anomaly — distinguish outages from value spikes.- Weekly seasonality needs ≥3 weeks of training data — flag young jobs as the cause.
- Detector function direction matters — see references/anomaly-detection-functions.md.
Mode: Troubleshoot — Job lifecycle
When: "missing documents", "datafeed stopped", hard_limit, "results look wrong", lifecycle changes.
Process
- Load job and datafeed state. Call
GET /_ml/anomaly_detectors/{job_id}/_statsandGET /_ml/datafeeds/datafeed-{job_id}/_stats. Readstate,data_counts,model_size_stats, and datafeedstate. If the user embeds stats JSON, diagnose frommemory_statusand datafeed state directly. Diagnose memory status first (critical). Inspect
model_size_stats:Field Meaning memory_statusok/soft_limit(pruning) /hard_limit(critical)model_bytesCurrent memory used model_bytes_memory_limitConfigured model_memory_limitWhen
memory_statusishard_limitandmodel_bytesequalsmodel_bytes_memory_limit, the model hit its memory ceiling — it stops learning new entities and results degrade or stop. A stopped datafeed is often a symptom, not the root cause. Do not recommend only restarting the datafeed — that alone does not clear a hard limit.- Remediate hard_limit. The fix is to raise
model_memory_limit(via job update) and/or reduce model size by lowering cardinality (fewer partition/by/over field values, split into multiple jobs). Raising the limit requires the lifecycle sequence below (stop datafeed → close job → update → open → start). Optionally callPOST /_ml/anomaly_detectors/_estimate_model_memoryto size the new limit from source cardinality. - Diagnose missing documents / query timing. After memory is healthy, inspect datafeed
query_delayanddelayed_data_check_configviaGET /_ml/datafeeds/datafeed-{job_id}. Search.ml-annotations-*for delayed-data events. Setquery_delayto P95 ingest latency + buffer (default60s–120s). - Read job messages. Search
.ml-notifications-*for the job ID when errors are unclear. - Recover corrupted model state. Call
POST /_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_revertto revert to a known-good snapshot when the model was corrupted during hard_limit.
Lifecycle for config changes (memory limit, query_delay)
Apply in order — skipping steps causes rejected updates:
POST /_ml/datafeeds/datafeed-{job_id}/_stopPOST /_ml/anomaly_detectors/{job_id}/_closePOST /_ml/anomaly_detectors/{job_id}/_update(memory limit) and/orPOST /_ml/datafeeds/datafeed-{job_id}/_update(query_delay)POST /_ml/anomaly_detectors/{job_id}/_openPOST /_ml/datafeeds/datafeed-{job_id}/_start
Preview changes with POST /_ml/datafeeds/datafeed-{job_id}/_preview before restarting.
hard_limitcorrupts model state and causes downstream missing-doc false alarms. Fix memory before fixingquery_delay. Full troubleshooting detail: references/troubleshooting-reference.md.
Rules
- Ground lifecycle diagnosis in
memory_status— not generic "restart it" advice. - Fix memory before
query_delay— hard_limit invalidates downstream diagnostics. - Stop datafeed → close job → update → open → start for any memory or datafeed config change.
- Do not delete the job as first remediation for hard_limit — raise limit and/or reduce cardinality.
Mode: Manage — Create / configure jobs
When: "set up a job", "create an ML detector", "monitor X over time".
For the full create/open/start lifecycle, prefer the elasticsearch-anomaly-detection skill. This mode summarizes the
sequence and detector selection:
- Verify target index. Call
GET /{index}/_mapping— confirm time field and detector fields exist. - Create job. Call
PUT /_ml/anomaly_detectors/{job_id}withanalysis_config(detectors,bucket_span, influencers) anddata_description.time_field. - Create datafeed. Call
PUT /_ml/datafeeds/datafeed-{job_id}withindices,query, andquery_delay. - Open and start. Call
POST /_ml/anomaly_detectors/{job_id}/_open, thenPOST /_ml/datafeeds/datafeed-{job_id}/_start. - Confirm. Call
GET /_ml/anomaly_detectors/{job_id}/_statsandGET /_ml/datafeeds/datafeed-{job_id}/_stats.
Choose detector functions from user intent — see references/anomaly-detection-functions.md. Worked JSON bodies: references/job-creation-recipes.md.
Rules
- Create job before datafeed. Open job before starting datafeed.
query_delay= P95 ingest latency + buffer (60s–120s safe default).by_field_namevsover_field_name:bycompares entity to its own history;overcompares to peer group.- Forecasts require non-population jobs — jobs with
over_field_namecannot be forecasted.
Examples
RCA: "Something caused a spike in checkout latency — which entity?" → Query influencers for the bucket → web-07
has highest influencer_score (91.5) vs 22.0 and 8.4 → name web-07 as likely cause → recommend drilling into its
records — do not answer with only bucket anomaly_score 88.
Score drop: "Score went from 90 to 55 — did the model change?" → Compare initial_record_score vs record_score →
explain renormalization if drift is large.
Memory limit: "Job shows hard_limit and datafeed stopped." → Diagnose
model_size_stats.memory_status = hard_limit → raise model_memory_limit via close/update/open lifecycle and/or reduce
cardinality — not "just restart the datafeed".
New job: "Detect unusual error rates per host." → high_count with by_field_name: host.keyword →
create/open/start sequence.
Guidelines
- Pick a mode first. Don't blend RCA logic with score-explanation logic in one response.
- For "which entity?" rank
influencer_score, not bucketanomaly_score. - For lifecycle failures read
memory_statusbefore recommending datafeed restarts. - Show
initial_record_scorealongsiderecord_score— the gap tells the renormalization story. - Fix memory before
query_delay. Hard_limit invalidates downstream diagnostics. - Confirm RCAs with source evidence from the datafeed index.
Operations
| HTTP API (shorthand) | elastic CLI command |
GET /{index}/_mapping | elastic es indices get-mapping --index '<index>' |
POST /{index}/_search | elastic es search --index '<index>' --input-file '<search-body.json>' |
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>' |
GET /_ml/datafeeds/datafeed-{job_id} | elastic es ml get-datafeeds --datafeed-id 'datafeed-<job_id>' |
GET /_ml/datafeeds/datafeed-{job_id}/_stats | elastic es ml get-datafeed-stats --datafeed-id 'datafeed-<job_id>' |
POST /.ml-anomalies-*/_search | elastic es search --index '.ml-anomalies-*' --input-file '<search-body.json>' |
POST /.ml-annotations-*/_search | elastic es search --index '.ml-annotations-*' --input-file '<search-body.json>' |
POST /.ml-notifications-*/_search | elastic es search --index '.ml-notifications-*' --input-file '<search-body.json>' |
POST /_ml/anomaly_detectors/_estimate_model_memory | elastic es ml estimate-model-memory --analysis-config '<json>' |
PUT /_ml/anomaly_detectors/{job_id} | elastic es ml put-job --job-id '<job_id>' --input-file '<job-body.json>' |
PUT /_ml/datafeeds/datafeed-{job_id} | elastic es ml put-datafeed --datafeed-id 'datafeed-<job_id>' --input-file '<datafeed-body.json>' |
POST /_ml/anomaly_detectors/{job_id}/_open | elastic es ml open-job --job-id '<job_id>' |
POST /_ml/anomaly_detectors/{job_id}/_close | elastic es ml close-job --job-id '<job_id>' |
POST /_ml/anomaly_detectors/{job_id}/_update | elastic es ml update-job --job-id '<job_id>' --analysis-limits '<json>' |
POST /_ml/datafeeds/datafeed-{job_id}/_update | elastic es ml update-datafeed --datafeed-id 'datafeed-<job_id>' --input-file '<update-body.json>' |
POST /_ml/datafeeds/datafeed-{job_id}/_start | elastic es ml start-datafeed --datafeed-id 'datafeed-<job_id>' |
POST /_ml/datafeeds/datafeed-{job_id}/_stop | elastic es ml stop-datafeed --datafeed-id 'datafeed-<job_id>' |
POST /_ml/datafeeds/datafeed-{job_id}/_preview | elastic es ml preview-datafeed --datafeed-id 'datafeed-<job_id>' |
POST /_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_revert | elastic es ml revert-model-snapshot --job-id '<job_id>' --snapshot-id '<snapshot_id>' |
Search body shapes for each result_type and troubleshooting queries are documented in
references/investigation-queries.md and
references/troubleshooting-reference.md.
Other versions2 projects use a version of this.
Word for word · 2
- elastic/cursor-plugins★ 33100% same
- elastic/claude-plugin★ 4100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository51 other files it gives its agents.
- cloud-onboardingSkill
- cloud-provisioningSkill
- elasticsearch-anomaly-detection-explainerSkill
- elasticsearch-anomaly-detectionSkill
- elasticsearch-cluster-healthSkill
- elasticsearch-esqlSkill
- elasticsearch-index-designSkill
- elasticsearch-ingestSkill
- elasticsearch-onboardingSkill
- elasticsearch-query-optimizationSkill
- elasticsearch-reindexSkill
- elasticsearch-search-relevanceSkill
- kibana-agent-builderSkill
- kibana-alerting-rulesSkill
- kibana-anomaly-detectionSkill
- kibana-dashboardsSkill
- kibana-workflowsSkill
- observability-k8s-investigationSkill
- observability-llm-obsSkill
- observability-onboardingSkill
- observability-service-reliabilitySkill
- observability-sre-triageSkill
- security-alert-triageSkill
- security-case-managementSkill
- security-detection-rule-managementSkill
- security-generate-security-sample-dataSkill
- cloud-onboardingSkill
- cloud-provisioningSkill
- elasticsearch-anomaly-detection-explainerSkill
- elasticsearch-anomaly-detectionSkill
- elasticsearch-cluster-healthSkill
- elasticsearch-esqlSkill
- elasticsearch-index-designSkill
- elasticsearch-ingestSkill
- elasticsearch-onboardingSkill
- elasticsearch-query-optimizationSkill
- elasticsearch-reindexSkill
- elasticsearch-search-relevanceSkill
- kibana-agent-builderSkill
- kibana-alerting-rulesSkill
- kibana-dashboardsSkill
- kibana-workflowsSkill
- observability-k8s-investigationSkill
- observability-llm-obsSkill
- observability-onboardingSkill
- observability-service-reliabilitySkill
- observability-sre-triageSkill
- security-alert-triageSkill
- security-case-managementSkill
- security-detection-rule-managementSkill
- security-generate-security-sample-dataSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

