[Metrics UI] Use CPU Usage limits for Kubernetes pods when available (#58424)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Chris Cowan 2020-02-28 09:42:52 -07:00 committed by GitHub
parent 2b9dc43158
commit 29fbe395b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View file

@ -7,9 +7,27 @@
import { SnapshotModel } from '../../../types';
export const cpu: SnapshotModel = {
cpu: {
cpu_with_limit: {
avg: {
field: 'kubernetes.pod.cpu.usage.limit.pct',
},
},
cpu_without_limit: {
avg: {
field: 'kubernetes.pod.cpu.usage.node.pct',
},
},
cpu: {
bucket_script: {
buckets_path: {
with_limit: 'cpu_with_limit',
without_limit: 'cpu_without_limit',
},
script: {
source: 'params.with_limit > 0.0 ? params.with_limit : params.without_limit',
lang: 'painless',
},
gap_policy: 'skip',
},
},
};

View file

@ -24,9 +24,23 @@ export const podCpuUsage: TSVBMetricModelCreator = (
metrics: [
{
field: 'kubernetes.pod.cpu.usage.node.pct',
id: 'avg-cpu-usage',
id: 'avg-cpu-without',
type: 'avg',
},
{
field: 'kubernetes.pod.cpu.usage.limit.pct',
id: 'avg-cpu-with',
type: 'avg',
},
{
id: 'cpu-usage',
type: 'calculation',
variables: [
{ id: 'cpu_with', name: 'with_limit', field: 'avg-cpu-with' },
{ id: 'cpu_without', name: 'without_limit', field: 'avg-cpu-without' },
],
script: 'params.with_limit > 0.0 ? params.with_limit : params.without_limit',
},
],
},
],