From 5a1472fb8a66846df9ead386157838d1be0916a0 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Wed, 6 Oct 2021 01:42:30 +0200 Subject: [PATCH] Add more file system metrics to the pod and container graphs Signed-off-by: Marc Bachmann --- src/common/k8s-api/endpoints/daemon-set.api.ts | 2 ++ src/common/k8s-api/endpoints/deployment.api.ts | 2 ++ src/common/k8s-api/endpoints/job.api.ts | 2 ++ src/common/k8s-api/endpoints/metrics.api.ts | 2 ++ src/common/k8s-api/endpoints/namespaces.api.ts | 2 ++ src/common/k8s-api/endpoints/pods.api.ts | 6 +++++- src/common/k8s-api/endpoints/replica-set.api.ts | 2 ++ src/common/k8s-api/endpoints/stateful-set.api.ts | 2 ++ src/main/prometheus/lens.ts | 4 ++++ src/main/prometheus/operator.ts | 4 ++++ src/main/prometheus/stacklight.ts | 4 ++++ .../+workloads-pods/container-charts.tsx | 16 ++++++++++++++++ .../components/+workloads-pods/pod-charts.tsx | 16 ++++++++++++++++ 13 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/common/k8s-api/endpoints/daemon-set.api.ts b/src/common/k8s-api/endpoints/daemon-set.api.ts index 44c99a13b8d6..7c5717ae10be 100644 --- a/src/common/k8s-api/endpoints/daemon-set.api.ts +++ b/src/common/k8s-api/endpoints/daemon-set.api.ts @@ -110,6 +110,8 @@ export function getMetricsForDaemonSets(daemonsets: DaemonSet[], namespace: stri cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/common/k8s-api/endpoints/deployment.api.ts b/src/common/k8s-api/endpoints/deployment.api.ts index f4d82c64b317..a59cdb8b31d6 100644 --- a/src/common/k8s-api/endpoints/deployment.api.ts +++ b/src/common/k8s-api/endpoints/deployment.api.ts @@ -83,6 +83,8 @@ export function getMetricsForDeployments(deployments: Deployment[], namespace: s cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/common/k8s-api/endpoints/job.api.ts b/src/common/k8s-api/endpoints/job.api.ts index 4907e6c7960f..8f96d8b15eda 100644 --- a/src/common/k8s-api/endpoints/job.api.ts +++ b/src/common/k8s-api/endpoints/job.api.ts @@ -133,6 +133,8 @@ export function getMetricsForJobs(jobs: Job[], namespace: string, selector = "") cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/common/k8s-api/endpoints/metrics.api.ts b/src/common/k8s-api/endpoints/metrics.api.ts index 91587bff9776..bd6bc4709cf2 100644 --- a/src/common/k8s-api/endpoints/metrics.api.ts +++ b/src/common/k8s-api/endpoints/metrics.api.ts @@ -65,6 +65,8 @@ export interface IResourceMetrics { cpuUsage: T; memoryUsage: T; fsUsage: T; + fsWrites: T; + fsReads: T; networkReceive: T; networkTransmit: T; } diff --git a/src/common/k8s-api/endpoints/namespaces.api.ts b/src/common/k8s-api/endpoints/namespaces.api.ts index 08e95933996c..7a3a360ce064 100644 --- a/src/common/k8s-api/endpoints/namespaces.api.ts +++ b/src/common/k8s-api/endpoints/namespaces.api.ts @@ -63,6 +63,8 @@ export function getMetricsForNamespace(namespace: string, selector = ""): Promis cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/common/k8s-api/endpoints/pods.api.ts b/src/common/k8s-api/endpoints/pods.api.ts index 361e72ca54cb..2c1bfdc6e862 100644 --- a/src/common/k8s-api/endpoints/pods.api.ts +++ b/src/common/k8s-api/endpoints/pods.api.ts @@ -46,6 +46,8 @@ export function getMetricsForPods(pods: Pod[], namespace: string, selector = "po memoryRequests: opts, memoryLimits: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { @@ -57,7 +59,9 @@ export interface IPodMetrics { [metric: string]: T; cpuUsage: T; memoryUsage: T; - fsUsage: T; + fsUsage: T, + fsWrites: T, + fsReads: T, networkReceive: T; networkTransmit: T; cpuRequests?: T; diff --git a/src/common/k8s-api/endpoints/replica-set.api.ts b/src/common/k8s-api/endpoints/replica-set.api.ts index 7a9a76ec060f..50240621740b 100644 --- a/src/common/k8s-api/endpoints/replica-set.api.ts +++ b/src/common/k8s-api/endpoints/replica-set.api.ts @@ -59,6 +59,8 @@ export function getMetricsForReplicaSets(replicasets: ReplicaSet[], namespace: s cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/common/k8s-api/endpoints/stateful-set.api.ts b/src/common/k8s-api/endpoints/stateful-set.api.ts index dd97e01e0570..1a844da7e407 100644 --- a/src/common/k8s-api/endpoints/stateful-set.api.ts +++ b/src/common/k8s-api/endpoints/stateful-set.api.ts @@ -62,6 +62,8 @@ export function getMetricsForStatefulSets(statefulSets: StatefulSet[], namespace cpuUsage: opts, memoryUsage: opts, fsUsage: opts, + fsWrites: opts, + fsReads: opts, networkReceive: opts, networkTransmit: opts, }, { diff --git a/src/main/prometheus/lens.ts b/src/main/prometheus/lens.ts index 7cd79232388a..21e06c1b031e 100644 --- a/src/main/prometheus/lens.ts +++ b/src/main/prometheus/lens.ts @@ -124,6 +124,10 @@ export class PrometheusLens extends PrometheusProvider { return `sum(kube_pod_container_resource_limits{pod=~"${opts.pods}",resource="memory",namespace="${opts.namespace}"}) by (${opts.selector})`; case "fsUsage": return `sum(container_fs_usage_bytes{container!="POD",container!="",pod=~"${opts.pods}",namespace="${opts.namespace}"}) by (${opts.selector})`; + case "fsWrites": + return `sum(rate(container_fs_writes_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; + case "fsReads": + return `sum(rate(container_fs_reads_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkReceive": return `sum(rate(container_network_receive_bytes_total{pod=~"${opts.pods}",namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkTransmit": diff --git a/src/main/prometheus/operator.ts b/src/main/prometheus/operator.ts index 6fb2cb5cc6a2..00c5adf6da0e 100644 --- a/src/main/prometheus/operator.ts +++ b/src/main/prometheus/operator.ts @@ -109,6 +109,10 @@ export class PrometheusOperator extends PrometheusProvider { return `sum(kube_pod_container_resource_limits{pod=~"${opts.pods}", resource="memory", namespace="${opts.namespace}"}) by (${opts.selector})`; case "fsUsage": return `sum(container_fs_usage_bytes{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}) by (${opts.selector})`; + case "fsWrites": + return `sum(rate(container_fs_writes_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; + case "fsReads": + return `sum(rate(container_fs_reads_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkReceive": return `sum(rate(container_network_receive_bytes_total{pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkTransmit": diff --git a/src/main/prometheus/stacklight.ts b/src/main/prometheus/stacklight.ts index 7d2c07134d45..9c7c207a0f0e 100644 --- a/src/main/prometheus/stacklight.ts +++ b/src/main/prometheus/stacklight.ts @@ -124,6 +124,10 @@ export class PrometheusStacklight extends PrometheusProvider { return `sum(kube_pod_container_resource_limits{pod=~"${opts.pods}",resource="memory",namespace="${opts.namespace}"}) by (${opts.selector})`; case "fsUsage": return `sum(container_fs_usage_bytes{container!="POD",container!="",pod=~"${opts.pods}",namespace="${opts.namespace}"}) by (${opts.selector})`; + case "fsWrites": + return `sum(rate(container_fs_writes_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; + case "fsReads": + return `sum(rate(container_fs_reads_bytes_total{container!="", pod=~"${opts.pods}", namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkReceive": return `sum(rate(container_network_receive_bytes_total{pod=~"${opts.pods}",namespace="${opts.namespace}"}[${this.rateAccuracy}])) by (${opts.selector})`; case "networkTransmit": diff --git a/src/renderer/components/+workloads-pods/container-charts.tsx b/src/renderer/components/+workloads-pods/container-charts.tsx index 3e5d0dd583c9..68da9bd99a4e 100644 --- a/src/renderer/components/+workloads-pods/container-charts.tsx +++ b/src/renderer/components/+workloads-pods/container-charts.tsx @@ -46,6 +46,8 @@ export const ContainerCharts = observer(() => { memoryRequests, memoryLimits, fsUsage, + fsWrites, + fsReads } = mapValues(metrics, metric => normalizeMetrics(metric).data.result[0].values); const datasets = [ @@ -106,6 +108,20 @@ export const ContainerCharts = observer(() => { borderColor: "#ffc63d", data: fsUsage.map(([x, y]) => ({ x, y })), }, + { + id: "fsWrites", + label: `Writes`, + tooltip: `Bytes written on this filesystem`, + borderColor: "#ff963d", + data: fsWrites.map(([x, y]) => ({ x, y })), + }, + { + id: "fsReads", + label: `Reads`, + tooltip: `Bytes read on this filesystem`, + borderColor: "#fff73d", + data: fsReads.map(([x, y]) => ({ x, y })), + }, ], ]; diff --git a/src/renderer/components/+workloads-pods/pod-charts.tsx b/src/renderer/components/+workloads-pods/pod-charts.tsx index a41219cc2e5f..db88e56dd0f6 100644 --- a/src/renderer/components/+workloads-pods/pod-charts.tsx +++ b/src/renderer/components/+workloads-pods/pod-charts.tsx @@ -51,6 +51,8 @@ export const PodCharts = observer(() => { cpuUsage, memoryUsage, fsUsage, + fsWrites, + fsReads, networkReceive, networkTransmit, } = mapValues(metrics, metric => normalizeMetrics(metric).data.result[0].values); @@ -102,6 +104,20 @@ export const PodCharts = observer(() => { borderColor: "#ffc63d", data: fsUsage.map(([x, y]) => ({ x, y })), }, + { + id: `${id}-fsWrites`, + label: `Writes`, + tooltip: `Bytes written on this filesystem`, + borderColor: "#ff963d", + data: fsWrites.map(([x, y]) => ({ x, y })), + }, + { + id: `${id}-fsReads`, + label: `Reads`, + tooltip: `Bytes read on this filesystem`, + borderColor: "#fff73d", + data: fsReads.map(([x, y]) => ({ x, y })), + }, ], ];