Skip to content

Commit

Permalink
[APM] Show hostname in JVM view (#109651)
Browse files Browse the repository at this point in the history
* [APM] Show hostname in JVM view

* [APM] delete no needed param

* [APM] fix linting

* [APM] changes after review

* [APM] changes after review part deux

* [APM] fix snapshot

* [APM] improve guard on api response
  • Loading branch information
MiriamAparicio authored Aug 26, 2021
1 parent 9c922a0 commit 652470b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { EuiToolTip } from '@elastic/eui';
import { EuiToolTip, EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common';
Expand Down Expand Up @@ -78,6 +78,12 @@ function ServiceNodeOverview() {
{i18n.translate('xpack.apm.jvmsTable.nameColumnLabel', {
defaultMessage: 'Name',
})}
<EuiIcon
size="s"
color="subdued"
type="questionInCircle"
className="eui-alignTop"
/>
</>
</EuiToolTip>
),
Expand Down Expand Up @@ -110,11 +116,20 @@ function ServiceNodeOverview() {
);
},
},
{
name: i18n.translate('xpack.apm.jvmsTable.hostName', {
defaultMessage: 'Host name',
}),
field: 'hostName',
sortable: true,
render: (_, { hostName }) => hostName ?? '',
},
{
name: i18n.translate('xpack.apm.jvmsTable.cpuColumnLabel', {
defaultMessage: 'CPU avg',
}),
field: 'cpu',
dataType: 'number',
sortable: true,
render: (_, { cpu }) => asPercent(cpu, 1),
},
Expand All @@ -123,6 +138,7 @@ function ServiceNodeOverview() {
defaultMessage: 'Heap memory avg',
}),
field: 'heapMemory',
dataType: 'number',
sortable: true,
render: asDynamicBytes,
},
Expand All @@ -131,6 +147,7 @@ function ServiceNodeOverview() {
defaultMessage: 'Non-heap memory avg',
}),
field: 'nonHeapMemory',
dataType: 'number',
sortable: true,
render: asDynamicBytes,
},
Expand All @@ -139,6 +156,7 @@ function ServiceNodeOverview() {
defaultMessage: 'Thread count max',
}),
field: 'threadCount',
dataType: 'number',
sortable: true,
render: asInteger,
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions x-pack/plugins/apm/server/lib/service_nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
METRIC_JAVA_NON_HEAP_MEMORY_USED,
METRIC_JAVA_THREAD_COUNT,
METRIC_PROCESS_CPU_PERCENT,
HOST_NAME,
} from '../../../common/elasticsearch_fieldnames';
import { SERVICE_NODE_NAME_MISSING } from '../../../common/service_nodes';
import { asMutableArray } from '../../../common/utils/as_mutable_array';
import { getServiceNodesProjection } from '../../projections/service_nodes';
import { mergeProjection } from '../../projections/util/merge_projection';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
Expand Down Expand Up @@ -46,6 +48,14 @@ const getServiceNodes = async ({
missing: SERVICE_NODE_NAME_MISSING,
},
aggs: {
latest: {
top_metrics: {
metrics: asMutableArray([{ field: HOST_NAME }] as const),
sort: {
'@timestamp': 'desc',
},
},
},
cpu: {
avg: {
field: METRIC_PROCESS_CPU_PERCENT,
Expand Down Expand Up @@ -83,6 +93,10 @@ const getServiceNodes = async ({
name: bucket.key as string,
cpu: bucket.cpu.value,
heapMemory: bucket.heapMemory.value,
hostName: bucket.latest.top?.[0]?.metrics?.['host.hostname'] as
| string
| null
| undefined,
nonHeapMemory: bucket.nonHeapMemory.value,
threadCount: bucket.threadCount.value,
}))
Expand Down

0 comments on commit 652470b

Please sign in to comment.