mirror of
https://github.com/skooner-k8s/skooner.git
synced 2026-05-22 07:32:49 +00:00
Merge pull request #266 from idevera/idevera/246
246: Display chart for each pod
This commit is contained in:
@@ -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<Metrics>}) {
|
||||
export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary<Metrics>, 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',
|
||||
|
||||
@@ -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<Metrics>}) {
|
||||
export default function RamChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary<Metrics>, 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',
|
||||
|
||||
@@ -82,8 +82,8 @@ export default class PodView extends Base<Props, State> {
|
||||
{errors && !!errors.length && <Error messages={errors} />}
|
||||
|
||||
<ChartsContainer>
|
||||
<PodCpuChart items={item && [item]} metrics={filteredMetrics} />
|
||||
<PodRamChart items={item && [item]} metrics={filteredMetrics} />
|
||||
<PodCpuChart items={item && [item]} metrics={filteredMetrics} pod={item}/>
|
||||
<PodRamChart items={item && [item]} metrics={filteredMetrics} pod={item}/>
|
||||
</ChartsContainer>
|
||||
|
||||
<div className='contentPanel'>
|
||||
|
||||
Reference in New Issue
Block a user