Skip to content

Commit

Permalink
[Metrics] Display node details metrics for kubernetes containers (#13…
Browse files Browse the repository at this point in the history
…5585)

* display cpu metrics for kubernetes containers

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* container k8s memory usage

* naming

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* remove unused types

* simplify cpu avg

* node > limit

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
klacabane and kibanamachine authored Jul 7, 2022
1 parent 7db0773 commit d4139a1
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export const container: InventoryModel = {
'containerNetworkTraffic',
'containerDiskIOBytes',
'containerDiskIOOps',
'containerK8sOverview',
'containerK8sCpuUsage',
'containerK8sMemoryUsage',
],
tooltipMetrics: ['cpu', 'memory', 'rx', 'tx'],
};
65 changes: 65 additions & 0 deletions x-pack/plugins/infra/common/inventory_models/container/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,35 @@ export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPr
metrics={metrics}
onChangeRangeTime={onChangeRangeTime}
>
<SubSection id="containerK8sOverview">
<GaugesSectionVis
seriesOverrides={{
cpu: {
name: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.cpuUsageSeriesLabel',
{
defaultMessage: 'CPU Usage',
}
),
color: theme.eui.euiColorFullShade,
formatter: 'percent',
gaugeMax: 1,
},
memory: {
name: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.memoryUsageSeriesLabel',
{
defaultMessage: 'Memory Usage',
}
),
color: theme.eui.euiColorFullShade,
formatter: 'percent',
gaugeMax: 1,
},
}}
/>
</SubSection>

<SubSection id="containerOverview">
<GaugesSectionVis
seriesOverrides={{
Expand Down Expand Up @@ -93,6 +122,42 @@ export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPr
}}
/>
</SubSection>
<SubSection
id="containerK8sCpuUsage"
label={i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.cpuUsageSection.sectionLabel',
{
defaultMessage: 'CPU Usage',
}
)}
>
<ChartSectionVis
stacked={true}
type="area"
formatter="percent"
seriesOverrides={{
cpu: { color: theme.eui.euiColorVis1 },
}}
/>
</SubSection>
<SubSection
id="containerK8sMemoryUsage"
label={i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.memoryUsageSection.sectionLabel',
{
defaultMessage: 'Memory Usage',
}
)}
>
<ChartSectionVis
stacked={true}
type="area"
formatter="percent"
seriesOverrides={{
memory: { color: theme.eui.euiColorVis1 },
}}
/>
</SubSection>
<SubSection
id="containerCpuUsage"
label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { containerDiskIOOps } from './tsvb/container_diskio_ops';
import { containerDiskIOBytes } from './tsvb/container_disk_io_bytes';
import { containerMemory } from './tsvb/container_memory';
import { containerNetworkTraffic } from './tsvb/container_network_traffic';
import { containerK8sOverview } from './tsvb/container_k8s_overview';
import { containerK8sCpuUsage } from './tsvb/container_k8s_cpu_usage';
import { containerK8sMemoryUsage } from './tsvb/container_k8s_memory_usage';

export const metrics: InventoryMetrics = {
tsvb: {
Expand All @@ -28,6 +31,9 @@ export const metrics: InventoryMetrics = {
containerDiskIOBytes,
containerNetworkTraffic,
containerMemory,
containerK8sCpuUsage,
containerK8sOverview,
containerK8sMemoryUsage,
},
snapshot: { cpu, memory, rx, tx },
defaultSnapshot: 'cpu',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const containerK8sCpuUsage: TSVBMetricModelCreator = (
timeField,
indexPattern,
interval
): TSVBMetricModel => ({
id: 'containerK8sCpuUsage',
requires: ['kubernetes.container'],
index_pattern: indexPattern,
interval,
time_field: timeField,
type: 'timeseries',
series: [
{
id: 'cpu',
split_mode: 'everything',
metrics: [
{
field: 'kubernetes.container.cpu.usage.limit.pct',
id: 'avg-cpu',
type: 'avg',
},
],
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const containerK8sMemoryUsage: TSVBMetricModelCreator = (
timeField,
indexPattern,
interval
): TSVBMetricModel => ({
id: 'containerK8sMemoryUsage',
requires: ['kubernetes.container'],
index_pattern: indexPattern,
interval,
time_field: timeField,
type: 'timeseries',
series: [
{
id: 'memory',
split_mode: 'everything',
metrics: [
{
field: 'kubernetes.container.memory.usage.limit.pct',
id: 'avg-memory',
type: 'avg',
},
],
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const containerK8sOverview: TSVBMetricModelCreator = (
timeField,
indexPattern,
interval
): TSVBMetricModel => ({
id: 'containerK8sOverview',
requires: ['kubernetes.container'],
index_pattern: indexPattern,
interval,
time_field: timeField,
type: 'timeseries',
series: [
{
id: 'cpu',
split_mode: 'everything',
metrics: [
{
field: 'kubernetes.container.cpu.usage.limit.pct',
id: 'avg-cpu-total',
type: 'avg',
},
],
},
{
id: 'memory',
split_mode: 'everything',
metrics: [
{
field: 'kubernetes.container.memory.usage.limit.pct',
id: 'avg-memory-total',
type: 'avg',
},
],
},
],
});
3 changes: 3 additions & 0 deletions x-pack/plugins/infra/common/inventory_models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const InventoryMetricRT = rt.keyof({
containerDiskIOBytes: null,
containerMemory: null,
containerNetworkTraffic: null,
containerK8sOverview: null,
containerK8sCpuUsage: null,
containerK8sMemoryUsage: null,
nginxHits: null,
nginxRequestRate: null,
nginxActiveConnections: null,
Expand Down

0 comments on commit d4139a1

Please sign in to comment.