diff --git a/packages/core/src/common/cluster-types.ts b/packages/core/src/common/cluster-types.ts index a8ce7da9125c..cd4f89d51c8a 100644 --- a/packages/core/src/common/cluster-types.ts +++ b/packages/core/src/common/cluster-types.ts @@ -125,6 +125,7 @@ export interface ClusterPrometheusPreferences { prometheusProvider?: { type: string; }; + filesystemMountpoints?: string; } /** diff --git a/packages/core/src/main/routes/metrics/add-metrics-route.injectable.ts b/packages/core/src/main/routes/metrics/add-metrics-route.injectable.ts index bc0071431b9b..eaf6dba4cd18 100644 --- a/packages/core/src/main/routes/metrics/add-metrics-route.injectable.ts +++ b/packages/core/src/main/routes/metrics/add-metrics-route.injectable.ts @@ -69,6 +69,7 @@ const addMetricsRouteInjectable = getRouteInjectable({ const queryParams: Partial> = Object.fromEntries(query.entries()); const prometheusMetadata: ClusterPrometheusMetadata = {}; const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster); + const mountpoints = cluster.preferences.filesystemMountpoints || "/"; try { const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails(); @@ -99,7 +100,7 @@ const addMetricsRouteInjectable = getRouteInjectable({ const data = payload as Record>; const queries = object.entries(data) .map(([queryName, queryOpts]) => ( - provider.getQuery(queryOpts, queryName) + provider.getQuery({ ...queryOpts, mountpoints }, queryName) )); const result = await loadMetrics(queries, cluster, prometheusPath, queryParams); diff --git a/packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx b/packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx index 011107101f06..0597752c3868 100644 --- a/packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx +++ b/packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx @@ -32,6 +32,7 @@ interface Dependencies { @observer class NonInjectedClusterPrometheusSetting extends React.Component { + @observable mountpoints = ""; @observable path = ""; @observable selectedOption: ProviderValue = autoDetectPrometheus; @observable loading = true; @@ -68,7 +69,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component { - const { prometheus, prometheusProvider } = this.props.cluster.preferences; + const { prometheus, prometheusProvider, filesystemMountpoints } = this.props.cluster.preferences; if (prometheus) { const prefix = prometheus.prefix || ""; @@ -83,6 +84,10 @@ class NonInjectedClusterPrometheusSetting extends React.Component { + this.props.cluster.preferences.filesystemMountpoints = this.mountpoints; + }; + render() { return ( <> @@ -165,6 +174,22 @@ class NonInjectedClusterPrometheusSetting extends React.Component )} + <> +
+
+ + this.mountpoints = value} + onBlur={this.onSaveMountpoints} + placeholder="/" + /> + + {`A regexp for the label with the filesystem mountpoints that will create a graph for disk usage. For the root disk only use "/" and for all disks use ".*".`} + +
+ ); } diff --git a/packages/technical-features/prometheus/src/helm-provider.injectable.ts b/packages/technical-features/prometheus/src/helm-provider.injectable.ts index ac6b46d4e4f6..6395877e46ab 100644 --- a/packages/technical-features/prometheus/src/helm-provider.injectable.ts +++ b/packages/technical-features/prometheus/src/helm-provider.injectable.ts @@ -50,9 +50,9 @@ export const getHelmLikeQueryFor = case "podAllocatableCapacity": return `sum(kube_node_status_allocatable{node=~"${opts.nodes}", resource="pods"}) by (component)`; case "fsSize": - return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint="/"} - node_filesystem_avail_bytes{node=~"${opts.nodes}", mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (node)`; } break; case "nodes": @@ -72,9 +72,9 @@ export const getHelmLikeQueryFor = case "cpuAllocatableCapacity": return `sum(kube_node_status_allocatable{resource="cpu"}) by (node)`; case "fsSize": - return `sum(node_filesystem_size_bytes{mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"}) by (node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{mountpoint="/"} - node_filesystem_avail_bytes{mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{mountpoint=~"${opts.mountpoints}"}) by (node)`; } break; case "pods": diff --git a/packages/technical-features/prometheus/src/lens-provider.injectable.ts b/packages/technical-features/prometheus/src/lens-provider.injectable.ts index cb8b7bbf5ac5..025fe50a719c 100644 --- a/packages/technical-features/prometheus/src/lens-provider.injectable.ts +++ b/packages/technical-features/prometheus/src/lens-provider.injectable.ts @@ -50,9 +50,9 @@ export const getLensLikeQueryFor = case "podAllocatableCapacity": return `sum(kube_node_status_allocatable{node=~"${opts.nodes}", resource="pods"}) by (component)`; case "fsSize": - return `sum(node_filesystem_size_bytes{kubernetes_node=~"${opts.nodes}", mountpoint="/"}) by (kubernetes_node)`; + return `sum(node_filesystem_size_bytes{kubernetes_node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (kubernetes_node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{kubernetes_node=~"${opts.nodes}", mountpoint="/"} - node_filesystem_avail_bytes{kubernetes_node=~"${opts.nodes}", mountpoint="/"}) by (kubernetes_node)`; + return `sum(node_filesystem_size_bytes{kubernetes_node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{kubernetes_node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (kubernetes_node)`; } break; case "nodes": @@ -72,9 +72,9 @@ export const getLensLikeQueryFor = case "cpuAllocatableCapacity": return `sum(kube_node_status_allocatable{resource="cpu"}) by (node)`; case "fsSize": - return `sum(node_filesystem_size_bytes{mountpoint="/"}) by (kubernetes_node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"}) by (kubernetes_node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{mountpoint="/"} - node_filesystem_avail_bytes{mountpoint="/"}) by (kubernetes_node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{mountpoint=~"${opts.mountpoints}"}) by (kubernetes_node)`; } break; case "pods": diff --git a/packages/technical-features/prometheus/src/operator-provider.injectable.ts.ts b/packages/technical-features/prometheus/src/operator-provider.injectable.ts.ts index d8da7255b6b7..a63e4813dc64 100644 --- a/packages/technical-features/prometheus/src/operator-provider.injectable.ts.ts +++ b/packages/technical-features/prometheus/src/operator-provider.injectable.ts.ts @@ -50,9 +50,9 @@ export const getOperatorLikeQueryFor = case "podAllocatableCapacity": return `sum(kube_node_status_allocatable{node=~"${opts.nodes}", resource="pods"})`; case "fsSize": - return `sum(node_filesystem_size_bytes{mountpoint="/"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"})`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"})`; case "fsUsage": - return `sum(node_filesystem_size_bytes{mountpoint="/"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"} - node_filesystem_avail_bytes{mountpoint="/"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"})`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"} - node_filesystem_avail_bytes{mountpoint=~"${opts.mountpoints}"} * on (pod,namespace) group_left(node) kube_pod_info{node=~"${opts.nodes}"})`; } break; case "nodes": @@ -72,9 +72,9 @@ export const getOperatorLikeQueryFor = case "cpuAllocatableCapacity": return `sum(kube_node_status_allocatable{resource="cpu"}) by (node)`; case "fsSize": - return `sum(node_filesystem_size_bytes{mountpoint="/"} * on (pod,namespace) group_left(node) kube_pod_info) by (node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} * on (pod,namespace) group_left(node) kube_pod_info) by (node)`; case "fsUsage": - return `sum((node_filesystem_size_bytes{mountpoint="/"} - node_filesystem_avail_bytes{mountpoint="/"}) * on (pod, namespace) group_left(node) kube_pod_info) by (node)`; + return `sum((node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{mountpoint=~"${opts.mountpoints}"}) * on (pod, namespace) group_left(node) kube_pod_info) by (node)`; } break; case "pods": diff --git a/packages/technical-features/prometheus/src/stacklight-provider.injectable.ts b/packages/technical-features/prometheus/src/stacklight-provider.injectable.ts index 36979d36ea85..25dee9b91583 100644 --- a/packages/technical-features/prometheus/src/stacklight-provider.injectable.ts +++ b/packages/technical-features/prometheus/src/stacklight-provider.injectable.ts @@ -50,9 +50,9 @@ export const getStacklightLikeQueryFor = case "podAllocatableCapacity": return `sum(kube_node_status_allocatable{node=~"${opts.nodes}", resource="pods"}) by (component)`; case "fsSize": - return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint="/"} - node_filesystem_avail_bytes{node=~"${opts.nodes}", mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{node=~"${opts.nodes}", mountpoint=~"${opts.mountpoints}"}) by (node)`; } break; case "nodes": @@ -72,9 +72,9 @@ export const getStacklightLikeQueryFor = case "cpuAllocatableCapacity": return `sum(kube_node_status_allocatable{resource="cpu"}) by (node)`; case "fsSize": - return `sum(node_filesystem_size_bytes{mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"}) by (node)`; case "fsUsage": - return `sum(node_filesystem_size_bytes{mountpoint="/"} - node_filesystem_avail_bytes{mountpoint="/"}) by (node)`; + return `sum(node_filesystem_size_bytes{mountpoint=~"${opts.mountpoints}"} - node_filesystem_avail_bytes{mountpoint=~"${opts.mountpoints}"}) by (node)`; } break; case "pods":