From a035eeb83614cf95ca4e586a5fb45beb8a43221e Mon Sep 17 00:00:00 2001 From: Irene DeVera Date: Wed, 25 Aug 2021 13:38:13 -0700 Subject: [PATCH 1/3] 246: Update chart to reflect current pod cpu resources Signed-off-by: Irene DeVera --- client/src/components/podCpuChart.tsx | 8 ++++++-- client/src/views/pod.tsx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/components/podCpuChart.tsx b/client/src/components/podCpuChart.tsx index 722b3fb..d548d2d 100644 --- a/client/src/components/podCpuChart.tsx +++ b/client/src/components/podCpuChart.tsx @@ -6,11 +6,15 @@ import {parseCpu, TO_ONE_CPU} from '../utils/unitHelpers'; import {Pod, Metrics} from '../utils/types'; import PrometheusGraph from '../views/prometheusgraph'; -export default function PodCpuChart({items, metrics}: {items?: Pod[], metrics?: _.Dictionary}) { +export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { const totals = getPodCpuTotals(items, metrics); // const decimals = totals && totals.used > 10 ? 1 : 2; + + const defaultLabels = "unit='core', resource='cpu'"; + const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const query = { - queryString: 'sum(kube_pod_container_resource_requests{unit="core", resource="cpu"})', + queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}})`, title: 'Pod CPU Usage', yAxisMin: 0, yAxisUnit: 'CPU', diff --git a/client/src/views/pod.tsx b/client/src/views/pod.tsx index b7eea89..0183c01 100644 --- a/client/src/views/pod.tsx +++ b/client/src/views/pod.tsx @@ -82,7 +82,7 @@ export default class PodView extends Base { {errors && !!errors.length && } - + From cb09c76c57763b327afb2905ee82ed41b76f4703 Mon Sep 17 00:00:00 2001 From: Irene DeVera Date: Wed, 25 Aug 2021 14:15:07 -0700 Subject: [PATCH 2/3] 246: Update Ram chart for each pod Signed-off-by: Irene DeVera --- client/src/components/podRamChart.tsx | 7 +++++-- client/src/views/pod.tsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/podRamChart.tsx b/client/src/components/podRamChart.tsx index f9fe6f7..3ce3160 100644 --- a/client/src/components/podRamChart.tsx +++ b/client/src/components/podRamChart.tsx @@ -5,11 +5,14 @@ import {parseRam, TO_GB} from '../utils/unitHelpers'; import {Pod, Metrics} from '../utils/types'; import PrometheusGraph from '../views/prometheusgraph'; -export default function RamChart({items, metrics}: {items?: Pod[], metrics?: _.Dictionary}) { +export default function RamChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { const totals = getPodRamTotals(items, metrics); + const defaultLabels = "unit='byte'"; + const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const query = { - queryString: `sum(kube_pod_container_resource_requests{unit="byte"}/${TO_GB})`, + queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}}/${TO_GB})`, title: 'Pod Memory Usage', yAxisMin: 0, yAxisUnit: 'GiB', diff --git a/client/src/views/pod.tsx b/client/src/views/pod.tsx index 0183c01..595a2fc 100644 --- a/client/src/views/pod.tsx +++ b/client/src/views/pod.tsx @@ -83,7 +83,7 @@ export default class PodView extends Base { - +
From 739f01dcdb2a3ee7835ceb1cc443b4004f09c640 Mon Sep 17 00:00:00 2001 From: Irene DeVera Date: Thu, 26 Aug 2021 09:52:51 -0700 Subject: [PATCH 3/3] 244: Update replica cup and memory usage Signed-off-by: Irene DeVera --- client/src/components/podCpuChart.tsx | 8 +++----- client/src/components/podRamChart.tsx | 6 +++--- client/src/views/pod.tsx | 4 ++-- client/src/views/replicaSet.tsx | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/client/src/components/podCpuChart.tsx b/client/src/components/podCpuChart.tsx index d548d2d..974284c 100644 --- a/client/src/components/podCpuChart.tsx +++ b/client/src/components/podCpuChart.tsx @@ -3,15 +3,14 @@ import React from 'react'; // import Chart from './chart'; import LoadingChart from './loadingChart'; import {parseCpu, TO_ONE_CPU} from '../utils/unitHelpers'; -import {Pod, Metrics} from '../utils/types'; +import {Pod, Metrics, ReplicaSet} from '../utils/types'; import PrometheusGraph from '../views/prometheusgraph'; -export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { +export default function PodCpuChart({items, metrics, item}: {items?: Pod[], metrics?: _.Dictionary, item?: Pod | ReplicaSet}) { const totals = getPodCpuTotals(items, metrics); // const decimals = totals && totals.used > 10 ? 1 : 2; - const defaultLabels = "unit='core', resource='cpu'"; - const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const labelMatchers = item ? `${defaultLabels}, pod="${item.metadata.name}"` : defaultLabels; const query = { queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}})`, @@ -45,7 +44,6 @@ export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metri function getPodCpuTotals(pods?: Pod[], metrics?: _.Dictionary) { if (!pods || !metrics) return null; - const used = _(metrics) .flatMap(x => x.containers) .sumBy(x => parseCpu(x.usage.cpu)); diff --git a/client/src/components/podRamChart.tsx b/client/src/components/podRamChart.tsx index 3ce3160..0cc63d4 100644 --- a/client/src/components/podRamChart.tsx +++ b/client/src/components/podRamChart.tsx @@ -2,14 +2,14 @@ import _ from 'lodash'; import React from 'react'; import LoadingChart from './loadingChart'; import {parseRam, TO_GB} from '../utils/unitHelpers'; -import {Pod, Metrics} from '../utils/types'; +import {Pod, Metrics, ReplicaSet} from '../utils/types'; import PrometheusGraph from '../views/prometheusgraph'; -export default function RamChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { +export default function RamChart({items, metrics, item}: {items?: Pod[], metrics?: _.Dictionary, item?: Pod | ReplicaSet}) { const totals = getPodRamTotals(items, metrics); const defaultLabels = "unit='byte'"; - const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const labelMatchers = item ? `${defaultLabels}, pod="${item.metadata.name}"` : defaultLabels; const query = { queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}}/${TO_GB})`, diff --git a/client/src/views/pod.tsx b/client/src/views/pod.tsx index 595a2fc..230d7ba 100644 --- a/client/src/views/pod.tsx +++ b/client/src/views/pod.tsx @@ -82,8 +82,8 @@ export default class PodView extends Base { {errors && !!errors.length && } - - + +
diff --git a/client/src/views/replicaSet.tsx b/client/src/views/replicaSet.tsx index 35e93b4..bd31289 100644 --- a/client/src/views/replicaSet.tsx +++ b/client/src/views/replicaSet.tsx @@ -87,8 +87,8 @@ export default class ReplicaSetView extends Base { - - + +