[Infrastructure UI] Change CPU count column to CPU usage (#151696)

closes #151601 

## Summary

Swaped  '# of CPUs' for 'CPU Usage' in Hosts View

<img width="2533" alt="Screenshot 2023-02-20 at 16 59 32"
src="https://user-images.githubusercontent.com/11225826/220165618-3deb050e-ca06-4758-8fc5-ac59552e96c7.png">

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
mohamedhamed-ahmed 2023-02-21 14:47:52 +00:00 committed by GitHub
parent 9d4142aa3d
commit bd3e3feca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 45 deletions

View file

@ -6,7 +6,6 @@
*/
import { cpu } from './snapshot/cpu';
import { cpuCores } from './snapshot/cpu_cores';
import { diskLatency } from './snapshot/disk_latency';
import { count } from '../../shared/metrics/snapshot/count';
import { load } from './snapshot/load';
@ -38,7 +37,6 @@ import { InventoryMetrics } from '../../types';
const exposedHostSnapshotMetrics = {
cpu,
cpuCores,
diskLatency,
load,
logRate,

View file

@ -1,16 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { MetricsUIAggregation } from '../../../types';
export const cpuCores: MetricsUIAggregation = {
cpuCores: {
max: {
field: 'system.cpu.cores',
},
},
};

View file

@ -344,7 +344,6 @@ export type MetricsUIAggregation = rt.TypeOf<typeof MetricsUIAggregationRT>;
export const SnapshotMetricTypeKeys = {
count: null,
cpu: null,
cpuCores: null,
diskLatency: null,
load: null,
memory: null,

View file

@ -22,7 +22,7 @@ const HOST_TABLE_METRICS: Array<{ type: SnapshotMetricType }> = [
{ type: 'rx' },
{ type: 'tx' },
{ type: 'memory' },
{ type: 'cpuCores' },
{ type: 'cpu' },
{ type: 'diskLatency' },
{ type: 'memoryTotal' },
];

View file

@ -27,8 +27,8 @@ describe('useHostTable hook', () => {
avg: 0.94525,
},
{
name: 'cpuCores',
value: 10,
name: 'cpu',
value: 0.6353277777777777,
},
{
name: 'memoryTotal',
@ -53,8 +53,8 @@ describe('useHostTable hook', () => {
avg: 0.5400000214576721,
},
{
name: 'cpuCores',
value: 8,
name: 'cpu',
value: 0.8647805555555556,
},
{
name: 'memoryTotal',
@ -89,9 +89,9 @@ describe('useHostTable hook', () => {
name: 'memory',
avg: 0.94525,
},
cpuCores: {
name: 'cpuCores',
value: 10,
cpu: {
name: 'cpu',
value: 0.6353277777777777,
},
memoryTotal: {
name: 'memoryTotal',
@ -118,9 +118,9 @@ describe('useHostTable hook', () => {
name: 'memory',
avg: 0.5400000214576721,
},
cpuCores: {
name: 'cpuCores',
value: 8,
cpu: {
name: 'cpu',
value: 0.8647805555555556,
},
memoryTotal: {
name: 'memoryTotal',

View file

@ -24,7 +24,7 @@ import type {
*/
export type CloudProvider = 'gcp' | 'aws' | 'azure' | 'unknownProvider';
type HostMetric = 'cpuCores' | 'diskLatency' | 'rx' | 'tx' | 'memory' | 'memoryTotal';
type HostMetric = 'cpu' | 'diskLatency' | 'rx' | 'tx' | 'memory' | 'memoryTotal';
type HostMetrics = Record<HostMetric, SnapshotNodeMetric>;
@ -74,9 +74,12 @@ const osLabel = i18n.translate('xpack.infra.hostsViewPage.table.operatingSystemC
defaultMessage: 'Operating System',
});
const cpuCountLabel = i18n.translate('xpack.infra.hostsViewPage.table.numberOfCpusColumnHeader', {
defaultMessage: '# of CPUs',
});
const averageCpuUsageLabel = i18n.translate(
'xpack.infra.hostsViewPage.table.averageCpuUsageColumnHeader',
{
defaultMessage: 'CPU usage (avg.)',
}
);
const diskLatencyLabel = i18n.translate('xpack.infra.hostsViewPage.table.diskLatencyColumnHeader', {
defaultMessage: 'Disk Latency (avg.)',
@ -146,11 +149,10 @@ export const useHostsTable = (nodes: SnapshotNode[], { time }: HostTableParams)
render: (os: string) => <EuiText size="s">{os}</EuiText>,
},
{
name: cpuCountLabel,
field: 'cpuCores',
name: averageCpuUsageLabel,
field: 'cpu.avg',
sortable: true,
render: (cpuCores: SnapshotNodeMetric) =>
formatMetric('cpuCores', cpuCores?.value ?? cpuCores?.max),
render: (avg: number) => formatMetric('cpu', avg),
align: 'right',
},
{

View file

@ -31,10 +31,6 @@ const METRIC_FORMATTERS: MetricFormatters = {
formatter: InfraFormatterType.percent,
template: '{{value}}',
},
cpuCores: {
formatter: InfraFormatterType.number,
template: '{{value}}',
},
memory: {
formatter: InfraFormatterType.percent,
template: '{{value}}',

View file

@ -16374,7 +16374,6 @@
"xpack.infra.hostsViewPage.table.averageTxColumnHeader": "TX (moy.)",
"xpack.infra.hostsViewPage.table.diskLatencyColumnHeader": "Latence du disque (moy.)",
"xpack.infra.hostsViewPage.table.nameColumnHeader": "Nom",
"xpack.infra.hostsViewPage.table.numberOfCpusColumnHeader": "Nombre de processeurs",
"xpack.infra.hostsViewPage.table.operatingSystemColumnHeader": "Système d'exploitation",
"xpack.infra.hostsViewPage.tabs.metricsCharts.actions.openInLines": "Ouvrir dans Lens",
"xpack.infra.hostsViewPage.tabs.metricsCharts.title": "Indicateurs",

View file

@ -16359,7 +16359,6 @@
"xpack.infra.hostsViewPage.table.averageTxColumnHeader": "TX平均",
"xpack.infra.hostsViewPage.table.diskLatencyColumnHeader": "ディスクレイテンシ(平均)",
"xpack.infra.hostsViewPage.table.nameColumnHeader": "名前",
"xpack.infra.hostsViewPage.table.numberOfCpusColumnHeader": "CPU数",
"xpack.infra.hostsViewPage.table.operatingSystemColumnHeader": "オペレーティングシステム",
"xpack.infra.hostsViewPage.tabs.metricsCharts.actions.openInLines": "Lensで開く",
"xpack.infra.hostsViewPage.tabs.metricsCharts.title": "メトリック",

View file

@ -16379,7 +16379,6 @@
"xpack.infra.hostsViewPage.table.averageTxColumnHeader": "TX平均值",
"xpack.infra.hostsViewPage.table.diskLatencyColumnHeader": "磁盘延迟(平均值)",
"xpack.infra.hostsViewPage.table.nameColumnHeader": "名称",
"xpack.infra.hostsViewPage.table.numberOfCpusColumnHeader": "# 个 CPU",
"xpack.infra.hostsViewPage.table.operatingSystemColumnHeader": "操作系统",
"xpack.infra.hostsViewPage.tabs.metricsCharts.actions.openInLines": "在 Lens 中打开",
"xpack.infra.hostsViewPage.tabs.metricsCharts.title": "指标",