Skip to content

Commit

Permalink
[Metrics UI] Use CPU Usage limits for Kubernetes pods when available (#…
Browse files Browse the repository at this point in the history
…58424) (#58906)

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
simianhacker and elasticmachine authored Mar 2, 2020
1 parent 65fb3a8 commit 836c5e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
},
],
Expand Down

0 comments on commit 836c5e3

Please sign in to comment.