[8.x] [ML] Trained Models: Show deployment stats for unallocated deployments (#202005) (#202168)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Trained Models: Show deployment stats for unallocated
deployments (#202005)](https://github.com/elastic/kibana/pull/202005)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"dmitrii.arnautov@elastic.co"},"sourceCommit":{"committedDate":"2024-11-28T13:22:31Z","message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Feature:3rd
Party
Models","Team:ML","ci:cloud-deploy","backport:version","v8.17.0","v8.18.0","v8.16.2"],"title":"[ML]
Trained Models: Show deployment stats for unallocated deployments
","number":202005,"url":"https://github.com/elastic/kibana/pull/202005","mergeCommit":{"message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202005","number":202005,"mergeCommit":{"message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
Kibana Machine 2024-11-29 02:15:41 +11:00 committed by GitHub
parent 2850e29c40
commit b3ec87c71b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 7 deletions

View file

@ -193,6 +193,7 @@ export interface AllocatedModel {
*/
model_id?: string;
state: string;
reason?: string;
model_size_bytes: number;
required_native_memory_bytes: number;
node: {

View file

@ -57,15 +57,17 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
{
width: '8%',
name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.modelRoutingStateHeader', {
defaultMessage: 'Routing state',
defaultMessage: 'State',
}),
'data-test-subj': 'mlAllocatedModelsTableRoutingState',
render: (v: AllocatedModel) => {
const { routing_state: routingState, reason } = v.node.routing_state;
const isFailed = routingState === 'failed';
return (
<EuiToolTip content={reason ? reason : ''}>
<EuiBadge color={reason ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
<EuiBadge color={isFailed ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
</EuiToolTip>
);
},
@ -252,7 +254,7 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
}),
'data-test-subj': 'mlAllocatedModelsTableStartedTime',
render: (v: AllocatedModel) => {
return dateFormatter(v.node.start_time);
return v.node.start_time ? dateFormatter(v.node.start_time) : '-';
},
},
{

View file

@ -169,13 +169,40 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
license_level,
]);
const deploymentStatItems: AllocatedModel[] = useMemo<AllocatedModel[]>(() => {
const deploymentStatItems = useMemo<AllocatedModel[]>(() => {
const deploymentStats = stats.deployment_stats;
const modelSizeStats = stats.model_size_stats;
if (!deploymentStats || !modelSizeStats) return [];
const items: AllocatedModel[] = deploymentStats.flatMap((perDeploymentStat) => {
return deploymentStats.flatMap((perDeploymentStat) => {
// A deployment can be in a starting state and not allocated to any node yet.
if (perDeploymentStat.nodes.length < 1) {
return [
{
key: `${perDeploymentStat.deployment_id}_no_node`,
...perDeploymentStat,
...modelSizeStats,
node: {
name: '-',
average_inference_time_ms: 0,
inference_count: 0,
routing_state: {
routing_state: perDeploymentStat.state,
reason: perDeploymentStat.reason,
},
last_access: 0,
number_of_pending_requests: 0,
start_time: 0,
throughput_last_minute: 0,
number_of_allocations: 0,
threads_per_allocation: 0,
error_count: 0,
},
},
];
}
return perDeploymentStat.nodes.map((n) => {
const nodeName = Object.values(n.node)[0].name;
return {
@ -200,8 +227,6 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
};
});
});
return items;
}, [stats]);
const hideColumns = useMemo(() => {