
elasticsearch-anomaly-detection
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.
- Installs
- 1K
- Last 24h
- +20
- Trending rank
- #5845
- 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- 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 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.
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.
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>' |
FAQ
What does the elasticsearch-anomaly-detection skill do?
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.
How do I install elasticsearch-anomaly-detection?
Run npx skills add https://github.com/elastic/agent-skills --skill elasticsearch-anomaly-detection 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/ (personal) or .claude/skills/elasticsearch-anomaly-detection/ (project).
Which AI agents can use elasticsearch-anomaly-detection?
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 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?
It is published by elastic in elastic/agent-skills. It has 1,038 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 backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.