elasticsearch-anomaly-detection
Skill583 starsChanged 58 days agoApache-2.0View on GitHub
Create and manage Elastic ML anomaly detection jobs via the API. Use when setting up jobs on an index or data stream, configuring jobs and datafeeds, or opening, starting, or stopping them.
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Create, open, and start ML anomaly detection jobs on time-series data.
- Very specific: line 92
Create the job: Call PUT /_ml/anomaly_detectors/{job_id} with the job id the user requested (or a descriptive id you propose).
- Very specific: line 95
Create the datafeed: Call PUT /_ml/datafeeds/datafeed-{job_id} immediately after job creation.
- Distinctive: line 114
Confirm running state from stats: Verify the outcome with:
- Distinctive: line 124
When stopping or deleting a job, reverse the startup order:
- Distinctive: line 129
Stop the datafeed before closing the job.
≈ “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
Elasticsearch Anomaly Detection
Create, open, and start ML anomaly detection jobs on time-series data. Choose the right count-family detector direction, configure bucket span and time field, wire the datafeed to the correct index, and confirm running state from stats — not from assumptions.
<!-- 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 -->Prerequisite: ML anomaly detection requires a Platinum-equivalent license on self-managed clusters. Serverless projects include ML. The caller needs
manage_mlto create and manage jobs.Related skill: For interpreting anomaly scores, influencers, and model behavior after a job is running, use
elasticsearch-anomaly-detection-explainer— not this skill.
Process
- Discover the target index and time field. List candidate indices with
GET /_cat/indices(pass a pattern when the user names one). Fetch field types for the chosen index withGET /{index}/_mapping. The decision: confirm the index exists, identify the time field (often@timestamp), and verify document volume is sufficient for baseline learning. Never guess index or field names — they vary across deployments. Choose detector function and direction. Match the user's intent to a count-family detector in
analysis_config.detectors:- Spike, surge, unusual increase in event volume →
high_count(orcount, which flags both directions but is acceptable when the user cares about spikes). Do not uselow_count— it will miss spikes. - Drop, outage, absence of events, traffic stops →
low_count. Do not usehigh_count— it will miss drops and silence. - Metric deviation (CPU, latency, a numeric field) → mean-family functions (
mean,high_mean,low_mean) withfield_nameset — only when the user asks about a numeric metric, not raw event volume.
The decision: pick one primary detector whose direction matches the anomaly type. For volume spike/drop questions on document counts, stay in the count family — mean detectors are unsuited to "how many events" questions.
- Spike, surge, unusual increase in event volume →
Set immutable job shape before creation. These fields cannot change after
PUT /_ml/anomaly_detectors/{job_id}:analysis_config.bucket_span— use the interval the user specifies (e.g.15mfor 15-minute buckets). Match the granularity of anomalies they care about; too short is noisy, too long is slow to detect.data_description.time_field— the time field from the mapping (commonly@timestamp).analysis_config.detectors— the function and direction from step 2.
Example job body for a volume-spike detector:
{ "analysis_config": { "bucket_span": "15m", "detectors": [{ "function": "high_count" }] }, "data_description": { "time_field": "@timestamp" } }Example for an outage / drop detector:
{ "analysis_config": { "bucket_span": "15m", "detectors": [{ "function": "low_count" }] }, "data_description": { "time_field": "@timestamp" } }- Create the job. Call
PUT /_ml/anomaly_detectors/{job_id}with the job id the user requested (or a descriptive id you propose). The job starts inclosedstate — creating it does not start analysis. Create the datafeed. Call
PUT /_ml/datafeeds/datafeed-{job_id}immediately after job creation. Setjob_idto the same id,indicesto the target index (exact name or pattern from step 1), and a query that selects the relevant documents (typicallymatch_all). The datafeed id convention isdatafeed-{job_id}.{ "job_id": "{job_id}", "indices": ["{index}"], "query": { "match_all": {} } }Open the job, then start the datafeed — in that order. This sequence is mandatory; do not skip or reorder:
POST /_ml/anomaly_detectors/{job_id}/_open— transitions the job toopened.POST /_ml/datafeeds/datafeed-{job_id}/_start— transitions the datafeed tostarted.
Opening before the datafeed exists fails. Starting the datafeed before opening the job fails. Do not report success after only creating resources — the job is not running until both are active.
Confirm running state from stats. Verify the outcome with:
GET /_ml/anomaly_detectors/{job_id}/_stats— expectstate: "opened".GET /_ml/datafeeds/datafeed-{job_id}/_stats— expectstate: "started".
Optionally call
GET /_ml/anomaly_detectors/{job_id}to confirm configuration (detectors,bucket_span,time_field, datafeed indices). Report both stats states explicitly — "created" is not the same as "opened" and "started".
Teardown
When stopping or deleting a job, reverse the startup order:
POST /_ml/datafeeds/datafeed-{job_id}/_stop— stop the datafeed first.POST /_ml/anomaly_detectors/{job_id}/_close— then close the job.
Stop the datafeed before closing the job. Close the job before resetting or deleting it.
Guidelines
- Required lifecycle order (create): job → datafeed → open job → start datafeed. Every new job follows this sequence.
- Detector direction is the highest-impact decision for volume anomalies. Re-read the user's wording: "spike", "surge", and "unusual increase" → high direction; "drop", "outage", "stops", "absence" → low direction.
- Immutable fields (
bucket_span, detectors,time_field) require delete-and-recreate if wrong — validate mapping and intent before the firstPUT. - Datafeed index must match the user's target. Point
indicesat the exact index or pattern they named — not a nearby guess. - Entity-level analysis (
by_field_name,over_field_name,partition_field_name) and advanced tuning live in references/anomaly-detection-reference.md.
Full Reference
For API paths, request/response fields, score semantics, and field interactions, read references/anomaly-detection-reference.md.
Operations
| HTTP API (shorthand) | elastic CLI command |
GET /_cat/indices | elastic es cat indices --index '<pattern>' |
GET /{index}/_mapping | elastic es indices get-mapping --index '<index>' |
PUT /_ml/anomaly_detectors/{job_id} | elastic es ml put-job --job-id '<job_id>' --analysis-config '<json>' --data-description '<json>' |
PUT /_ml/datafeeds/datafeed-{job_id} | elastic es ml put-datafeed --datafeed-id 'datafeed-<job_id>' --job-id '<job_id>' --indices '<index>' --query '<json>' |
POST /_ml/anomaly_detectors/{job_id}/_open | elastic es ml open-job --job-id '<job_id>' |
POST /_ml/datafeeds/datafeed-{job_id}/_start | elastic es ml start-datafeed --datafeed-id 'datafeed-<job_id>' |
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}/_stats | elastic es ml get-datafeed-stats --datafeed-id 'datafeed-<job_id>' |
POST /_ml/datafeeds/datafeed-{job_id}/_stop | elastic es ml stop-datafeed --datafeed-id 'datafeed-<job_id>' |
POST /_ml/anomaly_detectors/{job_id}/_close | elastic es ml close-job --job-id '<job_id>' |
Other versions3 projects use a version of this.
Word for word · 3
- elastic/cursor-plugins★ 33100% same
- elastic/claude-plugin★ 4100% same
- elastic/elastic-aws-kiro-powers★ 0100% 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-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-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
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.

