/
index.ts
72 lines (68 loc) · 2.02 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
import {
METRIC_JAVA_HEAP_MEMORY_MAX,
METRIC_JAVA_HEAP_MEMORY_COMMITTED,
METRIC_JAVA_HEAP_MEMORY_USED,
SERVICE_AGENT_NAME
} from '../../../../../../common/elasticsearch_fieldnames';
import { Setup } from '../../../../helpers/setup_request';
import { fetchAndTransformMetrics } from '../../../fetch_and_transform_metrics';
import { ChartBase } from '../../../types';
const series = {
heapMemoryUsed: {
title: i18n.translate('xpack.apm.agentMetrics.java.heapMemorySeriesUsed', {
defaultMessage: 'Avg. used'
}),
color: theme.euiColorVis0
},
heapMemoryCommitted: {
title: i18n.translate(
'xpack.apm.agentMetrics.java.heapMemorySeriesCommitted',
{
defaultMessage: 'Avg. committed'
}
),
color: theme.euiColorVis1
},
heapMemoryMax: {
title: i18n.translate('xpack.apm.agentMetrics.java.heapMemorySeriesMax', {
defaultMessage: 'Avg. limit'
}),
color: theme.euiColorVis2
}
};
const chartBase: ChartBase = {
title: i18n.translate('xpack.apm.agentMetrics.java.heapMemoryChartTitle', {
defaultMessage: 'Heap Memory'
}),
key: 'heap_memory_area_chart',
type: 'area',
yUnit: 'bytes',
series
};
export async function getHeapMemoryChart(
setup: Setup,
serviceName: string,
serviceNodeName?: string
) {
return fetchAndTransformMetrics({
setup,
serviceName,
serviceNodeName,
chartBase,
aggs: {
heapMemoryMax: { avg: { field: METRIC_JAVA_HEAP_MEMORY_MAX } },
heapMemoryCommitted: {
avg: { field: METRIC_JAVA_HEAP_MEMORY_COMMITTED }
},
heapMemoryUsed: { avg: { field: METRIC_JAVA_HEAP_MEMORY_USED } }
},
additionalFilters: [{ term: { [SERVICE_AGENT_NAME]: 'java' } }]
});
}