Anomaly Detection Ml API
The machine learning APIs enable you to retrieve information related to the Elastic Stack machine learning features.
The machine learning APIs enable you to retrieve information related to the Elastic Stack machine learning features.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/anomaly-detection:anomaly-detection-ml-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Elasticsearch Ml API
license:
name: Apache 2.0
url: https://github.com/elastic/elasticsearch-specification/blob/main/LICENSE
version: ''
description: 'Elasticsearch provides REST APIs that are used by the UI components and can be called directly to configure and access Elasticsearch features.
## Documentation source and versions
This documentation is derived from the `main` branch of the elasticsearch-specification repository. It is provided under license Attribution-NonCommercial-NoDerivatives 4.0 International.
This documentation contains work-in-progress information for future Elastic Stack releases.'
x-doc-license:
name: Attribution-NonCommercial-NoDerivatives 4.0 International
url: https://creativecommons.org/licenses/by-nc-nd/4.0/
x-feedbackLink:
label: Feedback
url: https://github.com/elastic/docs-content/issues/new?assignees=&labels=feedback%2Ccommunity&projects=&template=api-feedback.yaml&title=%5BFeedback%5D%3A+
security:
- apiKeyAuth: []
- basicAuth: []
- bearerAuth: []
tags:
- name: Ml
x-displayName: Machine learning
description: The machine learning APIs enable you to retrieve information related to the Elastic Stack machine learning features.
externalDocs:
url: https://www.elastic.co/docs/explore-analyze/machine-learning
description: Learn more about machine learning.
paths:
/_ml/memory/{node_id}/_stats:
get:
tags:
- Ml
summary: Get machine learning memory usage info
description: '**All methods and paths for this operation:**
GET
/_ml/memory/_stats
GET
/_ml/memory/{node_id}/_stats
Get information about how machine learning jobs and trained models are using memory,
on each node, both within the JVM heap, and natively, outside of the JVM.
## Required authorization
* Cluster privileges: `monitor_ml`'
operationId: ml-get-memory-stats
parameters:
- $ref: '#/components/parameters/ml.get_memory_stats-node_id'
- $ref: '#/components/parameters/ml.get_memory_stats-master_timeout'
- $ref: '#/components/parameters/ml.get_memory_stats-timeout'
responses:
'200':
$ref: '#/components/responses/ml.get_memory_stats-200'
x-state: Generally available; Added in 8.2.0
x-codeSamples:
- lang: Console
source: 'GET _ml/memory/_stats?human
'
- lang: Python
source: "resp = client.ml.get_memory_stats(\n human=True,\n)"
- lang: JavaScript
source: "const response = await client.ml.getMemoryStats({\n human: \"true\",\n});"
- lang: Ruby
source: "response = client.ml.get_memory_stats(\n human: \"true\"\n)"
- lang: PHP
source: "$resp = $client->ml()->getMemoryStats([\n \"human\" => \"true\",\n]);"
- lang: curl
source: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/memory/_stats?human"'
- lang: C#
source: var response = await client.MachineLearning.GetMemoryStatsAsync();
- lang: Java
source: 'client.ml().getMemoryStats(g -> g);
'
x-metaTags:
- content: Elasticsearch, Machine Learning
name: product_name
/_ml/info:
get:
tags:
- Ml
summary: Get machine learning information
description: 'Get defaults and limits used by machine learning.
This endpoint is designed to be used by a user interface that needs to fully
understand machine learning configurations where some options are not
specified, meaning that the defaults should be used. This endpoint may be
used to find out what those defaults are. It also provides information about
the maximum size of machine learning jobs that could run in the current
cluster configuration.
## Required authorization
* Cluster privileges: `monitor_ml`'
operationId: ml-info
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
properties:
defaults:
allOf:
- $ref: '#/components/schemas/ml.info.Defaults'
limits:
allOf:
- $ref: '#/components/schemas/ml.info.Limits'
upgrade_mode:
type: boolean
native_code:
allOf:
- $ref: '#/components/schemas/ml.info.NativeCode'
required:
- defaults
- limits
- upgrade_mode
- native_code
x-state: Generally available; Added in 6.3.0
x-codeSamples:
- lang: Console
source: 'GET _ml/info
'
- lang: Python
source: resp = client.ml.info()
- lang: JavaScript
source: const response = await client.ml.info();
- lang: Ruby
source: response = client.ml.info
- lang: PHP
source: $resp = $client->ml()->info();
- lang: curl
source: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/info"'
- lang: C#
source: var response = await client.MachineLearning.InfoAsync();
- lang: Java
source: 'client.ml().info();
'
x-metaTags:
- content: Elasticsearch, Machine Learning
name: product_name
/_ml/set_upgrade_mode:
post:
tags:
- Ml
summary: Set upgrade_mode for ML indices
description: 'Sets a cluster wide upgrade_mode setting that prepares machine learning
indices for an upgrade.
When upgrading your cluster, in some circumstances you must restart your
nodes and reindex your machine learning indices. In those circumstances,
there must be no machine learning jobs running. You can close the machine
learning jobs, do the upgrade, then open all the jobs again. Alternatively,
you can use this API to temporarily halt tasks associated with the jobs and
datafeeds and prevent new jobs from opening. You can also use this API
during upgrades that do not require you to reindex your machine learning
indices, though stopping jobs is not a requirement in that case.
You can see the current value for the upgrade_mode setting by using the get
machine learning info API.
## Required authorization
* Cluster privileges: `manage_ml`'
operationId: ml-set-upgrade-mode
parameters:
- in: query
name: enabled
description: 'When `true`, it enables `upgrade_mode` which temporarily halts all job
and datafeed tasks and prohibits new job and datafeed tasks from
starting.'
deprecated: false
schema:
default: false
type: boolean
style: form
- in: query
name: timeout
description: The time to wait for the request to be completed.
deprecated: false
schema:
default: 30s
allOf:
- $ref: '#/components/schemas/_types.Duration'
style: form
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/_types.AcknowledgedResponseBase'
x-state: Generally available; Added in 6.7.0
x-codeSamples:
- lang: Console
source: 'POST _ml/set_upgrade_mode?enabled=true
'
- lang: Python
source: "resp = client.ml.set_upgrade_mode(\n enabled=True,\n)"
- lang: JavaScript
source: "const response = await client.ml.setUpgradeMode({\n enabled: \"true\",\n});"
- lang: Ruby
source: "response = client.ml.set_upgrade_mode(\n enabled: \"true\"\n)"
- lang: PHP
source: "$resp = $client->ml()->setUpgradeMode([\n \"enabled\" => \"true\",\n]);"
- lang: curl
source: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/set_upgrade_mode?enabled=true"'
- lang: C#
source: "var response = await client.MachineLearning\n .SetUpgradeModeAsync(d1 => d1\n .Enabled(true)\n );"
- lang: Java
source: "client.ml().setUpgradeMode(s -> s\n .enabled(true)\n);\n"
x-metaTags:
- content: Elasticsearch, Machine Learning
name: product_name
components:
schemas:
_types.NodeStatistics:
description: Contains statistics about the number of nodes selected by the request.
type: object
properties:
failures:
type: array
items:
$ref: '#/components/schemas/_types.ErrorCause'
total:
description: Total number of nodes selected by the request.
type: number
successful:
description: Number of nodes that responded successfully to the request.
type: number
failed:
description: Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response.
type: number
required:
- total
- successful
- failed
ml.get_memory_stats.JvmStats:
type: object
properties:
heap_max:
description: Maximum amount of memory available for use by the heap.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
heap_max_in_bytes:
description: Maximum amount of memory, in bytes, available for use by the heap.
type: number
java_inference:
description: Amount of Java heap currently being used for caching inference models.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
java_inference_in_bytes:
description: Amount of Java heap, in bytes, currently being used for caching inference models.
type: number
java_inference_max:
description: Maximum amount of Java heap to be used for caching inference models.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
java_inference_max_in_bytes:
description: Maximum amount of Java heap, in bytes, to be used for caching inference models.
type: number
required:
- heap_max_in_bytes
- java_inference_in_bytes
- java_inference_max_in_bytes
ml.info.Datafeeds:
type: object
properties:
scroll_size:
type: number
required:
- scroll_size
ml.get_memory_stats.MemMlStats:
type: object
properties:
anomaly_detectors:
description: Amount of native memory set aside for anomaly detection jobs.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
anomaly_detectors_in_bytes:
description: Amount of native memory, in bytes, set aside for anomaly detection jobs.
type: number
data_frame_analytics:
description: Amount of native memory set aside for data frame analytics jobs.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
data_frame_analytics_in_bytes:
description: Amount of native memory, in bytes, set aside for data frame analytics jobs.
type: number
max:
description: Maximum amount of native memory (separate to the JVM heap) that may be used by machine learning native processes.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
max_in_bytes:
description: Maximum amount of native memory (separate to the JVM heap), in bytes, that may be used by machine learning native processes.
type: number
native_code_overhead:
description: Amount of native memory set aside for loading machine learning native code shared libraries.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
native_code_overhead_in_bytes:
description: Amount of native memory, in bytes, set aside for loading machine learning native code shared libraries.
type: number
native_inference:
description: Amount of native memory set aside for trained models that have a PyTorch model_type.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
native_inference_in_bytes:
description: Amount of native memory, in bytes, set aside for trained models that have a PyTorch model_type.
type: number
required:
- anomaly_detectors_in_bytes
- data_frame_analytics_in_bytes
- max_in_bytes
- native_code_overhead_in_bytes
- native_inference_in_bytes
_types.analysis.CharFilter:
externalDocs:
url: https://www.elastic.co/docs/reference/text-analysis/character-filter-reference
x-model: true
_types.ErrorCause:
description: 'Cause and details about a request failure. This class defines the properties common to all error types.
Additional details are also provided, that depend on the error type.'
type: object
properties:
type:
description: The type of error
type: string
reason:
description: A human-readable explanation of the error, in English.
oneOf:
- type: string
- type:
- string
- 'null'
stack_trace:
description: The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
type: string
caused_by:
allOf:
- $ref: '#/components/schemas/_types.ErrorCause'
root_cause:
type: array
items:
$ref: '#/components/schemas/_types.ErrorCause'
suppressed:
type: array
items:
$ref: '#/components/schemas/_types.ErrorCause'
required:
- type
_types.TransportAddress:
type: string
ml.get_memory_stats.Memory:
type: object
properties:
attributes:
type: object
additionalProperties:
type: string
jvm:
description: Contains Java Virtual Machine (JVM) statistics for the node.
allOf:
- $ref: '#/components/schemas/ml.get_memory_stats.JvmStats'
mem:
description: Contains statistics about memory usage for the node.
allOf:
- $ref: '#/components/schemas/ml.get_memory_stats.MemStats'
name:
description: Human-readable identifier for the node. Based on the Node name setting setting.
allOf:
- $ref: '#/components/schemas/_types.Name'
roles:
description: Roles assigned to the node.
type: array
items:
type: string
transport_address:
description: The host and port where transport HTTP connections are accepted.
allOf:
- $ref: '#/components/schemas/_types.TransportAddress'
ephemeral_id:
allOf:
- $ref: '#/components/schemas/_types.Id'
required:
- attributes
- jvm
- mem
- name
- roles
- transport_address
- ephemeral_id
ml.get_memory_stats.MemStats:
type: object
properties:
adjusted_total:
description: 'If the amount of physical memory has been overridden using the es.total_memory_bytes system property
then this reports the overridden value. Otherwise it reports the same value as total.'
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
adjusted_total_in_bytes:
description: 'If the amount of physical memory has been overridden using the `es.total_memory_bytes` system property
then this reports the overridden value in bytes. Otherwise it reports the same value as `total_in_bytes`.'
type: number
total:
description: Total amount of physical memory.
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
total_in_bytes:
description: Total amount of physical memory in bytes.
type: number
ml:
description: Contains statistics about machine learning use of native memory on the node.
allOf:
- $ref: '#/components/schemas/ml.get_memory_stats.MemMlStats'
required:
- adjusted_total_in_bytes
- total_in_bytes
- ml
ml.info.AnomalyDetectors:
type: object
properties:
categorization_analyzer:
allOf:
- $ref: '#/components/schemas/ml._types.CategorizationAnalyzer'
categorization_examples_limit:
type: number
model_memory_limit:
type: string
model_snapshot_retention_days:
type: number
daily_model_snapshot_retention_after_days:
type: number
required:
- categorization_analyzer
- categorization_examples_limit
- model_memory_limit
- model_snapshot_retention_days
- daily_model_snapshot_retention_after_days
_types.VersionString:
type: string
_types.analysis.TokenFilter:
externalDocs:
url: https://www.elastic.co/docs/reference/text-analysis/token-filter-reference
x-model: true
ml.info.NativeCode:
type: object
properties:
build_hash:
type: string
version:
allOf:
- $ref: '#/components/schemas/_types.VersionString'
required:
- build_hash
- version
_types.Duration:
externalDocs:
url: https://www.elastic.co/docs/reference/elasticsearch/rest-apis/api-conventions#time-units
description: 'A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
`d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.'
type: string
_types.ByteSize:
oneOf:
- type: number
- type: string
ml.info.Defaults:
type: object
properties:
anomaly_detectors:
allOf:
- $ref: '#/components/schemas/ml.info.AnomalyDetectors'
datafeeds:
allOf:
- $ref: '#/components/schemas/ml.info.Datafeeds'
model_platform_variant:
description: 'Returns `linux-x86_64` when all ML nodes are x86, or when no ML nodes exist but the cluster is in Elastic Cloud.
Returns `platform_agnostic` otherwise.'
allOf:
- $ref: '#/components/schemas/ml.info.ModelPlatformVariant'
required:
- anomaly_detectors
- datafeeds
- model_platform_variant
ml.info.Limits:
type: object
properties:
max_single_ml_node_processors:
type: number
total_ml_processors:
type: number
max_model_memory_limit:
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
effective_max_model_memory_limit:
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
total_ml_memory:
allOf:
- $ref: '#/components/schemas/_types.ByteSize'
required:
- total_ml_memory
_types.AcknowledgedResponseBase:
type: object
properties:
acknowledged:
description: For a successful response, this value is always true. On failure, an exception is returned instead.
type: boolean
required:
- acknowledged
ml._types.CategorizationAnalyzerDefinition:
type: object
properties:
char_filter:
description: One or more character filters. In addition to the built-in character filters, other plugins can provide more character filters. If this property is not specified, no character filters are applied prior to categorization. If you are customizing some other aspect of the analyzer and you need to achieve the equivalent of `categorization_filters` (which are not permitted when some other aspect of the analyzer is customized), add them here as pattern replace character filters.
type: array
items:
$ref: '#/components/schemas/_types.analysis.CharFilter'
filter:
description: One or more token filters. In addition to the built-in token filters, other plugins can provide more token filters. If this property is not specified, no token filters are applied prior to categorization.
type: array
items:
$ref: '#/components/schemas/_types.analysis.TokenFilter'
tokenizer:
x-model: true
oneOf:
- type: object
- type: string
description: 'The name or definition of the tokenizer to use after character filters are applied. This property is compulsory if `categorization_analyzer` is specified as an object. Machine learning provides a tokenizer called `ml_standard` that tokenizes in a way that has been determined to produce good categorization results on a variety of log file formats for logs in English. If you want to use that tokenizer but change the character or token filters, specify `"tokenizer": "ml_standard"` in your `categorization_analyzer`. Additionally, the `ml_classic` tokenizer is available, which tokenizes in the same way as the non-customizable tokenizer in old versions of the product (before 6.2). `ml_classic` was the default categorization tokenizer in versions 6.2 to 7.13, so if you need categorization identical to the default for jobs created in these versions, specify `"tokenizer": "ml_classic"` in your `categorization_analyzer`.
'
externalDocs:
url: https://www.elastic.co/docs/reference/text-analysis/tokenizer-reference
description: Tokenizer reference
_types.Id:
type: string
ml._types.CategorizationAnalyzer:
oneOf:
- type: string
- $ref: '#/components/schemas/ml._types.CategorizationAnalyzerDefinition'
_types.Name:
type: string
ml.info.ModelPlatformVariant:
type: string
enum:
- linux-x86_64
- platform_agnostic
responses:
ml.get_memory_stats-200:
description: ''
content:
application/json:
schema:
type: object
properties:
_nodes:
allOf:
- $ref: '#/components/schemas/_types.NodeStatistics'
cluster_name:
allOf:
- $ref: '#/components/schemas/_types.Name'
nodes:
type: object
additionalProperties:
$ref: '#/components/schemas/ml.get_memory_stats.Memory'
required:
- _nodes
- cluster_name
- nodes
parameters:
ml.get_memory_stats-master_timeout:
in: query
name: master_timeout
description: 'Period to wait for a connection to the master node. If no response is received before the timeout
expires, the request fails and returns an error.'
deprecated: false
schema:
default: 30s
allOf:
- $ref: '#/components/schemas/_types.Duration'
style: form
ml.get_memory_stats-timeout:
in: query
name: timeout
description: 'Period to wait for a response. If no response is received before the timeout expires, the request
fails and returns an error.'
deprecated: false
schema:
default: 30s
allOf:
- $ref: '#/components/schemas/_types.Duration'
style: form
ml.get_memory_stats-node_id:
in: path
name: node_id
description: 'The names of particular nodes in the cluster to target. For example, `nodeId1,nodeId2` or
`ml:true`'
required: true
deprecated: false
schema:
$ref: '#/components/schemas/_types.Id'
style: simple
securitySchemes:
apiKeyAuth:
in: header
name: Authorization
type: apiKey
description: "Elasticsearch APIs support key-based authentication.\nYou must create an API key and use the encoded value in the request header.\nFor example:\n\n\n```\ncurl -X GET \"${ES_URL}/_cat/indices?v=true\" \\\n -H \"Authorization: ApiKey ${API_KEY}\"\n```\n\nTo get API keys, use the `/_security/api_key` APIs.\n"
basicAuth:
scheme: basic
type: http
bearerAuth:
scheme: bearer
type: http
description: 'Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)
'
x-provenance:
method: harvested
publisher: Anomaly Detection
source: https://www.elastic.co/docs/api/doc/elasticsearch/group/elasticsearch-openapi-source.json
note: split by refine-openapis from the provider's own published document, verified by fetch (openapi/_original/*.fetch.json);
stamped by stamp-openapi-provenance.py (roadmap#793)