elastic / elastic/elasticsearch
[ML] Update Get Trained Models Statistics API to have common deployment stats between Serverless & ESS
- Dominant language
- Java
- Stars
- 77.9k
- Forks
- 26.1k
- PR merge metrics
- PR metrics pending
Description
This is an enhancement request to update the [getTrainedModelsStats API](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html#get-trained-models-stats) to have common deployment stats regardless of the environment (Serverless/ESS).
We're using the `getTrainedModelsStats` API within the Security Solution to check if the recommended version of `ELSER` is deployed and running by ensuring:
```
stats.deployment_stats?.state === 'started' &&
stats.deployment_stats?.allocation_status.state === 'fully_allocated'.
```
In working to support ELSER in Serverless I noticed the response from `getTrainedModelsStats` is a bit different, and doesn't include `deployment_stats.state` or `deployment_stats.allocation_status`.
After discussion (internal [slack](https://elastic.slack.com/archives/C2AJLJHMM/p1710159212969799?thread_ts=1709937469.619559&cid=C2AJLJHMM)) with @davidkyle, he mentioned that in Serverless all the node specific stats are filtered out, so `stats.deployment_stats.state` is lost in the process, and since `allocation_status` more strictly relates to the concept of nodes that it should remain hidden in Serverless.
It was mentioned that perhaps there should be a single state variable that is present in both stateful and serverless, and that we could potentially add `stats.deployment_stats.state` back in for Serverless.
As a workaround, for we're currently using `deployment_statsnodes[].routing_state === 'started'` for determining if the Serverless node is ready.
Contributor guide
Assessment
This issue has not been assessed yet.