diff --git a/ee/licensing/httplicensing/provider.go b/ee/licensing/httplicensing/provider.go index 0c63ff295b..52a162143c 100644 --- a/ee/licensing/httplicensing/provider.go +++ b/ee/licensing/httplicensing/provider.go @@ -3,6 +3,7 @@ package httplicensing import ( "context" "encoding/json" + "github.com/SigNoz/signoz/ee/query-service/constants" "time" "github.com/SigNoz/signoz/ee/licensing/licensingstore/sqllicensingstore" @@ -251,6 +252,13 @@ func (provider *provider) GetFeatureFlags(ctx context.Context) ([]*featuretypes. } } + if constants.IsDotMetricsEnabled { + gettableFeatures = append(gettableFeatures, &featuretypes.GettableFeature{ + Name: featuretypes.DotMetricsEnabled, + Active: true, + }) + } + return gettableFeatures, nil } diff --git a/ee/query-service/constants/constants.go b/ee/query-service/constants/constants.go index ff04ff0246..c2d77252ff 100644 --- a/ee/query-service/constants/constants.go +++ b/ee/query-service/constants/constants.go @@ -4,6 +4,10 @@ import ( "os" ) +const ( + DefaultSiteURL = "https://localhost:8080" +) + var LicenseSignozIo = "https://license.signoz.io/api/v1" var LicenseAPIKey = GetOrDefaultEnv("SIGNOZ_LICENSE_API_KEY", "") var SaasSegmentKey = GetOrDefaultEnv("SIGNOZ_SAAS_SEGMENT_KEY", "") @@ -20,3 +24,22 @@ func GetOrDefaultEnv(key string, fallback string) string { } return v } + +// constant functions that override env vars + +// GetDefaultSiteURL returns default site url, primarily +// used to send saml request and allowing backend to +// handle http redirect +func GetDefaultSiteURL() string { + return GetOrDefaultEnv("SIGNOZ_SITE_URL", DefaultSiteURL) +} + +const DotMetricsEnabled = "DOT_METRICS_ENABLED" + +var IsDotMetricsEnabled = false + +func init() { + if GetOrDefaultEnv(DotMetricsEnabled, "false") == "true" { + IsDotMetricsEnabled = true + } +} diff --git a/frontend/src/api/infraMonitoring/getK8sClustersList.ts b/frontend/src/api/infraMonitoring/getK8sClustersList.ts index 2da1b214b3..b08090ed2a 100644 --- a/frontend/src/api/infraMonitoring/getK8sClustersList.ts +++ b/frontend/src/api/infraMonitoring/getK8sClustersList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sClustersListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -40,23 +42,80 @@ export interface K8sClustersListResponse { }; } +export const clustersMetaMap = [ + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, + { dot: 'k8s.cluster.uid', under: 'k8s_cluster_uid' }, +] as const; + +export function mapClustersMeta( + raw: Record, +): K8sClustersData['meta'] { + const out: Record = { ...raw }; + clustersMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sClustersData['meta']; +} + export const getK8sClustersList = async ( props: K8sClustersListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/clusters/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/clusters/list', requestProps, { signal, headers, }); + const payload: K8sClustersListResponse = response.data; + + // one-liner meta mapping + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapClustersMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts b/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts index c09de10580..a35f8871ec 100644 --- a/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts +++ b/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sDaemonSetsListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -46,23 +48,82 @@ export interface K8sDaemonSetsListResponse { }; } +export const daemonSetsMetaMap = [ + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, + { dot: 'k8s.daemonset.name', under: 'k8s_daemonset_name' }, + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, +] as const; + +export function mapDaemonSetsMeta( + raw: Record, +): K8sDaemonSetsData['meta'] { + const out: Record = { ...raw }; + daemonSetsMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sDaemonSetsData['meta']; +} + export const getK8sDaemonSetsList = async ( props: K8sDaemonSetsListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/daemonsets/list', props, { + // filter prep (unchanged)… + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/daemonsets/list', requestProps, { signal, headers, }); + const payload: K8sDaemonSetsListResponse = response.data; + + // single-line meta mapping + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapDaemonSetsMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sDeploymentsList.ts b/frontend/src/api/infraMonitoring/getK8sDeploymentsList.ts index b991ce22e7..f39c62c88b 100644 --- a/frontend/src/api/infraMonitoring/getK8sDeploymentsList.ts +++ b/frontend/src/api/infraMonitoring/getK8sDeploymentsList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sDeploymentsListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -46,23 +48,81 @@ export interface K8sDeploymentsListResponse { }; } +export const deploymentsMetaMap = [ + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, + { dot: 'k8s.deployment.name', under: 'k8s_deployment_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, +] as const; + +export function mapDeploymentsMeta( + raw: Record, +): K8sDeploymentsData['meta'] { + const out: Record = { ...raw }; + deploymentsMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sDeploymentsData['meta']; +} + export const getK8sDeploymentsList = async ( props: K8sDeploymentsListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/deployments/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/deployments/list', requestProps, { signal, headers, }); + const payload: K8sDeploymentsListResponse = response.data; + + // single-line mapping + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapDeploymentsMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sJobsList.ts b/frontend/src/api/infraMonitoring/getK8sJobsList.ts index 36a6bb973d..828e42a79d 100644 --- a/frontend/src/api/infraMonitoring/getK8sJobsList.ts +++ b/frontend/src/api/infraMonitoring/getK8sJobsList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sJobsListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -48,23 +50,79 @@ export interface K8sJobsListResponse { }; } +export const jobsMetaMap = [ + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, + { dot: 'k8s.job.name', under: 'k8s_job_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, +] as const; + +export function mapJobsMeta(raw: Record): K8sJobsData['meta'] { + const out: Record = { ...raw }; + jobsMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sJobsData['meta']; +} + export const getK8sJobsList = async ( props: K8sJobsListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/jobs/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/jobs/list', requestProps, { signal, headers, }); + const payload: K8sJobsListResponse = response.data; + + // one-liner meta mapping + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapJobsMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sNamespacesList.ts b/frontend/src/api/infraMonitoring/getK8sNamespacesList.ts index bba2249f4e..a492aac045 100644 --- a/frontend/src/api/infraMonitoring/getK8sNamespacesList.ts +++ b/frontend/src/api/infraMonitoring/getK8sNamespacesList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sNamespacesListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -38,23 +40,79 @@ export interface K8sNamespacesListResponse { }; } +export const namespacesMetaMap = [ + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, +] as const; + +export function mapNamespacesMeta( + raw: Record, +): K8sNamespacesData['meta'] { + const out: Record = { ...raw }; + namespacesMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sNamespacesData['meta']; +} + export const getK8sNamespacesList = async ( props: K8sNamespacesListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/namespaces/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/namespaces/list', requestProps, { signal, headers, }); + const payload: K8sNamespacesListResponse = response.data; + + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapNamespacesMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sNodesList.ts b/frontend/src/api/infraMonitoring/getK8sNodesList.ts index 71228b030b..d0045f4820 100644 --- a/frontend/src/api/infraMonitoring/getK8sNodesList.ts +++ b/frontend/src/api/infraMonitoring/getK8sNodesList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sNodesListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -41,23 +43,81 @@ export interface K8sNodesListResponse { }; } +export const nodesMetaMap = [ + { dot: 'k8s.node.name', under: 'k8s_node_name' }, + { dot: 'k8s.node.uid', under: 'k8s_node_uid' }, + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, +] as const; + +export function mapNodesMeta( + raw: Record, +): K8sNodesData['meta'] { + const out: Record = { ...raw }; + nodesMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sNodesData['meta']; +} + export const getK8sNodesList = async ( props: K8sNodesListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/nodes/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/nodes/list', requestProps, { signal, headers, }); + const payload: K8sNodesListResponse = response.data; + + // one-liner to map dot→underscore + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapNodesMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sPodsList.ts b/frontend/src/api/infraMonitoring/getK8sPodsList.ts index 05258ef166..560788285f 100644 --- a/frontend/src/api/infraMonitoring/getK8sPodsList.ts +++ b/frontend/src/api/infraMonitoring/getK8sPodsList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sPodsListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -69,23 +71,87 @@ export interface K8sPodsListResponse { }; } +export const podsMetaMap = [ + { dot: 'k8s.cronjob.name', under: 'k8s_cronjob_name' }, + { dot: 'k8s.daemonset.name', under: 'k8s_daemonset_name' }, + { dot: 'k8s.deployment.name', under: 'k8s_deployment_name' }, + { dot: 'k8s.job.name', under: 'k8s_job_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, + { dot: 'k8s.node.name', under: 'k8s_node_name' }, + { dot: 'k8s.pod.name', under: 'k8s_pod_name' }, + { dot: 'k8s.pod.uid', under: 'k8s_pod_uid' }, + { dot: 'k8s.statefulset.name', under: 'k8s_statefulset_name' }, + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, +] as const; + +export function mapPodsMeta(raw: Record): K8sPodsData['meta'] { + // clone everything + const out: Record = { ...raw }; + // overlay only the dot→under mappings + podsMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sPodsData['meta']; +} + +// getK8sPodsList export const getK8sPodsList = async ( props: K8sPodsListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/pods/list', props, { + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ + ...item, + key: { ...item.key, key: mappedKey }, + }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/pods/list', requestProps, { signal, headers, }); + const payload: K8sPodsListResponse = response.data; + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapPodsMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getK8sVolumesList.ts b/frontend/src/api/infraMonitoring/getK8sVolumesList.ts index ea825ba05d..2089e5cd59 100644 --- a/frontend/src/api/infraMonitoring/getK8sVolumesList.ts +++ b/frontend/src/api/infraMonitoring/getK8sVolumesList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sVolumesListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -47,23 +49,92 @@ export interface K8sVolumesListResponse { }; } +export const volumesMetaMap: Array<{ + dot: keyof Record; + under: keyof K8sVolumesData['meta']; +}> = [ + { dot: 'k8s.cluster.name', under: 'k8s_cluster_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, + { dot: 'k8s.node.name', under: 'k8s_node_name' }, + { + dot: 'k8s.persistentvolumeclaim.name', + under: 'k8s_persistentvolumeclaim_name', + }, + { dot: 'k8s.pod.name', under: 'k8s_pod_name' }, + { dot: 'k8s.pod.uid', under: 'k8s_pod_uid' }, + { dot: 'k8s.statefulset.name', under: 'k8s_statefulset_name' }, +]; + +export function mapVolumesMeta( + rawMeta: Record, +): K8sVolumesData['meta'] { + // start with everything that was already there + const out: Record = { ...rawMeta }; + + // for each dot→under rule, if the raw has the dot, overwrite the underscore + volumesMetaMap.forEach(({ dot, under }) => { + if (dot in rawMeta) { + const val = rawMeta[dot]; + out[under] = typeof val === 'string' ? val : rawMeta[under]; + } + }); + + return out as K8sVolumesData['meta']; +} + export const getK8sVolumesList = async ( props: K8sVolumesListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/pvcs/list', props, { + // Prepare filters + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ ...item, key: { ...item.key, key: mappedKey } }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/pvcs/list', requestProps, { signal, headers, }); + const payload: K8sVolumesListResponse = response.data; + + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapVolumesMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts b/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts index 191ec069c3..2544c0cfe3 100644 --- a/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts +++ b/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts @@ -5,6 +5,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { TagFilter } from 'types/api/queryBuilder/queryBuilderData'; +import { UnderscoreToDotMap } from '../utils'; + export interface K8sStatefulSetsListPayload { filters: TagFilter; groupBy?: BaseAutocompleteData[]; @@ -45,23 +47,78 @@ export interface K8sStatefulSetsListResponse { }; } +export const statefulSetsMetaMap = [ + { dot: 'k8s.statefulset.name', under: 'k8s_statefulset_name' }, + { dot: 'k8s.namespace.name', under: 'k8s_namespace_name' }, +] as const; + +export function mapStatefulSetsMeta( + raw: Record, +): K8sStatefulSetsData['meta'] { + const out: Record = { ...raw }; + statefulSetsMetaMap.forEach(({ dot, under }) => { + if (dot in raw) { + const v = raw[dot]; + out[under] = typeof v === 'string' ? v : raw[under]; + } + }); + return out as K8sStatefulSetsData['meta']; +} + export const getK8sStatefulSetsList = async ( props: K8sStatefulSetsListPayload, signal?: AbortSignal, headers?: Record, + dotMetricsEnabled = false, ): Promise | ErrorResponse> => { try { - const response = await axios.post('/statefulsets/list', props, { + // Prepare filters + const requestProps = + dotMetricsEnabled && Array.isArray(props.filters?.items) + ? { + ...props, + filters: { + ...props.filters, + items: props.filters.items.reduce( + (acc, item) => { + if (item.value === undefined) return acc; + if ( + item.key && + typeof item.key === 'object' && + 'key' in item.key && + typeof item.key.key === 'string' + ) { + const mappedKey = UnderscoreToDotMap[item.key.key] ?? item.key.key; + acc.push({ ...item, key: { ...item.key, key: mappedKey } }); + } else { + acc.push(item); + } + return acc; + }, + [] as typeof props.filters.items, + ), + }, + } + : props; + + const response = await axios.post('/statefulsets/list', requestProps, { signal, headers, }); + const payload: K8sStatefulSetsListResponse = response.data; + + // apply our helper + payload.data.records = payload.data.records.map((record) => ({ + ...record, + meta: mapStatefulSetsMeta(record.meta as Record), + })); return { statusCode: 200, error: null, message: 'Success', - payload: response.data, - params: props, + payload, + params: requestProps, }; } catch (error) { return ErrorResponseHandler(error as AxiosError); diff --git a/frontend/src/api/utils.ts b/frontend/src/api/utils.ts index 95dfceb457..731b8e859a 100644 --- a/frontend/src/api/utils.ts +++ b/frontend/src/api/utils.ts @@ -17,3 +17,19 @@ export const Logout = (): void => { history.push(ROUTES.LOGIN); }; + +export const UnderscoreToDotMap: Record = { + k8s_cluster_name: 'k8s.cluster.name', + k8s_cluster_uid: 'k8s.cluster.uid', + k8s_namespace_name: 'k8s.namespace.name', + k8s_node_name: 'k8s.node.name', + k8s_node_uid: 'k8s.node.uid', + k8s_pod_name: 'k8s.pod.name', + k8s_pod_uid: 'k8s.pod.uid', + k8s_deployment_name: 'k8s.deployment.name', + k8s_daemonset_name: 'k8s.daemonset.name', + k8s_statefulset_name: 'k8s.statefulset.name', + k8s_cronjob_name: 'k8s.cronjob.name', + k8s_job_name: 'k8s.job.name', + k8s_persistentvolumeclaim_name: 'k8s.persistentvolumeclaim.name', +}; diff --git a/frontend/src/components/HostMetricsDetail/Metrics/Metrics.tsx b/frontend/src/components/HostMetricsDetail/Metrics/Metrics.tsx index cba11cdaa2..f7142ebb20 100644 --- a/frontend/src/components/HostMetricsDetail/Metrics/Metrics.tsx +++ b/frontend/src/components/HostMetricsDetail/Metrics/Metrics.tsx @@ -23,6 +23,9 @@ import { useQueries, UseQueryResult } from 'react-query'; import { SuccessResponse } from 'types/api'; import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; + interface MetricsTabProps { timeRange: { startTime: number; @@ -45,9 +48,20 @@ function Metrics({ handleTimeChange, isModalTimeSelection, }: MetricsTabProps): JSX.Element { + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const queryPayloads = useMemo( - () => getHostQueryPayload(hostName, timeRange.startTime, timeRange.endTime), - [hostName, timeRange.startTime, timeRange.endTime], + () => + getHostQueryPayload( + hostName, + timeRange.startTime, + timeRange.endTime, + dotMetricsEnabled, + ), + [hostName, timeRange.startTime, timeRange.endTime, dotMetricsEnabled], ); const queries = useQueries( diff --git a/frontend/src/constants/features.ts b/frontend/src/constants/features.ts index 0a80a9789b..f1e486ee91 100644 --- a/frontend/src/constants/features.ts +++ b/frontend/src/constants/features.ts @@ -10,4 +10,5 @@ export enum FeatureKeys { ONBOARDING_V3 = 'ONBOARDING_V3', THIRD_PARTY_API = 'THIRD_PARTY_API', TRACE_FUNNELS = 'TRACE_FUNNELS', + DOT_METRICS_ENABLED = 'DOT_METRICS_ENABLED', } diff --git a/frontend/src/container/AllError/index.tsx b/frontend/src/container/AllError/index.tsx index 96415daec6..aabd36ee2d 100644 --- a/frontend/src/container/AllError/index.tsx +++ b/frontend/src/container/AllError/index.tsx @@ -21,7 +21,10 @@ import ROUTES from 'constants/routes'; import { useGetCompositeQueryParam } from 'hooks/queryBuilder/useGetCompositeQueryParam'; import { useNotifications } from 'hooks/useNotifications'; import useResourceAttribute from 'hooks/useResourceAttribute'; -import { convertCompositeQueryToTraceSelectedTags } from 'hooks/useResourceAttribute/utils'; +import { + convertCompositeQueryToTraceSelectedTags, + getResourceDeploymentKeys, +} from 'hooks/useResourceAttribute/utils'; import { TimestampInput } from 'hooks/useTimezoneFormatter/useTimezoneFormatter'; import useUrlQuery from 'hooks/useUrlQuery'; import createQueryParams from 'lib/createQueryParams'; @@ -38,6 +41,8 @@ import { ErrorResponse, SuccessResponse } from 'types/api'; import { Exception, PayloadProps } from 'types/api/errors/getAll'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../constants/features'; +import { useAppContext } from '../../providers/App/App'; import { FilterDropdownExtendsProps } from './types'; import { extractFilterValues, @@ -405,6 +410,11 @@ function AllErrors(): JSX.Element { }, ]; + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const onChangeHandler: TableProps['onChange'] = useCallback( ( paginations: TablePaginationConfig, @@ -438,7 +448,7 @@ function AllErrors(): JSX.Element { useEffect(() => { if (!isUndefined(errorCountResponse.data?.payload)) { const selectedEnvironments = queries.find( - (val) => val.tagKey === 'resource_deployment_environment', + (val) => val.tagKey === getResourceDeploymentKeys(dotMetricsEnabled), )?.tagValue; logEvent('Exception: List page visited', { diff --git a/frontend/src/container/AllError/tests/AllError.test.tsx b/frontend/src/container/AllError/tests/AllError.test.tsx index 812786a5c1..25124edac0 100644 --- a/frontend/src/container/AllError/tests/AllError.test.tsx +++ b/frontend/src/container/AllError/tests/AllError.test.tsx @@ -10,6 +10,8 @@ import { Provider, useSelector } from 'react-redux'; import { MemoryRouter } from 'react-router-dom'; import store from 'store'; +import * as appContextHooks from '../../../providers/App/App'; +import { LicenseEvent } from '../../../types/api/licensesV3/getActive'; import AllErrors from '../index'; import { INIT_URL_WITH_COMMON_QUERY, @@ -28,6 +30,30 @@ jest.mock('react-redux', () => ({ useSelector: jest.fn(), })); +jest.spyOn(appContextHooks, 'useAppContext').mockReturnValue({ + user: { + role: 'admin', + }, + activeLicenseV3: { + event_queue: { + created_at: '0', + event: LicenseEvent.NO_EVENT, + scheduled_at: '0', + status: '', + updated_at: '0', + }, + license: { + license_key: 'test-license-key', + license_type: 'trial', + org_id: 'test-org-id', + plan_id: 'test-plan-id', + plan_name: 'test-plan-name', + plan_type: 'trial', + plan_version: 'test-plan-version', + }, + }, +} as any); + function Exceptions({ initUrl }: { initUrl?: string[] }): JSX.Element { return ( diff --git a/frontend/src/container/Home/Home.tsx b/frontend/src/container/Home/Home.tsx index f1b4c32b12..89e69a1111 100644 --- a/frontend/src/container/Home/Home.tsx +++ b/frontend/src/container/Home/Home.tsx @@ -10,6 +10,7 @@ import getAllUserPreferences from 'api/preferences/getAllUserPreference'; import updateUserPreferenceAPI from 'api/preferences/updateUserPreference'; import Header from 'components/Header/Header'; import { DEFAULT_ENTITY_VERSION } from 'constants/app'; +import { FeatureKeys } from 'constants/features'; import { LOCALSTORAGE } from 'constants/localStorage'; import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder'; import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; @@ -161,10 +162,20 @@ export default function Home(): JSX.Element { enabled: !!query, }); - const { data: k8sPodsData } = useGetK8sPodsList(query as K8sPodsListPayload, { - queryKey: ['K8sPodsList', query], - enabled: !!query, - }); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + + const { data: k8sPodsData } = useGetK8sPodsList( + query as K8sPodsListPayload, + { + queryKey: ['K8sPodsList', query], + enabled: !!query, + }, + undefined, + dotMetricsEnabled, + ); const [isLogsIngestionActive, setIsLogsIngestionActive] = useState(false); const [isTracesIngestionActive, setIsTracesIngestionActive] = useState(false); diff --git a/frontend/src/container/Home/Services/ServiceMetrics.tsx b/frontend/src/container/Home/Services/ServiceMetrics.tsx index d588f9d65d..6abbf2d046 100644 --- a/frontend/src/container/Home/Services/ServiceMetrics.tsx +++ b/frontend/src/container/Home/Services/ServiceMetrics.tsx @@ -30,6 +30,7 @@ import { GlobalReducer } from 'types/reducer/globalTime'; import { Tags } from 'types/reducer/trace'; import { USER_ROLES } from 'types/roles'; +import { FeatureKeys } from '../../../constants/features'; import { DOCS_LINKS } from '../constants'; import { columns, TIME_PICKER_OPTIONS } from './constants'; @@ -210,6 +211,11 @@ function ServiceMetrics({ const topLevelOperations = useMemo(() => Object.entries(data || {}), [data]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const queryRangeRequestData = useMemo( () => getQueryRangeRequestData({ @@ -217,12 +223,14 @@ function ServiceMetrics({ minTime: timeRange.startTime * 1e6, maxTime: timeRange.endTime * 1e6, globalSelectedInterval, + dotMetricsEnabled, }), [ globalSelectedInterval, timeRange.endTime, timeRange.startTime, topLevelOperations, + dotMetricsEnabled, ], ); diff --git a/frontend/src/container/InfraMonitoringHosts/HostsList.tsx b/frontend/src/container/InfraMonitoringHosts/HostsList.tsx index f4dac3f9eb..f67b47c7f7 100644 --- a/frontend/src/container/InfraMonitoringHosts/HostsList.tsx +++ b/frontend/src/container/InfraMonitoringHosts/HostsList.tsx @@ -25,9 +25,11 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery, Query } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../constants/features'; +import { useAppContext } from '../../providers/App/App'; import HostsListControls from './HostsListControls'; import HostsListTable from './HostsListTable'; -import { getHostListsQuery, HostsQuickFiltersConfig } from './utils'; +import { getHostListsQuery, GetHostsQuickFiltersConfig } from './utils'; // eslint-disable-next-line sonarjs/cognitive-complexity function HostsList(): JSX.Element { const { maxTime, minTime } = useSelector( @@ -114,6 +116,11 @@ function HostsList(): JSX.Element { entityVersion: '', }); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const handleFiltersChange = useCallback( (value: IBuilderQuery['filters']): void => { const isNewFilterAdded = value.items.length !== filters.items.length; @@ -182,7 +189,7 @@ function HostsList(): JSX.Element { diff --git a/frontend/src/container/InfraMonitoringHosts/utils.tsx b/frontend/src/container/InfraMonitoringHosts/utils.tsx index b6778ff22d..4e9bbd4ba2 100644 --- a/frontend/src/container/InfraMonitoringHosts/utils.tsx +++ b/frontend/src/container/InfraMonitoringHosts/utils.tsx @@ -198,3 +198,48 @@ export const HostsQuickFiltersConfig: IQuickFiltersConfig[] = [ defaultOpen: true, }, ]; + +export function GetHostsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + // These keys don’t change with dotMetricsEnabled + const hostNameKey = dotMetricsEnabled ? 'host.name' : 'host_name'; + const osTypeKey = dotMetricsEnabled ? 'os.type' : 'os_type'; + // This metric stays the same regardless of notation + const metricName = dotMetricsEnabled + ? 'system.cpu.load_average.15m' + : 'system_cpu_load_average_15m'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Host Name', + attributeKey: { + key: hostNameKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'OS Type', + attributeKey: { + key: osTypeKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/constants.ts index 9d60aca7a4..2a84e83ca3 100644 --- a/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/ClusterDetails/constants.ts @@ -46,1485 +46,1981 @@ export const getClusterMetricsQueryPayload = ( cluster: K8sClustersData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '0224c582', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const getKey = (dotKey: string, underscoreKey: string): string => + dotMetricsEnabled ? dotKey : underscoreKey; + const k8sPodCpuUtilizationKey = getKey( + 'k8s.pod.cpu.utilization', + 'k8s_pod_cpu_utilization', + ); + const k8sNodeAllocatableCpuKey = getKey( + 'k8s.node.allocatable_cpu', + 'k8s_node_allocatable_cpu', + ); + const k8sPodMemoryUsageKey = getKey( + 'k8s.pod.memory.usage', + 'k8s_pod_memory_usage', + ); + const k8sNodeAllocatableMemoryKey = getKey( + 'k8s.node.allocatable_memory', + 'k8s_node_allocatable_memory', + ); + const k8sNodeConditionReadyKey = getKey( + 'k8s.node.condition_ready', + 'k8s_node_condition_ready', + ); + const k8sDeploymentAvailableKey = getKey( + 'k8s.deployment.available', + 'k8s_deployment_available', + ); + const k8sDeploymentDesiredKey = getKey( + 'k8s.deployment.desired', + 'k8s_deployment_desired', + ); + const k8sStatefulsetCurrentPodsKey = getKey( + 'k8s.statefulset.current_pods', + 'k8s_statefulset_current_pods', + ); + const k8sStatefulsetDesiredPodsKey = getKey( + 'k8s.statefulset.desired_pods', + 'k8s_statefulset_desired_pods', + ); + const k8sStatefulsetReadyPodsKey = getKey( + 'k8s.statefulset.ready_pods', + 'k8s_statefulset_ready_pods', + ); + const k8sStatefulsetUpdatedPodsKey = getKey( + 'k8s.statefulset.updated_pods', + 'k8s_statefulset_updated_pods', + ); + const k8sDaemonsetCurrentScheduledNodesKey = getKey( + 'k8s.daemonset.current_scheduled_nodes', + 'k8s_daemonset_current_scheduled_nodes', + ); + const k8sDaemonsetDesiredScheduledNodesKey = getKey( + 'k8s.daemonset.desired_scheduled_nodes', + 'k8s_daemonset_desired_scheduled_nodes', + ); + const k8sDaemonsetReadyNodesKey = getKey( + 'k8s.daemonset.ready_nodes', + 'k8s_daemonset_ready_nodes', + ); + const k8sJobActivePodsKey = getKey( + 'k8s.job.active_pods', + 'k8s_job_active_pods', + ); + const k8sJobSuccessfulPodsKey = getKey( + 'k8s.job.successful_pods', + 'k8s_job_successful_pods', + ); + const k8sJobFailedPodsKey = getKey( + 'k8s.job.failed_pods', + 'k8s_job_failed_pods', + ); + const k8sJobDesiredSuccessfulPodsKey = getKey( + 'k8s.job.desired_successful_pods', + 'k8s_job_desired_successful_pods', + ); + const k8sClusterNameKey = getKey('k8s.cluster.name', 'k8s_cluster_name'); + const k8sNodeNameKey = getKey('k8s.node.name', 'k8s_node_name'); + const k8sDeploymentNameKey = getKey( + 'k8s.deployment.name', + 'k8s_deployment_name', + ); + const k8sNamespaceNameKey = getKey('k8s.namespace.name', 'k8s_namespace_name'); + const k8sStatefulsetNameKey = getKey( + 'k8s.statefulset.name', + 'k8s_statefulset_name', + ); + const k8sDaemonsetNameKey = getKey('k8s.daemonset.name', 'k8s_daemonset_name'); + const k8sJobNameKey = getKey('k8s.job.name', 'k8s_job_name'); + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '0224c582', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'a0e11f0c', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'a0e11f0c', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (min)', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (min)', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'c775629c', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'c775629c', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (max)', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (max)', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_cpu--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_cpu', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '31f6c43a', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_cpu--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocatableCpuKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '31f6c43a', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '61a3c55e', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '834a887f', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (min)', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '9b002160', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (max)', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_memory--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_memory', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '02a9a67e', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_condition_ready--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_condition_ready', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'd7779183', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_node_name', - type: 'tag', + key: k8sPodMemoryUsageKey, + type: 'Gauge', }, - ], - having: [ - { - columnName: 'MAX(k8s_node_condition_ready)', - op: '=', - value: 1, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '61a3c55e', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', }, - ], - legend: '{{k8s_node_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + functions: [], + groupBy: [], + having: [], + legend: 'usage (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '834a887f', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (min)', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '9b002160', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (max)', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_memory--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocatableMemoryKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '02a9a67e', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_condition_ready--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_condition_ready', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'd7779183', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - ], - having: [ - { - columnName: 'MAX(k8s_node_condition_ready)', - op: '=', - value: 0, - }, - ], - legend: '{{k8s_node_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_deployment_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_deployment_available', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'a7da59c7', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_condition_ready--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeConditionReadyKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'available', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_deployment_desired--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_deployment_desired', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ + having: [ { - id: '55110885', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, + columnName: `MAX(${k8sNodeConditionReadyKey})`, op: '=', - value: cluster.meta.k8s_cluster_name, + value: 1, }, ], - op: 'AND', + legend: `{{${k8sNodeNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_current_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_current_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '3c57b4d1', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'current', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_desired_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_desired_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '0f49fe64', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_ready_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_ready_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '0bebf625', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'ready', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_updated_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_updated_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '1ddacbbe', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'updated', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_current_scheduled_nodes--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_current_scheduled_nodes', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e0bea554', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_condition_ready--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeConditionReadyKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, }, - op: '=', - value: cluster.meta.k8s_cluster_name, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - ], - having: [], - legend: 'current_nodes', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_desired_scheduled_nodes--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_desired_scheduled_nodes', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ + having: [ { - id: '741052f7', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, + columnName: `MAX(${k8sNodeConditionReadyKey})`, op: '=', - value: cluster.meta.k8s_cluster_name, + value: 0, }, ], - op: 'AND', + legend: `{{${k8sNodeNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - ], - having: [], - legend: 'desired_nodes', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_ready_nodes--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_ready_nodes', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'f23759f2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - ], - having: [], - legend: 'ready_nodes', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'last', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_job_active_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_job_active_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'fd485d85', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'running', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_job_successful_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_job_successful_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'fc1beb81', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'successful', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_job_failed_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_job_failed_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '97773348', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'failed', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_job_desired_successful_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_job_desired_successful_pods', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '5911618b', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: cluster.meta.k8s_cluster_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - ], - having: [], - legend: 'desired successful', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'last', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_deployment_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sDeploymentAvailableKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sDeploymentNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_deployment_desired--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sDeploymentDesiredKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sDeploymentNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_statefulset_current_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sStatefulsetCurrentPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_statefulset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sStatefulsetNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_statefulset_desired_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sStatefulsetDesiredPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_statefulset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sStatefulsetNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_statefulset_ready_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sStatefulsetReadyPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_statefulset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sStatefulsetNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_statefulset_updated_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sStatefulsetUpdatedPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_statefulset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sStatefulsetNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + { + disabled: false, + legend: '', + name: 'D', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + { + disabled: false, + legend: '', + name: 'D', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_daemonset_current_scheduled_nodes--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sDaemonsetCurrentScheduledNodesKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sDaemonsetNameKey}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_daemonset_desired_scheduled_nodes--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sDaemonsetDesiredScheduledNodesKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sDaemonsetNameKey}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_daemonset_ready_nodes--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sDaemonsetReadyNodesKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sDaemonsetNameKey}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_active_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobActivePodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sJobNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_successful_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobSuccessfulPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sJobNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_failed_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobFailedPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sJobNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_desired_successful_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobDesiredSuccessfulPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: 'd7779183', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sJobNameKey}}} ({{${k8sNamespaceNameKey}})`, + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + { + disabled: false, + legend: '', + name: 'D', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + { + disabled: false, + legend: '', + name: 'B', + query: '', + }, + { + disabled: false, + legend: '', + name: 'C', + query: '', + }, + { + disabled: false, + legend: '', + name: 'D', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TABLE, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_active_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobActivePodsKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'fd485d85', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: 'k8s_cluster_name', + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: 'running', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'last', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_successful_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobSuccessfulPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'fc1beb81', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: 'k8s_cluster_name', + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: 'successful', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'last', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_failed_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobFailedPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '97773348', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: 'k8s_cluster_name', + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: 'failed', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'last', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_job_desired_successful_pods--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sJobDesiredSuccessfulPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '5911618b', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: 'k8s_cluster_name', + type: 'tag', + }, + op: '=', + value: cluster.meta.k8s_cluster_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + ], + having: [], + legend: 'desired successful', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'last', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: true, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/K8sClustersList.tsx b/frontend/src/container/InfraMonitoringK8s/Clusters/K8sClustersList.tsx index aef7bb491a..9fe85939aa 100644 --- a/frontend/src/container/InfraMonitoringK8s/Clusters/K8sClustersList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/K8sClustersList.tsx @@ -28,11 +28,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -135,6 +137,11 @@ function K8sClustersList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sClustersRowData, groupBy: IBuilderQuery['groupBy'], @@ -194,6 +201,8 @@ function K8sClustersList({ queryKey: ['clusterList', fetchGroupedByRowDataQuery], enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, }, + undefined, + dotMetricsEnabled, ); const { @@ -202,8 +211,10 @@ function K8sClustersList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: - K8sEntityToAggregateAttributeMapping[K8sCategory.CLUSTERS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.CLUSTERS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -249,6 +260,8 @@ function K8sClustersList({ queryKey: ['clusterList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const clustersData = useMemo(() => data?.payload?.data?.records || [], [data]); diff --git a/frontend/src/container/InfraMonitoringK8s/Clusters/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Clusters/utils.tsx index f03804537e..7dfc0e23d7 100644 --- a/frontend/src/container/InfraMonitoringK8s/Clusters/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Clusters/utils.tsx @@ -136,6 +136,11 @@ export const getK8sClustersListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.cluster.name': 'k8s_cluster_name', + 'k8s.cluster.uid': 'k8s_cluster_uid', +}; + const getGroupByEle = ( cluster: K8sClustersData, groupBy: IBuilderQuery['groupBy'], @@ -143,7 +148,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(cluster.meta[group.key as keyof typeof cluster.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof cluster.meta; + const value = cluster.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts index 1b9ea26033..b207c4ccc1 100644 --- a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts @@ -30,619 +30,664 @@ export const getDaemonSetMetricsQueryPayload = ( daemonSet: K8sDaemonSetsData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sPodCpuUtilizationKey = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + const k8sContainerCpuRequestKey = dotMetricsEnabled + ? 'k8s.container.cpu_request' + : 'k8s_container_cpu_request'; + + const k8sContainerCpuLimitKey = dotMetricsEnabled + ? 'k8s.container.cpu_limit' + : 'k8s_container_cpu_limit'; + + const k8sPodMemoryUsageKey = dotMetricsEnabled + ? 'k8s.pod.memory.usage' + : 'k8s_pod_memory_usage'; + + const k8sContainerMemoryRequestKey = dotMetricsEnabled + ? 'k8s.container.memory_request' + : 'k8s_container_memory_request'; + + const k8sContainerMemoryLimitKey = dotMetricsEnabled + ? 'k8s.container.memory_limit' + : 'k8s_container_memory_limit'; + + const k8sPodNetworkIoKey = dotMetricsEnabled + ? 'k8s.pod.network.io' + : 'k8s_pod_network_io'; + + const k8sPodNetworkErrorsKey = dotMetricsEnabled + ? 'k8s.pod.network.errors' + : 'k8s_pod_network_errors'; + + const k8sDaemonSetNameKey = dotMetricsEnabled + ? 'k8s.daemonset.name' + : 'k8s_daemonset_name'; + + const k8sPodNameKey = dotMetricsEnabled ? 'k8s.pod.name' : 'k8s_pod_name'; + + const k8sNamespaceNameKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '745a486f', + key: { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonSetNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '148dffa7', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'd420a02b', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '745a486f', - key: { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '148dffa7', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_limit', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'd420a02b', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6d3283ce', - key: { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'a334f5c2', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_limit', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'fde3c631', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '6d3283ce', + key: { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonSetNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'a334f5c2', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'fde3c631', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'ccbdbd6a', - key: { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '581a85fb', - key: { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_daemonset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: daemonSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'ccbdbd6a', + key: { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonSetNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '581a85fb', + key: { + dataType: DataTypes.String, + id: 'k8s_daemonset_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDaemonSetNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_daemonset_name, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: daemonSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx index 767b175347..7084c4ba09 100644 --- a/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -137,6 +139,11 @@ function K8sDaemonSetsList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sDaemonSetsRowData, groupBy: IBuilderQuery['groupBy'], @@ -196,6 +203,8 @@ function K8sDaemonSetsList({ queryKey: ['daemonSetList', fetchGroupedByRowDataQuery], enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, }, + undefined, + dotMetricsEnabled, ); const { @@ -204,8 +213,10 @@ function K8sDaemonSetsList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: - K8sEntityToAggregateAttributeMapping[K8sCategory.DAEMONSETS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.DAEMONSETS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -246,6 +257,8 @@ function K8sDaemonSetsList({ queryKey: ['daemonSetList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const daemonSetsData = useMemo(() => data?.payload?.data?.records || [], [ diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx b/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx index e7d39d81de..5a3be3a741 100644 --- a/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx @@ -236,6 +236,12 @@ export const getK8sDaemonSetsListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.daemonset.name': 'k8s_daemonset_name', + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.cluster.name': 'k8s_cluster_name', +}; + const getGroupByEle = ( daemonSet: K8sDaemonSetsData, groupBy: IBuilderQuery['groupBy'], @@ -243,7 +249,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(daemonSet.meta[group.key as keyof typeof daemonSet.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof daemonSet.meta; + const value = daemonSet.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/Deployments/DeploymentDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Deployments/DeploymentDetails/constants.ts index c6481481b1..f334f4ada9 100644 --- a/frontend/src/container/InfraMonitoringK8s/Deployments/DeploymentDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Deployments/DeploymentDetails/constants.ts @@ -30,515 +30,556 @@ export const getDeploymentMetricsQueryPayload = ( deployment: K8sDeploymentsData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'aec60cba', - key: { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sPodCpuUtilizationKey = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + const k8sContainerCpuRequestKey = dotMetricsEnabled + ? 'k8s.container.cpu_request' + : 'k8s_container_cpu_request'; + + const k8sContainerCpuLimitKey = dotMetricsEnabled + ? 'k8s.container.cpu_limit' + : 'k8s_container_cpu_limit'; + + const k8sPodMemoryUsageKey = dotMetricsEnabled + ? 'k8s.pod.memory.usage' + : 'k8s_pod_memory_usage'; + + const k8sContainerMemoryRequestKey = dotMetricsEnabled + ? 'k8s.container.memory_request' + : 'k8s_container_memory_request'; + + const k8sContainerMemoryLimitKey = dotMetricsEnabled + ? 'k8s.container.memory_limit' + : 'k8s_container_memory_limit'; + + const k8sPodNetworkIoKey = dotMetricsEnabled + ? 'k8s.pod.network.io' + : 'k8s_pod_network_io'; + + const k8sPodNetworkErrorsKey = dotMetricsEnabled + ? 'k8s.pod.network.errors' + : 'k8s_pod_network_errors'; + + const k8sDeploymentNameKey = dotMetricsEnabled + ? 'k8s.deployment.name' + : 'k8s_deployment_name'; + + const k8sPodNameKey = dotMetricsEnabled ? 'k8s.pod.name' : 'k8s_pod_name'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'aec60cba', + key: { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + op: '=', + value: deployment.meta.k8s_deployment_name, }, - op: '=', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'd047ec14', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'd047ec14', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: deployment.meta.k8s_deployment_name, }, - op: 'contains', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_limit', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '750b7856', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '750b7856', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: deployment.meta.k8s_deployment_name, }, - op: 'contains', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '768c2f47', - key: { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', - }, - op: '=', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '1a96fa81', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_limit', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'e69a2b7e', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '8b550f6d', - key: { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '768c2f47', + key: { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + op: '=', + value: deployment.meta.k8s_deployment_name, }, - op: '=', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'direction', - type: 'tag', + key: k8sContainerMemoryRequestKey, + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '1a96fa81', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: deployment.meta.k8s_deployment_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_limit--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'interface', - type: 'tag', + key: k8sContainerMemoryLimitKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'e69a2b7e', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: deployment.meta.k8s_deployment_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e16c1e4a', - key: { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', - }, - op: '=', - value: deployment.meta.k8s_deployment_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '8b550f6d', + key: { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + op: '=', + value: deployment.meta.k8s_deployment_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'e16c1e4a', + key: { + dataType: DataTypes.String, + id: 'k8s_deployment_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', + }, + op: '=', + value: deployment.meta.k8s_deployment_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Deployments/K8sDeploymentsList.tsx b/frontend/src/container/InfraMonitoringK8s/Deployments/K8sDeploymentsList.tsx index 1bbb58bb1a..215842b897 100644 --- a/frontend/src/container/InfraMonitoringK8s/Deployments/K8sDeploymentsList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Deployments/K8sDeploymentsList.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -138,6 +140,11 @@ function K8sDeploymentsList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sDeploymentsRowData, groupBy: IBuilderQuery['groupBy'], @@ -197,6 +204,8 @@ function K8sDeploymentsList({ queryKey: ['deploymentList', fetchGroupedByRowDataQuery], enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, }, + undefined, + dotMetricsEnabled, ); const { @@ -205,8 +214,10 @@ function K8sDeploymentsList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: - K8sEntityToAggregateAttributeMapping[K8sCategory.DEPLOYMENTS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.DEPLOYMENTS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -247,6 +258,8 @@ function K8sDeploymentsList({ queryKey: ['deploymentList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const deploymentsData = useMemo(() => data?.payload?.data?.records || [], [ diff --git a/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx index 779b9b4bf5..b64845eb9c 100644 --- a/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx @@ -226,6 +226,12 @@ export const getK8sDeploymentsListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.deployment.name': 'k8s_deployment_name', + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.cluster.name': 'k8s_cluster_name', +}; + const getGroupByEle = ( deployment: K8sDeploymentsData, groupBy: IBuilderQuery['groupBy'], @@ -233,9 +239,14 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push( - deployment.meta[group.key as keyof typeof deployment.meta], - ); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? + rawKey) as keyof typeof deployment.meta; + const value = deployment.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics/EntityMetrics.tsx b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics/EntityMetrics.tsx index 1fda22df75..d90ad708e0 100644 --- a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics/EntityMetrics.tsx +++ b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics/EntityMetrics.tsx @@ -29,6 +29,9 @@ import { SuccessResponse } from 'types/api'; import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange'; import { Options } from 'uplot'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; + interface EntityMetricsProps { timeRange: { startTime: number; @@ -49,6 +52,7 @@ interface EntityMetricsProps { node: T, start: number, end: number, + dotMetricsEnabled: boolean, ) => GetQueryResultsProps[]; queryKey: string; category: K8sCategory; @@ -65,9 +69,25 @@ function EntityMetrics({ queryKey, category, }: EntityMetricsProps): JSX.Element { + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; const queryPayloads = useMemo( - () => getEntityQueryPayload(entity, timeRange.startTime, timeRange.endTime), - [getEntityQueryPayload, entity, timeRange.startTime, timeRange.endTime], + () => + getEntityQueryPayload( + entity, + timeRange.startTime, + timeRange.endTime, + dotMetricsEnabled, + ), + [ + getEntityQueryPayload, + entity, + timeRange.startTime, + timeRange.endTime, + dotMetricsEnabled, + ], ); const queries = useQueries( diff --git a/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx b/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx index 9aa6ab6f33..a293f9cd5d 100644 --- a/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx +++ b/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx @@ -26,19 +26,21 @@ import { useState } from 'react'; import { useSearchParams } from 'react-router-dom-v5-compat'; import { Query } from 'types/api/queryBuilder/queryBuilderData'; +import { FeatureKeys } from '../../constants/features'; +import { useAppContext } from '../../providers/App/App'; import K8sClustersList from './Clusters/K8sClustersList'; import { - ClustersQuickFiltersConfig, - DaemonSetsQuickFiltersConfig, - DeploymentsQuickFiltersConfig, + GetClustersQuickFiltersConfig, + GetDaemonsetsQuickFiltersConfig, + GetDeploymentsQuickFiltersConfig, + GetJobsQuickFiltersConfig, + GetNamespaceQuickFiltersConfig, + GetNodesQuickFiltersConfig, + GetPodsQuickFiltersConfig, + GetStatefulsetsQuickFiltersConfig, + GetVolumesQuickFiltersConfig, INFRA_MONITORING_K8S_PARAMS_KEYS, - JobsQuickFiltersConfig, K8sCategories, - NamespaceQuickFiltersConfig, - NodesQuickFiltersConfig, - PodsQuickFiltersConfig, - StatefulsetsQuickFiltersConfig, - VolumesQuickFiltersConfig, } from './constants'; import K8sDaemonSetsList from './DaemonSets/K8sDaemonSetsList'; import K8sDeploymentsList from './Deployments/K8sDeploymentsList'; @@ -74,6 +76,11 @@ export default function InfraMonitoringK8s(): JSX.Element { entityVersion: '', }); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const handleFilterChange = (query: Query): void => { // update the current query with the new filters // in infra monitoring k8s, we are using only one query, hence updating the 0th index of queryData @@ -109,7 +116,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -129,7 +136,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -152,7 +159,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -172,7 +179,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -192,7 +199,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -212,7 +219,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -232,7 +239,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -255,7 +262,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( @@ -275,7 +282,7 @@ export default function InfraMonitoringK8s(): JSX.Element { children: ( diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts index e7ea02246d..e8bed7671b 100644 --- a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts @@ -30,395 +30,415 @@ export const getJobMetricsQueryPayload = ( job: K8sJobsData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sPodCpuUtilizationKey = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + const k8sPodMemoryUsageKey = dotMetricsEnabled + ? 'k8s.pod.memory.usage' + : 'k8s_pod_memory_usage'; + const k8sPodNetworkIoKey = dotMetricsEnabled + ? 'k8s.pod.network.io' + : 'k8s_pod_network_io'; + const k8sPodNetworkErrorsKey = dotMetricsEnabled + ? 'k8s.pod.network.errors' + : 'k8s_pod_network_errors'; + const k8sJobNameKey = dotMetricsEnabled ? 'k8s.job.name' : 'k8s_job_name'; + const k8sNamespaceNameKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '6b59b690', + key: { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + op: '=', + value: job.jobName, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: job.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6b59b690', - key: { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - op: '=', - value: job.jobName, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: job.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '8c217f4d', - key: { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - op: '=', - value: job.jobName, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: job.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '8c217f4d', + key: { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + op: '=', + value: job.jobName, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: job.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '2bbf9d0c', - key: { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - op: '=', - value: job.jobName, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: job.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '448e6cf7', - key: { - dataType: DataTypes.String, - id: 'k8s_job_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_job_name', - type: 'tag', - }, - op: '=', - value: job.jobName, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: job.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '2bbf9d0c', + key: { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + op: '=', + value: job.jobName, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: job.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '448e6cf7', + key: { + dataType: DataTypes.String, + id: 'k8s_job_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sJobNameKey, + type: 'tag', + }, + op: '=', + value: job.jobName, + }, + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: job.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx index 9c9563e55a..b413cb5363 100644 --- a/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -132,6 +134,11 @@ function K8sJobsList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sJobsRowData, groupBy: IBuilderQuery['groupBy'], @@ -185,10 +192,15 @@ function K8sJobsList({ isLoading: isLoadingGroupedByRowData, isError: isErrorGroupedByRowData, refetch: fetchGroupedByRowData, - } = useGetK8sJobsList(fetchGroupedByRowDataQuery as K8sJobsListPayload, { - queryKey: ['jobList', fetchGroupedByRowDataQuery], - enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, - }); + } = useGetK8sJobsList( + fetchGroupedByRowDataQuery as K8sJobsListPayload, + { + queryKey: ['jobList', fetchGroupedByRowDataQuery], + enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, + }, + undefined, + dotMetricsEnabled, + ); const { data: groupByFiltersData, @@ -196,7 +208,10 @@ function K8sJobsList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.JOBS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.JOBS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -242,6 +257,8 @@ function K8sJobsList({ queryKey: ['jobList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const jobsData = useMemo(() => data?.payload?.data?.records || [], [data]); diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx index 1cc7555b76..b580969e57 100644 --- a/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx @@ -263,6 +263,12 @@ export const getK8sJobsListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.job.name': 'k8s_job_name', + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.cluster.name': 'k8s_cluster_name', +}; + const getGroupByEle = ( job: K8sJobsData, groupBy: IBuilderQuery['groupBy'], @@ -270,7 +276,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(job.meta[group.key as keyof typeof job.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof job.meta; + const value = job.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/Namespaces/K8sNamespacesList.tsx b/frontend/src/container/InfraMonitoringK8s/Namespaces/K8sNamespacesList.tsx index 4d2cc2a847..e1c1b6ecba 100644 --- a/frontend/src/container/InfraMonitoringK8s/Namespaces/K8sNamespacesList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Namespaces/K8sNamespacesList.tsx @@ -28,11 +28,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -136,6 +138,11 @@ function K8sNamespacesList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sNamespacesRowData, groupBy: IBuilderQuery['groupBy'], @@ -195,6 +202,8 @@ function K8sNamespacesList({ queryKey: ['namespaceList', fetchGroupedByRowDataQuery], enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, }, + undefined, + dotMetricsEnabled, ); const { @@ -203,8 +212,10 @@ function K8sNamespacesList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: - K8sEntityToAggregateAttributeMapping[K8sCategory.NAMESPACES], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.NAMESPACES, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -245,6 +256,8 @@ function K8sNamespacesList({ queryKey: ['namespaceList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const namespacesData = useMemo(() => data?.payload?.data?.records || [], [ diff --git a/frontend/src/container/InfraMonitoringK8s/Namespaces/NamespaceDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Namespaces/NamespaceDetails/constants.ts index f7b32c5e65..8c6f928e0f 100644 --- a/frontend/src/container/InfraMonitoringK8s/Namespaces/NamespaceDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Namespaces/NamespaceDetails/constants.ts @@ -54,1580 +54,1671 @@ export const getNamespaceMetricsQueryPayload = ( namespace: K8sNamespacesData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const getKey = (dotKey: string, underscoreKey: string): string => + dotMetricsEnabled ? dotKey : underscoreKey; + const k8sPodCpuUtilizationKey = getKey( + 'k8s.pod.cpu.utilization', + 'k8s_pod_cpu_utilization', + ); + const k8sContainerCpuRequestKey = getKey( + 'k8s.container.cpu_request', + 'k8s_container_cpu_request', + ); + const k8sPodMemoryUsageKey = getKey( + 'k8s.pod.memory.usage', + 'k8s_pod_memory_usage', + ); + const k8sContainerMemoryRequestKey = getKey( + 'k8s.container.memory_request', + 'k8s_container_memory_request', + ); + const k8sPodMemoryWorkingSetKey = getKey( + 'k8s.pod.memory.working_set', + 'k8s_pod_memory_working_set', + ); + const k8sPodMemoryRssKey = getKey('k8s.pod.memory.rss', 'k8s_pod_memory_rss'); + const k8sPodNetworkIoKey = getKey('k8s.pod.network.io', 'k8s_pod_network_io'); + const k8sPodNetworkErrorsKey = getKey( + 'k8s.pod.network.errors', + 'k8s_pod_network_errors', + ); + const k8sStatefulsetCurrentPodsKey = getKey( + 'k8s.statefulset.current_pods', + 'k8s_statefulset_current_pods', + ); + const k8sStatefulsetDesiredPodsKey = getKey( + 'k8s.statefulset.desired_pods', + 'k8s_statefulset_desired_pods', + ); + const k8sStatefulsetUpdatedPodsKey = getKey( + 'k8s.statefulset.updated_pods', + 'k8s_statefulset_updated_pods', + ); + const k8sReplicasetDesiredKey = getKey( + 'k8s.replicaset.desired', + 'k8s_replicaset_desired', + ); + const k8sReplicasetAvailableKey = getKey( + 'k8s.replicaset.available', + 'k8s_replicaset_available', + ); + const k8sDaemonsetDesiredScheduledNamespacesKey = getKey( + 'k8s.daemonset.desired.scheduled.namespaces', + 'k8s_daemonset_desired_scheduled_namespaces', + ); + const k8sDaemonsetCurrentScheduledNamespacesKey = getKey( + 'k8s.daemonset.current.scheduled.namespaces', + 'k8s_daemonset_current_scheduled_namespaces', + ); + const k8sDaemonsetReadyNamespacesKey = getKey( + 'k8s.daemonset.ready.namespaces', + 'k8s_daemonset_ready_namespaces', + ); + const k8sDaemonsetMisscheduledNamespacesKey = getKey( + 'k8s.daemonset.misscheduled.namespaces', + 'k8s_daemonset_misscheduled_namespaces', + ); + const k8sDeploymentDesiredKey = getKey( + 'k8s.deployment.desired', + 'k8s_deployment_desired', + ); + const k8sDeploymentAvailableKey = getKey( + 'k8s.deployment.available', + 'k8s_deployment_available', + ); + const k8sNamespaceNameKey = getKey('k8s.namespace.name', 'k8s_namespace_name'); + const k8sPodNameKey = getKey('k8s.pod.name', 'k8s_pod_name'); + const k8sStatefulsetNameKey = getKey( + 'k8s.statefulset.name', + 'k8s_statefulset_name', + ); + const k8sReplicasetNameKey = getKey( + 'k8s.replicaset.name', + 'k8s_replicaset_name', + ); + const k8sDaemonsetNameKey = getKey('k8s.daemonset.name', 'k8s_daemonset_name'); + const k8sDeploymentNameKey = getKey( + 'k8s.deployment.name', + 'k8s_deployment_name', + ); + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodCpuUtilizationKey, + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '47b3adae', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '93d2be5e', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sContainerCpuRequestKey, + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '93d2be5e', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '795eb679', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodCpuUtilizationKey, + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '795eb679', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (min)', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (min)', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '6792adbe', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodCpuUtilizationKey, + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '6792adbe', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (max)', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (max)', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '10011298', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryUsageKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '10011298', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'ea53b656', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sContainerMemoryRequestKey, + isColumn: true, + isJSON: false, + key: k8sContainerMemoryRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'ea53b656', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'request', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [], - having: [], - legend: 'request', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_working_set--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_working_set', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '674ace83', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryWorkingSetKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryWorkingSetKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '674ace83', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'working set', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'working set', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_rss--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_rss', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '187dbdb3', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryRssKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryRssKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '187dbdb3', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'rss', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'rss', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'E', - filters: { - items: [ - { - id: 'a3dbf468', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryUsageKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'E', + filters: { + items: [ + { + id: 'a3dbf468', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (min)', + limit: null, + orderBy: [], + queryName: 'E', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (min)', - limit: null, - orderBy: [], - queryName: 'E', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'F', - filters: { - items: [ - { - id: '4b2406c2', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryUsageKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'F', + filters: { + items: [ + { + id: '4b2406c2', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage (max)', + limit: null, + orderBy: [], + queryName: 'F', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', }, - functions: [], - groupBy: [], - having: [], - legend: 'usage (max)', - limit: null, - orderBy: [], - queryName: 'F', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'c3a73f0a', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodCpuUtilizationKey, + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c3a73f0a', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sPodNameKey, + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: `{{${k8sPodNameKey}}}`, + limit: 20, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: 20, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '5cad3379', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodMemoryUsageKey, + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '5cad3379', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sPodNameKey, + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: `{{${k8sPodNameKey}}}`, + limit: 10, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: 10, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '00f5c5e1', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sPodNetworkIoKey, + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '00f5c5e1', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'interface', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'direction', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.String, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '3aa8e064', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.String, + id: k8sPodNetworkErrorsKey, + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '3aa8e064', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'interface', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'direction', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_current_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_current_pods', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '5f2a55c5', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TABLE, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sStatefulsetCurrentPodsKey, + isColumn: true, + isJSON: false, + key: k8sStatefulsetCurrentPodsKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '5f2a55c5', + key: { + dataType: DataTypes.String, + id: k8sStatefulsetNameKey, + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sStatefulsetNameKey, + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'current', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sStatefulsetDesiredPodsKey, + isColumn: true, isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', + key: k8sStatefulsetDesiredPodsKey, + type: 'Gauge', }, - ], - having: [], - legend: 'current', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_desired_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_desired_pods', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '13bd7a1d', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '13bd7a1d', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sStatefulsetNameKey, + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'desired', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sStatefulsetUpdatedPodsKey, + isColumn: true, isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', + key: k8sStatefulsetUpdatedPodsKey, + type: 'Gauge', }, - ], - having: [], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_statefulset_updated_pods--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_statefulset_updated_pods', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '9d287c73', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '9d287c73', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sStatefulsetNameKey, + isColumn: false, + isJSON: false, + key: k8sStatefulsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'updated', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - ], - having: [], - legend: 'updated', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: true, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_replicaset_desired--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_replicaset_desired', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '0c1e655c', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TABLE, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sReplicasetDesiredKey, + isColumn: true, + isJSON: false, + key: k8sReplicasetDesiredKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '0c1e655c', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sReplicasetNameKey, + isColumn: false, + isJSON: false, + key: k8sReplicasetNameKey, + type: 'tag', }, ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_replicaset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_replicaset_name', - type: 'tag', - }, - ], - having: [ - { - columnName: 'MAX(k8s_replicaset_desired)', - op: '>', - value: 0, - }, - ], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_replicaset_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_replicaset_available', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ + having: [ { - id: 'b2296bdb', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: namespace.namespaceName, + columnName: `MAX(${k8sReplicasetDesiredKey})`, + op: '>', + value: 0, }, ], - op: 'AND', + legend: 'desired', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_replicaset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sReplicasetAvailableKey, + isColumn: true, isJSON: false, - key: 'k8s_replicaset_name', - type: 'tag', + key: k8sReplicasetAvailableKey, + type: 'Gauge', }, - ], - having: [ - { - columnName: 'MAX(k8s_replicaset_available)', - op: '>', - value: 0, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'b2296bdb', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, + }, + ], + op: 'AND', }, - ], - legend: 'available', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sReplicasetNameKey, + isColumn: false, + isJSON: false, + key: k8sReplicasetNameKey, + type: 'tag', + }, + ], + having: [ + { + columnName: `MAX(${k8sReplicasetDesiredKey})`, + op: '>', + value: 0, + }, + ], + legend: 'available', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: true, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_desired_scheduled_namespaces--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_desired_scheduled_namespaces', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '2964eb92', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TABLE, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDaemonsetDesiredScheduledNamespacesKey, + isColumn: true, + isJSON: false, + key: k8sDaemonsetDesiredScheduledNamespacesKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '2964eb92', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDaemonsetNameKey, + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'desired', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDaemonsetCurrentScheduledNamespacesKey, + isColumn: true, isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', + key: k8sDaemonsetCurrentScheduledNamespacesKey, + type: 'Gauge', }, - ], - having: [], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_current_scheduled_namespaces--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_current_scheduled_namespaces', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'cd324eff', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'cd324eff', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDaemonsetNameKey, + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'current', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDaemonsetReadyNamespacesKey, + isColumn: true, isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', + key: k8sDaemonsetReadyNamespacesKey, + type: 'Gauge', }, - ], - having: [], - legend: 'current', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_ready_namespaces--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_ready_namespaces', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '0416fa6f', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '0416fa6f', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDaemonsetNameKey, + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'ready', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDaemonsetMisscheduledNamespacesKey, + isColumn: true, isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', + key: k8sDaemonsetMisscheduledNamespacesKey, + type: 'Gauge', }, - ], - having: [], - legend: 'ready', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_daemonset_misscheduled_namespaces--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_daemonset_misscheduled_namespaces', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: 'c0a126d3', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: 'c0a126d3', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDaemonsetNameKey, + isColumn: false, + isJSON: false, + key: k8sDaemonsetNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'misscheduled', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_daemonset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_daemonset_name', - type: 'tag', - }, - ], - having: [], - legend: 'misscheduled', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: true, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TABLE, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_deployment_desired--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_deployment_desired', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '9bc659c1', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TABLE, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDeploymentDesiredKey, + isColumn: true, + isJSON: false, + key: k8sDeploymentDesiredKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '9bc659c1', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDeploymentNameKey, + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'desired', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: k8sDeploymentAvailableKey, + isColumn: true, isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', + key: k8sDeploymentAvailableKey, + type: 'Gauge', }, - ], - having: [], - legend: 'desired', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_deployment_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_deployment_available', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'e1696631', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'e1696631', + key: { + dataType: DataTypes.String, + id: k8sNamespaceNameKey, + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: namespace.namespaceName, }, - op: '=', - value: namespace.namespaceName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: k8sDeploymentNameKey, + isColumn: false, + isJSON: false, + key: k8sDeploymentNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: 'available', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'last', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_deployment_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_deployment_name', - type: 'tag', - }, - ], - having: [], - legend: 'available', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'last', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: 'util %', + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [ { disabled: false, - expression: 'A/B', - legend: 'util %', - queryName: 'F1', + legend: '', + name: 'A', + query: '', }, ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: true, + start, + end, }, - variables: {}, - formatForWeb: true, - start, - end, - }, -]; + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Namespaces/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Namespaces/utils.tsx index d566c86910..cf9e5cfb31 100644 --- a/frontend/src/container/InfraMonitoringK8s/Namespaces/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Namespaces/utils.tsx @@ -122,6 +122,11 @@ export const getK8sNamespacesListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.cluster.name': 'k8s_cluster_name', +}; + const getGroupByEle = ( namespace: K8sNamespacesData, groupBy: IBuilderQuery['groupBy'], @@ -129,7 +134,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(namespace.meta[group.key as keyof typeof namespace.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof namespace.meta; + const value = namespace.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/Nodes/K8sNodesList.tsx b/frontend/src/container/InfraMonitoringK8s/Nodes/K8sNodesList.tsx index 107a13454a..ca83a54e9b 100644 --- a/frontend/src/container/InfraMonitoringK8s/Nodes/K8sNodesList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Nodes/K8sNodesList.tsx @@ -28,11 +28,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -130,6 +132,11 @@ function K8sNodesList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sNodesRowData, groupBy: IBuilderQuery['groupBy'], @@ -183,10 +190,15 @@ function K8sNodesList({ isLoading: isLoadingGroupedByRowData, isError: isErrorGroupedByRowData, refetch: fetchGroupedByRowData, - } = useGetK8sNodesList(fetchGroupedByRowDataQuery as K8sNodesListPayload, { - queryKey: ['nodeList', fetchGroupedByRowDataQuery], - enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, - }); + } = useGetK8sNodesList( + fetchGroupedByRowDataQuery as K8sNodesListPayload, + { + queryKey: ['nodeList', fetchGroupedByRowDataQuery], + enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, + }, + undefined, + dotMetricsEnabled, + ); const { data: groupByFiltersData, @@ -194,7 +206,10 @@ function K8sNodesList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.NODES], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.NODES, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -240,6 +255,8 @@ function K8sNodesList({ queryKey: ['nodeList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const nodesData = useMemo(() => data?.payload?.data?.records || [], [data]); diff --git a/frontend/src/container/InfraMonitoringK8s/Nodes/NodeDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Nodes/NodeDetails/constants.ts index e491d03d3c..659fb0110b 100644 --- a/frontend/src/container/InfraMonitoringK8s/Nodes/NodeDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Nodes/NodeDetails/constants.ts @@ -54,1581 +54,1665 @@ export const getNodeMetricsQueryPayload = ( node: K8sNodesData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '441b62d7', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_cpu--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_cpu', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'b205b1a3', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '884c2bf3', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '98be9da1', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (max)', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'E', - filters: { - items: [ - { - id: 'ce97dd7b', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (min)', - limit: null, - orderBy: [], - queryName: 'E', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'fdffcbb2', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (avg)', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_memory--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_memory', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '9b79a8bd', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '3387fb4a', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: 'd1ad7ccb', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (max)', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'E', - filters: { - items: [ - { - id: '5e578329', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used (min)', - limit: null, - orderBy: [], - queryName: 'E', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_working_set--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_working_set', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'F', - filters: { - items: [ - { - id: '6ab3ec98', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'working set', - limit: null, - orderBy: [], - queryName: 'F', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_rss--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_rss', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'G', - filters: { - items: [ - { - id: '80c9a1db', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'rss', - limit: null, - orderBy: [], - queryName: 'G', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '752765ef', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_cpu--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_cpu', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: 'f0c5c1ed', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'C', - filters: { - items: [ - { - id: 'b952b389', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: 'used/allocatable', - queryName: 'F1', - }, - { - disabled: false, - expression: 'A/C', - legend: 'used/request', - queryName: 'F2', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'c2a2c926', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'used', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_memory--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_memory', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '20e6760c', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'allocatable', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'C', - filters: { - items: [ - { - id: 'fcc4d5e8', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: 'used/allocatable', - queryName: 'F1', - }, - { - disabled: false, - expression: 'A/C', - legend: 'used/request', - queryName: 'F2', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '88d38c06', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const getKey = (dotKey: string, underscoreKey: string): string => + dotMetricsEnabled ? dotKey : underscoreKey; + const k8sNodeCpuUtilizationKey = getKey( + 'k8s.node.cpu.utilization', + 'k8s_node_cpu_utilization', + ); + + const k8sNodeAllocatableCpuKey = getKey( + 'k8s.node.allocatable_cpu', + 'k8s_node_allocatable_cpu', + ); + + const k8sContainerCpuRequestKey = getKey( + 'k8s.container.cpu_request', + 'k8s_container_cpu_request', + ); + + const k8sNodeMemoryUsageKey = getKey( + 'k8s.node.memory.usage', + 'k8s_node_memory_usage', + ); + + const k8sNodeAllocatableMemoryKey = getKey( + 'k8s.node.allocatable_memory', + 'k8s_node_allocatable_memory', + ); + + const k8sContainerMemoryRequestKey = getKey( + 'k8s.container.memory_request', + 'k8s_container_memory_request', + ); + + const k8sNodeMemoryWorkingSetKey = getKey( + 'k8s.node.memory.working_set', + 'k8s_node_memory_working_set', + ); + + const k8sNodeMemoryRssKey = getKey( + 'k8s.node.memory.rss', + 'k8s_node_memory_rss', + ); + + const k8sPodCpuUtilizationKey = getKey( + 'k8s.pod.cpu.utilization', + 'k8s_pod_cpu_utilization', + ); + + const k8sPodMemoryUsageKey = getKey( + 'k8s.pod.memory.usage', + 'k8s_pod_memory_usage', + ); + + const k8sNodeNetworkErrorsKey = getKey( + 'k8s.node.network.errors', + 'k8s_node_network_errors', + ); + + const k8sNodeNetworkIoKey = getKey( + 'k8s.node.network.io', + 'k8s_node_network_io', + ); + + const k8sNodeFilesystemUsageKey = getKey( + 'k8s.node.filesystem.usage', + 'k8s_node_filesystem_usage', + ); + + const k8sNodeFilesystemCapacityKey = getKey( + 'k8s.node.filesystem.capacity', + 'k8s_node_filesystem_capacity', + ); + + const k8sNodeFilesystemAvailableKey = getKey( + 'k8s.node.filesystem.available', + 'k8s_node_filesystem_available', + ); + + const k8sNodeNameKey = getKey('k8s.node.name', 'k8s_node_name'); + + const k8sPodNameKey = getKey('k8s.pod.name', 'k8s_pod_name'); + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + key: k8sNodeCpuUtilizationKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: 10, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '43033387', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '441b62d7', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_cpu--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + key: k8sNodeAllocatableCpuKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: 10, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e9ce8079', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'b205b1a3', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'direction', - type: 'tag', + key: k8sContainerCpuRequestKey, + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '884c2bf3', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'interface', - type: 'tag', + key: k8sNodeCpuUtilizationKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'd62d103f', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '98be9da1', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (max)', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'direction', - type: 'tag', + key: k8sNodeCpuUtilizationKey, + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'E', + filters: { + items: [ + { + id: 'ce97dd7b', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (min)', + limit: null, + orderBy: [], + queryName: 'E', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_usage--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'interface', - type: 'tag', + key: k8sNodeMemoryUsageKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'fdffcbb2', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (avg)', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_memory--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocatableMemoryKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '9b79a8bd', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '3387fb4a', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: 'd1ad7ccb', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (max)', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'E', + filters: { + items: [ + { + id: '5e578329', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used (min)', + limit: null, + orderBy: [], + queryName: 'E', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_working_set--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemoryWorkingSetKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'F', + filters: { + items: [ + { + id: '6ab3ec98', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'working set', + limit: null, + orderBy: [], + queryName: 'F', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_rss--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemoryRssKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'G', + filters: { + items: [ + { + id: '80c9a1db', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'rss', + limit: null, + orderBy: [], + queryName: 'G', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'b85d3580', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: '752765ef', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'used', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_capacity', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '23f502e1', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_cpu--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocatableCpuKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'f0c5c1ed', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [], - having: [], - legend: 'capacity', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_available', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'b80650ec', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'C', + filters: { + items: [ + { + id: 'b952b389', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [], - having: [], - legend: 'available', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: 'used/allocatable', + queryName: 'F1', + }, + { + disabled: false, + expression: 'A/C', + legend: 'used/request', + queryName: 'F2', + }, + ], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'b85d3580', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'c2a2c926', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: 'used', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_capacity', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '23f502e1', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_node_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_memory--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocatableMemoryKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '20e6760c', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, }, - op: '=', - value: node.meta.k8s_node_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'allocatable', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', }, - functions: [], - groupBy: [], - having: [], - legend: 'capacity', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'C', + filters: { + items: [ + { + id: 'fcc4d5e8', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: 'used/allocatable', + queryName: 'F1', + }, + { + disabled: false, + expression: 'A/C', + legend: 'used/request', + queryName: 'F2', + }, + ], + }, + clickhouse_sql: [ { disabled: false, - expression: 'A/B', - legend: 'util %', - queryName: 'F1', + legend: '', + name: 'A', + query: '', }, ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilizationKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '88d38c06', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sPodNameKey}}}`, + limit: 10, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemoryUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '43033387', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sPodNameKey}}}`, + limit: 10, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sNodeNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'e9ce8079', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sNodeNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'd62d103f', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFilesystemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'b85d3580', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFilesystemCapacityKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '23f502e1', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'capacity', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFilesystemAvailableKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'b80650ec', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'available', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFilesystemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'b85d3580', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'used', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFilesystemCapacityKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '23f502e1', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: '=', + value: node.meta.k8s_node_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'capacity', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: 'util %', + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Nodes/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Nodes/utils.tsx index 361b42b7e2..96d475bd35 100644 --- a/frontend/src/container/InfraMonitoringK8s/Nodes/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Nodes/utils.tsx @@ -152,6 +152,12 @@ export const getK8sNodesListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.node.name': 'k8s_node_name', + 'k8s.cluster.name': 'k8s_cluster_name', + 'k8s.node.uid': 'k8s_node_uid', +}; + const getGroupByEle = ( node: K8sNodesData, groupBy: IBuilderQuery['groupBy'], @@ -159,7 +165,14 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(node.meta[group.key as keyof typeof node.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof node.meta; + + const value = node.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/Pods/K8sPodLists.tsx b/frontend/src/container/InfraMonitoringK8s/Pods/K8sPodLists.tsx index acbb003925..6173ffef77 100644 --- a/frontend/src/container/InfraMonitoringK8s/Pods/K8sPodLists.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Pods/K8sPodLists.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -118,13 +120,21 @@ function K8sPodsList({ [currentQuery?.builder?.queryData], ); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const { data: groupByFiltersData, isLoading: isLoadingGroupByFilters, } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.PODS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.PODS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -201,6 +211,8 @@ function K8sPodsList({ queryKey: ['hostList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const createFiltersForSelectedRowData = ( @@ -255,10 +267,15 @@ function K8sPodsList({ isLoading: isLoadingGroupedByRowData, isError: isErrorGroupedByRowData, refetch: fetchGroupedByRowData, - } = useGetK8sPodsList(fetchGroupedByRowDataQuery as K8sPodsListPayload, { - queryKey: ['hostList', fetchGroupedByRowDataQuery], - enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, - }); + } = useGetK8sPodsList( + fetchGroupedByRowDataQuery as K8sPodsListPayload, + { + queryKey: ['hostList', fetchGroupedByRowDataQuery], + enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, + }, + undefined, + dotMetricsEnabled, + ); const podsData = useMemo(() => data?.payload?.data?.records || [], [data]); const totalCount = data?.payload?.data?.total || 0; diff --git a/frontend/src/container/InfraMonitoringK8s/Pods/PodDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Pods/PodDetails/constants.ts index 4f8579af71..ca825d14f1 100644 --- a/frontend/src/container/InfraMonitoringK8s/Pods/PodDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Pods/PodDetails/constants.ts @@ -66,2607 +66,2721 @@ export const getPodMetricsQueryPayload = ( pod: K8sPodsData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e812bfd9', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - { - id: '067b2dc4', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Avg', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '37729a44', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - { - id: '379af416', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Max', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '481db9b1', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - { - id: '39ee0dbd', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Min', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '2ea54c80', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '755c8a9d', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Avg', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '7243d538', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '1e3d01ee', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Avg', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '3ec4e2b6', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '0c8b2662', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Max', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: 'abe996ed', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'e915da76', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Min', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'E', - filters: { - items: [ - { - id: '3addc70a', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '32c15c03', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Max', - limit: null, - orderBy: [], - queryName: 'E', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'F', - filters: { - items: [ - { - id: 'da9de2a8', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '703fced1', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Min', - limit: null, - orderBy: [], - queryName: 'F', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e6ca88fe', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '5418405c', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Avg', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'cd9de239', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '1ea5c602', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Max', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '952e535a', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'd7632974', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Min', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '65969a40', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '5a822bec', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Avg', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'bd3dcfd4', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '3362c603', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Avg', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '04f5aff6', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'ce88008b', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Max', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'D', - filters: { - items: [ - { - id: '8718a7d7', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '53fc92fd', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Max', - limit: null, - orderBy: [], - queryName: 'D', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'E', - filters: { - items: [ - { - id: '990f8296', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '61dfa9f6', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request util % - Min', - limit: null, - orderBy: [], - queryName: 'E', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'min', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'F', - filters: { - items: [ - { - id: '4c78ab5c', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '508cdf26', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util % - Min', - limit: null, - orderBy: [], - queryName: 'F', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'min', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_rss--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_rss', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'f66ff082', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '80528f79', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'RSS Memory', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_working_set--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_working_set', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '2cae58e7', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '780cc786', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Working Set Memory', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'B-A', - legend: 'Cache Memory', - queryName: 'F1', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_major_page_faults--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_major_page_faults', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '7ad40408', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '8b2a539b', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'major page faults', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'fdf017be', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '4b4382be', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const getKey = (dotKey: string, underscoreKey: string): string => + dotMetricsEnabled ? dotKey : underscoreKey; + const k8sContainerNameKey = getKey('k8s.container.name', 'k8s_container_name'); + + const k8sPodCpuUtilKey = getKey( + 'k8s.pod.cpu.utilization', + 'k8s_pod_cpu_utilization', + ); + + const k8sPodCpuReqUtilKey = getKey( + 'k8s.pod.cpu_request_utilization', + 'k8s_pod_cpu_request_utilization', + ); + + const k8sPodCpuLimitUtilKey = getKey( + 'k8s.pod.cpu_limit_utilization', + 'k8s_pod_cpu_limit_utilization', + ); + + const k8sPodMemUsageKey = getKey( + 'k8s.pod.memory.usage', + 'k8s_pod_memory_usage', + ); + + const k8sPodMemReqUtilKey = getKey( + 'k8s.pod.memory_request_utilization', + 'k8s_pod_memory_request_utilization', + ); + + const k8sPodMemLimitUtilKey = getKey( + 'k8s.pod.memory_limit_utilization', + 'k8s_pod_memory_limit_utilization', + ); + + const k8sPodMemRssKey = getKey('k8s.pod.memory.rss', 'k8s_pod_memory_rss'); + + const k8sPodMemWorkingSetKey = getKey( + 'k8s.pod.memory.working_set', + 'k8s_pod_memory_working_set', + ); + + const k8sPodMemMajorPFKey = getKey( + 'k8s.pod.memory.major_page_faults', + 'k8s_pod_memory_major_page_faults', + ); + + const containerCpuUtilKey = getKey( + 'container.cpu.utilization', + 'container_cpu_utilization', + ); + + const k8sContainerCpuRequestKey = getKey( + 'k8s.container.cpu_request', + 'k8s_container_cpu_request', + ); + + const k8sContainerCpuLimitKey = getKey( + 'k8s.container.cpu_limit', + 'k8s_container_cpu_limit', + ); + + const k8sContainerMemoryLimitKey = getKey( + 'k8s.container.memory_limit', + 'k8s_container_memory_limit', + ); + + const k8sContainerMemoryRequestKey = getKey( + 'k8s.container.memory_request', + 'k8s_container_memory_request', + ); + + const containerMemUsageKey = getKey( + 'container.memory.usage', + 'container_memory_usage', + ); + + const containerMemWorkingSetKey = getKey( + 'container.memory.working_set', + 'container_memory_working_set', + ); + + const containerMemRssKey = getKey( + 'container.memory.rss', + 'container_memory_rss', + ); + + const k8sPodNetworkIoKey = getKey('k8s.pod.network.io', 'k8s_pod_network_io'); + + const k8sPodNetworkErrorsKey = getKey( + 'k8s.pod.network.errors', + 'k8s_pod_network_errors', + ); + + const k8sPodFilesystemCapacityKey = getKey( + 'k8s.pod.filesystem.capacity', + 'k8s_pod_filesystem_capacity', + ); + + const k8sPodFilesystemAvailableKey = getKey( + 'k8s.pod.filesystem.available', + 'k8s_pod_filesystem_available', + ); + + const k8sPodFilesystemUsageKey = getKey( + 'k8s.pod.filesystem.usage', + 'k8s_pod_filesystem_usage', + ); + + const k8sPodNameKey = getKey('k8s.pod.name', 'k8s_pod_name'); + + const k8sNamespaceNameKey = getKey('k8s.namespace.name', 'k8s_namespace_name'); + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_container_name', - type: 'tag', + key: k8sPodCpuUtilKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{k8s_container_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'f0c71cba', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'e812bfd9', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '9301d7c0', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + { + id: '067b2dc4', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Avg', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_container_name', - type: 'tag', + key: k8sPodCpuUtilKey, + type: 'Gauge', }, - ], - having: [], + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '37729a44', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + { + id: '379af416', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Max', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '481db9b1', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + { + id: '39ee0dbd', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Min', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + name: 'A', + query: '', }, + ], + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '9b14868b', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '92b99374', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], + disabled: false, legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + name: 'A', + query: '', }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'C', - filters: { - items: [ - { - id: '1de8c8b9', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '1c7de95d', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_container_name', - type: 'tag', + key: k8sPodCpuReqUtilKey, + type: 'Gauge', }, - ], - having: [], + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '2ea54c80', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '755c8a9d', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Avg', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '7243d538', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '1e3d01ee', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Avg', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '3ec4e2b6', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '0c8b2662', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Max', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: 'abe996ed', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'e915da76', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Min', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'E', + filters: { + items: [ + { + id: '3addc70a', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '32c15c03', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Max', + limit: null, + orderBy: [], + queryName: 'E', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodCpuLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'F', + filters: { + items: [ + { + id: 'da9de2a8', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '703fced1', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Min', + limit: null, + orderBy: [], + queryName: 'F', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, legend: '', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + name: 'A', + query: '', }, ], - queryFormulas: [ + id: v4(), + promql: [ { disabled: false, - expression: 'A/B', - legend: 'Req % : {{k8s_container_name}} ', - queryName: 'F1', - }, - { - disabled: false, - expression: 'A/C', - legend: 'Limit % : {{k8s_container_name}} ', - queryName: 'F2', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'e8914a2d', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '964fd905', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], - legend: 'usage :: {{k8s_container_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_working_set--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_working_set', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'a2f69b5d', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '76a586be', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], - legend: 'working set :: {{k8s_container_name}}', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_rss--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_rss', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '95fc86d1', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '7c5f875b', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], - legend: 'rss :: {{k8s_container_name}}', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'c2d56c31', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '80216712', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + name: 'A', + query: '', }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: 'c04e7733', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '84b59a9f', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_container_name', - type: 'tag', + key: k8sPodMemUsageKey, + type: 'Gauge', }, - ], - having: [], + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'e6ca88fe', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '5418405c', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Avg', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'cd9de239', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '1ea5c602', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Max', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '952e535a', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'd7632974', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Min', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', + name: 'A', + query: '', }, + ], + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'C', - filters: { - items: [ - { - id: 'd1549857', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'd649ad0c', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_container_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_container_name', - type: 'tag', - }, - ], - having: [], + disabled: false, legend: '', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'max', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: 'Req % : {{k8s_container_name}} ', - queryName: 'F1', - }, - { - disabled: false, - expression: 'A/C', - legend: 'Limit % : {{k8s_container_name}} ', - queryName: 'F2', + name: 'A', + query: '', }, ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '65969a40', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '5a822bec', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Avg', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'bd3dcfd4', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '3362c603', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Avg', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '04f5aff6', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'ce88008b', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Max', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'D', + filters: { + items: [ + { + id: '8718a7d7', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '53fc92fd', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Max', + limit: null, + orderBy: [], + queryName: 'D', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'E', + filters: { + items: [ + { + id: '990f8296', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '61dfa9f6', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request util % - Min', + limit: null, + orderBy: [], + queryName: 'E', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'min', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'F', + filters: { + items: [ + { + id: '4c78ab5c', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '508cdf26', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util % - Min', + limit: null, + orderBy: [], + queryName: 'F', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'min', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '29bc6602', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'bc9c5cf3', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + id: v4(), + promql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '200e722b', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'b54a3d78', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_rss--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemRssKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f66ff082', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '80528f79', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'RSS Memory', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_working_set--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemWorkingSetKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: '2cae58e7', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '780cc786', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Working Set Memory', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'B-A', + legend: 'Cache Memory', + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [ { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_filesystem_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_filesystem_capacity', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '779f7a2e', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '1a97cb95', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Capacity', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_filesystem_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_filesystem_available', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'dd756bfe', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: 'ddfbd379', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Available', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_filesystem_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_filesystem_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: 'a5ac4705', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_namespace_name, - }, - { - id: '1963fc96', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: pod.meta.k8s_pod_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Uage', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', + legend: '', + name: 'A', + query: '', }, ], - queryFormulas: [], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_memory_major_page_faults--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodMemMajorPFKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '7ad40408', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '8b2a539b', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'major page faults', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerCpuUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'fdf017be', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '4b4382be', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: `{{${k8sContainerNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerCpuUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'f0c71cba', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '9301d7c0', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '9b14868b', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '92b99374', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'C', + filters: { + items: [ + { + id: '1de8c8b9', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '1c7de95d', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: `Req % : {{${k8sContainerNameKey}}} `, + queryName: 'F1', + }, + { + disabled: false, + expression: 'A/C', + legend: `Limit % : {{${k8sContainerNameKey}}}`, + queryName: 'F2', + }, + ], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'e8914a2d', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '964fd905', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: `usage :: {{${k8sContainerNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_working_set--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemWorkingSetKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'a2f69b5d', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '76a586be', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: `working set :: {{${k8sContainerNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_rss--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemRssKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: '95fc86d1', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '7c5f875b', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: `rss :: {{${k8sContainerNameKey}}}`, + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'c2d56c31', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '80216712', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'c04e7733', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '84b59a9f', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemoryLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'C', + filters: { + items: [ + { + id: 'd1549857', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'd649ad0c', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_container_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sContainerNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'max', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: `Req % : {{${k8sContainerNameKey}}} `, + queryName: 'F1', + }, + { + disabled: false, + expression: 'A/C', + legend: `Limit % : {{${k8sContainerNameKey}}} `, + queryName: 'F2', + }, + ], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '29bc6602', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'bc9c5cf3', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '200e722b', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'b54a3d78', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_filesystem_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodFilesystemCapacityKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '779f7a2e', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '1a97cb95', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Capacity', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_filesystem_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodFilesystemAvailableKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'dd756bfe', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: 'ddfbd379', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Available', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_filesystem_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodFilesystemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'a5ac4705', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_namespace_name, + }, + { + id: '1963fc96', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: pod.meta.k8s_pod_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Uage', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + id: v4(), + promql: [ + { + disabled: false, + legend: '', + name: 'A', + query: '', + }, + ], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx index e2dae778f6..1fb608b74c 100644 --- a/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -137,6 +139,11 @@ function K8sStatefulSetsList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sStatefulSetsRowData, groupBy: IBuilderQuery['groupBy'], @@ -196,6 +203,8 @@ function K8sStatefulSetsList({ queryKey: ['statefulSetList', fetchGroupedByRowDataQuery], enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, }, + undefined, + dotMetricsEnabled, ); const { @@ -204,8 +213,10 @@ function K8sStatefulSetsList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: - K8sEntityToAggregateAttributeMapping[K8sCategory.STATEFULSETS], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.STATEFULSETS, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -251,6 +262,8 @@ function K8sStatefulSetsList({ queryKey: ['statefulSetList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const statefulSetsData = useMemo(() => data?.payload?.data?.records || [], [ diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts index c1ae28dd77..e9deda80b8 100644 --- a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts @@ -38,909 +38,875 @@ export const getStatefulSetMetricsQueryPayload = ( statefulSet: K8sStatefulSetsData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '8627bd22', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '82f07131', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '9c669f4f', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '3c835082', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Reqs util %', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_cpu_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'c0a5e5b1', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limit util %', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'f8ae7d0f', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'usage', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '66fbdd5e', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'requests', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '1a408383', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'contains', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'limits', - limit: null, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_request_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_request_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'acdccfa2', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Reqs util %', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_memory_limit_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: 'cc9a85d3', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Limits util %', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '2ea33f83', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, - }, - { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sStatefulSetNameKey = dotMetricsEnabled + ? 'k8s.statefulset.name' + : 'k8s_statefulset_name'; + const k8sNamespaceNameKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const k8sPodNameKey = dotMetricsEnabled ? 'k8s.pod.name' : 'k8s_pod_name'; + + const k8sPodCpuUtilKey = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + const k8sContainerCpuRequestKey = dotMetricsEnabled + ? 'k8s.container.cpu_request' + : 'k8s_container_cpu_request'; + const k8sContainerCpuLimitKey = dotMetricsEnabled + ? 'k8s.container.cpu_limit' + : 'k8s_container_cpu_limit'; + const k8sPodCpuReqUtilKey = dotMetricsEnabled + ? 'k8s.pod.cpu_request_utilization' + : 'k8s_pod_cpu_request_utilization'; + const k8sPodCpuLimitUtilKey = dotMetricsEnabled + ? 'k8s.pod.cpu_limit_utilization' + : 'k8s_pod_cpu_limit_utilization'; + + const k8sPodMemUsageKey = dotMetricsEnabled + ? 'k8s.pod.memory.usage' + : 'k8s_pod_memory_usage'; + const k8sContainerMemRequestKey = dotMetricsEnabled + ? 'k8s.container.memory_request' + : 'k8s_container_memory_request'; + const k8sContainerMemLimitKey = dotMetricsEnabled + ? 'k8s.container.memory_limit' + : 'k8s_container_memory_limit'; + const k8sPodMemReqUtilKey = dotMetricsEnabled + ? 'k8s.pod.memory_request_utilization' + : 'k8s_pod_memory_request_utilization'; + const k8sPodMemLimitUtilKey = dotMetricsEnabled + ? 'k8s.pod.memory_limit_utilization' + : 'k8s_pod_memory_limit_utilization'; + + const k8sPodNetworkIoKey = dotMetricsEnabled + ? 'k8s.pod.network.io' + : 'k8s_pod_network_io'; + const k8sPodNetworkErrorsKey = dotMetricsEnabled + ? 'k8s.pod.network.errors' + : 'k8s_pod_network_errors'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'cpu_usage', + isColumn: true, isJSON: false, - key: 'direction', - type: 'tag', + key: k8sPodCpuUtilKey, + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_errors', - type: 'Sum', - }, - aggregateOperator: 'increase', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '7e25d4fb', - key: { - dataType: DataTypes.String, - id: 'k8s_statefulset_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_statefulset_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, }, - op: '=', - value: statefulSet.meta.k8s_statefulset_name, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'cpu_request', + isColumn: true, + isJSON: false, + key: k8sContainerCpuRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'f3', + key: { + dataType: DataTypes.String, + id: 'pod_name', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'cpu_limit', + isColumn: true, + isJSON: false, + key: k8sContainerCpuLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'f4', + key: { + dataType: DataTypes.String, + id: 'pod_name', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'cpu_req_util', + isColumn: true, + isJSON: false, + key: k8sPodCpuReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Reqs util %', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'cpu_limit_util', + isColumn: true, + isJSON: false, + key: k8sPodCpuLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limit util %', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'mem_usage', + isColumn: true, + isJSON: false, + key: k8sPodMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'usage', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'mem_request', + isColumn: true, + isJSON: false, + key: k8sContainerMemRequestKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'f3', + key: { + dataType: DataTypes.String, + id: 'pod_name', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'requests', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'mem_limit', + isColumn: true, + isJSON: false, + key: k8sContainerMemLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'f4', + key: { + dataType: DataTypes.String, + id: 'pod_name', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'contains', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'limits', + limit: null, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'mem_req_util', + isColumn: true, + isJSON: false, + key: k8sPodMemReqUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Reqs util %', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'mem_limit_util', + isColumn: true, + isJSON: false, + key: k8sPodMemLimitUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Limits util %', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'net_io', + isColumn: true, + isJSON: false, + key: k8sPodNetworkIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', }, { - id: '47b3adae', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: '=', - value: statefulSet.meta.k8s_namespace_name, + dataType: DataTypes.String, + id: 'interface', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - isJSON: false, - key: 'interface', - type: 'tag', - }, - ], - having: [], - legend: '{{direction}} :: {{interface}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'increase', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'net_err', + isColumn: true, + isJSON: false, + key: k8sPodNetworkErrorsKey, + type: 'Sum', + }, + aggregateOperator: 'increase', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'f1', + key: { + dataType: DataTypes.String, + id: 'ss_name', + isColumn: false, + isJSON: false, + key: k8sStatefulSetNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_statefulset_name, + }, + { + id: 'f2', + key: { + dataType: DataTypes.String, + id: 'ns_name', + isColumn: false, + isJSON: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: '=', + value: statefulSet.meta.k8s_namespace_name, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'interface', + isColumn: false, + isJSON: false, + key: 'interface', + type: 'tag', + }, + ], + having: [], + legend: '{{direction}} :: {{interface}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'increase', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx b/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx index 35730263c2..0e393e99bf 100644 --- a/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx @@ -236,6 +236,11 @@ export const getK8sStatefulSetsListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.statefulset.name': 'k8s_statefulset_name', +}; + const getGroupByEle = ( statefulSet: K8sStatefulSetsData, groupBy: IBuilderQuery['groupBy'], @@ -243,9 +248,14 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push( - statefulSet.meta[group.key as keyof typeof statefulSet.meta], - ); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? + rawKey) as keyof typeof statefulSet.meta; + const value = statefulSet.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx index aa9a1c69dd..dea58590f7 100644 --- a/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx @@ -29,11 +29,13 @@ import { AppState } from 'store/reducers'; import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getOrderByFromParams } from '../commonUtils'; import { + GetK8sEntityToAggregateAttribute, INFRA_MONITORING_K8S_PARAMS_KEYS, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from '../constants'; import K8sHeader from '../K8sHeader'; import LoadingContainer from '../LoadingContainer'; @@ -137,6 +139,11 @@ function K8sVolumesList({ } }, [quickFiltersLastUpdated]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const createFiltersForSelectedRowData = ( selectedRowData: K8sVolumesRowData, groupBy: IBuilderQuery['groupBy'], @@ -190,10 +197,15 @@ function K8sVolumesList({ isLoading: isLoadingGroupedByRowData, isError: isErrorGroupedByRowData, refetch: fetchGroupedByRowData, - } = useGetK8sVolumesList(fetchGroupedByRowDataQuery as K8sVolumesListPayload, { - queryKey: ['volumeList', fetchGroupedByRowDataQuery], - enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, - }); + } = useGetK8sVolumesList( + fetchGroupedByRowDataQuery as K8sVolumesListPayload, + { + queryKey: ['volumeList', fetchGroupedByRowDataQuery], + enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData, + }, + undefined, + dotMetricsEnabled, + ); const { data: groupByFiltersData, @@ -201,7 +213,10 @@ function K8sVolumesList({ } = useGetAggregateKeys( { dataSource: currentQuery.builder.queryData[0].dataSource, - aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.NODES], + aggregateAttribute: GetK8sEntityToAggregateAttribute( + K8sCategory.NODES, + dotMetricsEnabled, + ), aggregateOperator: 'noop', searchText: '', tagType: '', @@ -247,6 +262,8 @@ function K8sVolumesList({ queryKey: ['volumeList', query], enabled: !!query, }, + undefined, + dotMetricsEnabled, ); const volumesData = useMemo(() => data?.payload?.data?.records || [], [data]); diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts index 089c097937..d18d5aff6e 100644 --- a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts @@ -34,562 +34,521 @@ export const getVolumeQueryPayload = ( volume: K8sVolumesData, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_volume_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_volume_available', - type: 'Gauge', + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sClusterNameKey = dotMetricsEnabled + ? 'k8s.cluster.name' + : 'k8s_cluster_name'; + const k8sNamespaceNameKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const k8sVolumeAvailableKey = dotMetricsEnabled + ? 'k8s.volume.available' + : 'k8s_volume_available'; + const k8sVolumeCapacityKey = dotMetricsEnabled + ? 'k8s.volume.capacity' + : 'k8s_volume_capacity'; + const k8sVolumeInodesUsedKey = dotMetricsEnabled + ? 'k8s.volume.inodes.used' + : 'k8s_volume_inodes_used'; + const k8sVolumeInodesKey = dotMetricsEnabled + ? 'k8s.volume.inodes' + : 'k8s_volume_inodes'; + const k8sVolumeInodesFreeKey = dotMetricsEnabled + ? 'k8s.volume.inodes.free' + : 'k8s_volume_inodes_free'; + const k8sVolumeTypeKey = dotMetricsEnabled + ? 'k8s.volume.type' + : 'k8s_volume_type'; + const k8sPVCNameKey = dotMetricsEnabled + ? 'k8s.persistentvolumeclaim.name' + : 'k8s_persistentvolumeclaim_name'; + const legendTemplate = dotMetricsEnabled + ? '{{k8s.namespace.name}}-{{k8s.pod.name}}' + : '{{k8s_namespace_name}}-{{k8s_pod_name}}'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_volume_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sVolumeAvailableKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: volume.meta.k8s_cluster_name, + }, + { + id: 'c2', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: 'in', + value: [volume.meta.k8s_namespace_name], + }, + { + id: 'c3', + key: { + dataType: DataTypes.String, + id: 'k8s_volume_type--string--tag--false', + isColumn: false, + key: k8sVolumeTypeKey, + type: 'tag', + }, + op: 'in', + value: ['persistentVolumeClaim'], + }, + { + id: 'c4', + key: { + dataType: DataTypes.String, + id: 'k8s_persistentvolumeclaim_name--string--tag--false', + isColumn: false, + key: k8sPVCNameKey, + type: 'tag', + }, + op: '=', + value: volume.persistentVolumeClaimName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: legendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: volume.meta.k8s_cluster_name, - }, - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: 'in', - value: [volume.meta.k8s_namespace_name], - }, - { - id: '217757e9', - key: { - dataType: DataTypes.String, - id: 'k8s_volume_type--string--tag--false', - isColumn: false, - key: 'k8s_volume_type', - type: 'tag', - }, - op: 'in', - value: ['persistentVolumeClaim'], - }, - { - id: '34754bda', - key: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_persistentvolumeclaim_name--string--tag--false', - }, - op: '=', - value: volume.persistentVolumeClaimName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_volume_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_volume_capacity', - type: 'Gauge', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_volume_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sVolumeCapacityKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: volume.meta.k8s_cluster_name, + }, + { + id: 'c2', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: 'in', + value: [volume.meta.k8s_namespace_name], + }, + { + id: 'c3', + key: { + dataType: DataTypes.String, + id: 'k8s_volume_type--string--tag--false', + isColumn: false, + key: k8sVolumeTypeKey, + type: 'tag', + }, + op: 'in', + value: ['persistentVolumeClaim'], + }, + { + id: 'c4', + key: { + dataType: DataTypes.String, + id: 'k8s_persistentvolumeclaim_name--string--tag--false', + isColumn: false, + key: k8sPVCNameKey, + type: 'tag', + }, + op: '=', + value: volume.persistentVolumeClaimName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: legendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: volume.meta.k8s_cluster_name, - }, - { - id: '0cdebb88', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: 'in', - value: [volume.meta.k8s_namespace_name], - }, - { - id: 'e0e880ce', - key: { - dataType: DataTypes.String, - id: 'k8s_volume_type--string--tag--false', - isColumn: false, - key: 'k8s_volume_type', - type: 'tag', - }, - op: 'in', - value: ['persistentVolumeClaim'], - }, - { - id: '34754bda', - key: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_persistentvolumeclaim_name--string--tag--false', - }, - op: '=', - value: volume.persistentVolumeClaimName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_volume_inodes_used--float64----true', - isColumn: true, - key: 'k8s_volume_inodes_used', - type: '', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_volume_inodes_used--float64----true', + isColumn: true, + key: k8sVolumeInodesUsedKey, + type: '', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: volume.meta.k8s_cluster_name, + }, + { + id: 'c2', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: 'in', + value: [volume.meta.k8s_namespace_name], + }, + { + id: 'c3', + key: { + dataType: DataTypes.String, + id: 'k8s_volume_type--string--tag--false', + isColumn: false, + key: k8sVolumeTypeKey, + type: 'tag', + }, + op: 'in', + value: ['persistentVolumeClaim'], + }, + { + id: 'c4', + key: { + dataType: DataTypes.String, + id: 'k8s_persistentvolumeclaim_name--string--tag--false', + isColumn: false, + key: k8sPVCNameKey, + type: 'tag', + }, + op: '=', + value: volume.persistentVolumeClaimName, + }, + ], + op: 'AND', + }, + groupBy: [], + having: [], + legend: legendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + functions: [], }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: volume.meta.k8s_cluster_name, - }, - { - id: '46393c61', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: 'in', - value: [volume.meta.k8s_namespace_name], - }, - { - id: '450ee3cb', - key: { - dataType: DataTypes.String, - id: 'k8s_volume_type--string--tag--false', - isColumn: false, - key: 'k8s_volume_type', - type: 'tag', - }, - op: 'in', - value: ['persistentVolumeClaim'], - }, - { - id: '34754bda', - key: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_persistentvolumeclaim_name--string--tag--false', - }, - op: '=', - value: volume.persistentVolumeClaimName, - }, - ], - op: 'AND', - }, - groupBy: [], - having: [], - legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - functions: [], - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_volume_inodes--float64----true', - isColumn: true, - key: 'k8s_volume_inodes', - type: '', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_volume_inodes--float64----true', + isColumn: true, + key: k8sVolumeInodesKey, + type: '', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: volume.meta.k8s_cluster_name, + }, + { + id: 'c2', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: 'in', + value: [volume.meta.k8s_namespace_name], + }, + { + id: 'c3', + key: { + dataType: DataTypes.String, + id: 'k8s_volume_type--string--tag--false', + isColumn: false, + key: k8sVolumeTypeKey, + type: 'tag', + }, + op: 'in', + value: ['persistentVolumeClaim'], + }, + { + id: 'c4', + key: { + dataType: DataTypes.String, + id: 'k8s_persistentvolumeclaim_name--string--tag--false', + isColumn: false, + key: k8sPVCNameKey, + type: 'tag', + }, + op: '=', + value: volume.persistentVolumeClaimName, + }, + ], + op: 'AND', + }, + groupBy: [], + having: [], + legend: legendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + functions: [], }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: volume.meta.k8s_cluster_name, - }, - { - id: '5a604bad', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: 'in', - value: [volume.meta.k8s_namespace_name], - }, - { - id: '24b074f3', - key: { - dataType: DataTypes.String, - id: 'k8s_volume_type--string--tag--false', - isColumn: false, - key: 'k8s_volume_type', - type: 'tag', - }, - op: 'in', - value: ['persistentVolumeClaim'], - }, - { - id: '34754bda', - key: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_persistentvolumeclaim_name--string--tag--false', - }, - op: '=', - value: volume.persistentVolumeClaimName, - }, - ], - op: 'AND', - }, - groupBy: [], - having: [], - legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - functions: [], - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_volume_inodes_free--float64----true', - isColumn: true, - key: 'k8s_volume_inodes_free', - type: '', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_volume_inodes_free--float64----true', + isColumn: true, + key: k8sVolumeInodesFreeKey, + type: '', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'c1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: volume.meta.k8s_cluster_name, + }, + { + id: 'c2', + key: { + dataType: DataTypes.String, + id: 'k8s_namespace_name--string--tag--false', + isColumn: false, + key: k8sNamespaceNameKey, + type: 'tag', + }, + op: 'in', + value: [volume.meta.k8s_namespace_name], + }, + { + id: 'c3', + key: { + dataType: DataTypes.String, + id: 'k8s_volume_type--string--tag--false', + isColumn: false, + key: k8sVolumeTypeKey, + type: 'tag', + }, + op: 'in', + value: ['persistentVolumeClaim'], + }, + { + id: 'c4', + key: { + dataType: DataTypes.String, + id: 'k8s_persistentvolumeclaim_name--string--tag--false', + isColumn: false, + key: k8sPVCNameKey, + type: 'tag', + }, + op: '=', + value: volume.persistentVolumeClaimName, + }, + ], + op: 'AND', + }, + groupBy: [], + having: [], + legend: legendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + functions: [], }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6077fbc2', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: volume.meta.k8s_cluster_name, - }, - { - id: '8f01b14d', - key: { - dataType: DataTypes.String, - id: 'k8s_namespace_name--string--tag--false', - isColumn: false, - key: 'k8s_namespace_name', - type: 'tag', - }, - op: 'in', - value: [volume.meta.k8s_namespace_name], - }, - { - id: 'a72c99da', - key: { - dataType: DataTypes.String, - id: 'k8s_volume_type--string--tag--false', - isColumn: false, - key: 'k8s_volume_type', - type: 'tag', - }, - op: 'in', - value: ['persistentVolumeClaim'], - }, - { - id: '34754bda', - key: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_persistentvolumeclaim_name--string--tag--false', - }, - op: '=', - value: volume.persistentVolumeClaimName, - }, - ], - op: 'AND', - }, - groupBy: [], - having: [], - legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - functions: [], - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: v4(), + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: v4(), - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + ]; +}; diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx index 6b8db6ea48..a86dbbfeb7 100644 --- a/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx @@ -142,6 +142,16 @@ export const getK8sVolumesListColumns = ( return columnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.node.name': 'k8s_node_name', + 'k8s.pod.name': 'k8s_pod_name', + 'k8s.pod.uid': 'k8s_pod_uid', + 'k8s.statefulset.name': 'k8s_statefulset_name', + 'k8s.cluster.name': 'k8s_cluster_name', + 'k8s.persistentvolumeclaim.name': 'k8s_persistentvolumeclaim_name', +}; + const getGroupByEle = ( volume: K8sVolumesData, groupBy: IBuilderQuery['groupBy'], @@ -149,7 +159,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(volume.meta[group.key as keyof typeof volume.meta]); + const rawKey = group.key as string; + + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof volume.meta; + + const value = volume.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/InfraMonitoringK8s/constants.ts b/frontend/src/container/InfraMonitoringK8s/constants.ts index d182922421..6956b2637c 100644 --- a/frontend/src/container/InfraMonitoringK8s/constants.ts +++ b/frontend/src/container/InfraMonitoringK8s/constants.ts @@ -36,7 +36,7 @@ export const K8sCategories = { VOLUMES: 'volumes', }; -export const K8sEntityToAggregateAttributeMapping = { +export const underscoreMap = { [K8sCategory.HOSTS]: 'system_cpu_load_average_15m', [K8sCategory.PODS]: 'k8s_pod_cpu_utilization', [K8sCategory.NODES]: 'k8s_node_cpu_utilization', @@ -50,469 +50,654 @@ export const K8sEntityToAggregateAttributeMapping = { [K8sCategory.VOLUMES]: 'k8s_volume_capacity', }; -export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Pod', - attributeKey: { - key: 'k8s_pod_name', - dataType: DataTypes.String, - type: 'tag', - isColumn: false, - isJSON: false, - id: 'k8s_pod_name--string--tag--true', - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'Node', - attributeKey: { - key: 'k8s_node_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - id: 'k8s.node.name--string--resource--true', - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'Deployment', - attributeKey: { - key: 'k8s_deployment_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'Statefulset', - attributeKey: { - key: 'k8s_statefulset_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'DaemonSet', - attributeKey: { - key: 'k8s_daemonset_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, - { - type: FiltersType.CHECKBOX, - title: 'Job', - attributeKey: { - key: 'k8s_job_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: false, - }, -]; +export const dotMap = { + [K8sCategory.HOSTS]: 'system.cpu.load_average.15m', + [K8sCategory.PODS]: 'k8s.pod.cpu.utilization', + [K8sCategory.NODES]: 'k8s.node.cpu.utilization', + [K8sCategory.NAMESPACES]: 'k8s.pod.cpu.utilization', + [K8sCategory.CLUSTERS]: 'k8s.node.cpu.utilization', + [K8sCategory.DEPLOYMENTS]: 'k8s.pod.cpu.utilization', + [K8sCategory.STATEFULSETS]: 'k8s.pod.cpu.utilization', + [K8sCategory.DAEMONSETS]: 'k8s.pod.cpu.utilization', + [K8sCategory.CONTAINERS]: 'k8s.pod.cpu.utilization', + [K8sCategory.JOBS]: 'k8s.job.desired_successful_pods', + [K8sCategory.VOLUMES]: 'k8s.volume.capacity', +}; -export const NodesQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Node Name', - attributeKey: { - key: 'k8s_node_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; +export function GetK8sEntityToAggregateAttribute( + category: K8sCategory, + dotMetricsEnabled: boolean, +): string { + return dotMetricsEnabled ? dotMap[category] : underscoreMap[category]; +} -export const NamespaceQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; +export function GetPodsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const podKey = dotMetricsEnabled ? 'k8s.pod.name' : 'k8s_pod_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const nodeKey = dotMetricsEnabled ? 'k8s.node.name' : 'k8s_node_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const deploymentKey = dotMetricsEnabled + ? 'k8s.deployment.name' + : 'k8s_deployment_name'; + const statefulsetKey = dotMetricsEnabled + ? 'k8s.statefulset.name' + : 'k8s_statefulset_name'; + const daemonsetKey = dotMetricsEnabled + ? 'k8s.daemonset.name' + : 'k8s_daemonset_name'; + const jobKey = dotMetricsEnabled ? 'k8s.job.name' : 'k8s_job_name'; -export const ClustersQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; + // Define aggregate attribute (metric) name + const cpuUtilizationMetric = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; -export const ContainersQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Container', - attributeKey: { - key: 'k8s_container_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + return [ + { + type: FiltersType.CHECKBOX, + title: 'Pod', + attributeKey: { + key: podKey, + dataType: DataTypes.String, + type: 'tag', + isColumn: false, + isJSON: false, + id: `${podKey}--string--tag--true`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - defaultOpen: true, - }, -]; + { + type: FiltersType.CHECKBOX, + title: 'Namespace', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${namespaceKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'Node', + attributeKey: { + key: nodeKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${nodeKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'Deployment', + attributeKey: { + key: deploymentKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${deploymentKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'Statefulset', + attributeKey: { + key: statefulsetKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${statefulsetKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'DaemonSet', + attributeKey: { + key: daemonsetKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${daemonsetKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + { + type: FiltersType.CHECKBOX, + title: 'Job', + attributeKey: { + key: jobKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${jobKey}--string--resource--false`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilizationMetric, + dataSource: DataSource.METRICS, + defaultOpen: false, + }, + ]; +} -export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'PVC Volume Claim Name', - attributeKey: { - key: 'k8s_persistentvolumeclaim_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_volume_capacity', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_volume_capacity', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_volume_capacity', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; +export function GetNodesQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + // Define attribute keys + const nodeKey = dotMetricsEnabled ? 'k8s.node.name' : 'k8s_node_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; -export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Deployment Name', - attributeKey: { - key: 'k8s_deployment_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; + // Define aggregate metric name for node CPU utilization + const cpuUtilMetric = dotMetricsEnabled + ? 'k8s.node.cpu.utilization' + : 'k8s_node_cpu_utilization'; -export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Statefulset Name', - attributeKey: { - key: 'k8s_statefulset_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + return [ + { + type: FiltersType.CHECKBOX, + title: 'Node Name', + attributeKey: { + key: nodeKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${nodeKey}--string--resource--true`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource--true`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; + ]; +} -export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'DaemonSet Name', - attributeKey: { - key: 'k8s_daemonset_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, - }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; +export function GetNamespaceQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const cpuUtilMetric = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; -export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [ - { - type: FiltersType.CHECKBOX, - title: 'Job Name', - attributeKey: { - key: 'k8s_job_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + return [ + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${namespaceKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Namespace Name', - attributeKey: { - key: 'k8s_namespace_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, - { - type: FiltersType.CHECKBOX, - title: 'Cluster Name', - attributeKey: { - key: 'k8s_cluster_name', - dataType: DataTypes.String, - type: 'resource', - isColumn: false, - isJSON: false, + ]; +} + +export function GetClustersQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const cpuUtilMetric = dotMetricsEnabled + ? 'k8s.node.cpu.utilization' + : 'k8s_node_cpu_utilization'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: cpuUtilMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, }, - aggregateOperator: 'noop', - aggregateAttribute: 'k8s_pod_cpu_utilization', - dataSource: DataSource.METRICS, - defaultOpen: true, - }, -]; + ]; +} + +export function GetContainersQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const containerKey = dotMetricsEnabled + ? 'k8s.container.name' + : 'k8s_container_name'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Container', + attributeKey: { + key: containerKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${containerKey}--string--resource`, + }, + defaultOpen: true, + }, + ]; +} + +export function GetVolumesQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const pvcKey = dotMetricsEnabled + ? 'k8s.persistentvolumeclaim.name' + : 'k8s_persistentvolumeclaim_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const volumeMetric = dotMetricsEnabled + ? 'k8s.volume.capacity' + : 'k8s_volume_capacity'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'PVC Volume Claim Name', + attributeKey: { + key: pvcKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${pvcKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: volumeMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${namespaceKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: volumeMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: volumeMetric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} + +export function GetDeploymentsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const deployKey = dotMetricsEnabled + ? 'k8s.deployment.name' + : 'k8s_deployment_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const metric = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Deployment Name', + attributeKey: { + key: deployKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${deployKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${namespaceKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} + +export function GetStatefulsetsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const ssKey = dotMetricsEnabled + ? 'k8s.statefulset.name' + : 'k8s_statefulset_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const metric = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Statefulset Name', + attributeKey: { + key: ssKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${ssKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${namespaceKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${clusterKey}--string--resource`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metric, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} + +export function GetDaemonsetsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const nameKey = dotMetricsEnabled + ? 'k8s.daemonset.name' + : 'k8s_daemonset_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const metricName = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'DaemonSet Name', + attributeKey: { + key: nameKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${nameKey}--string--resource--true`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} + +export function GetJobsQuickFiltersConfig( + dotMetricsEnabled: boolean, +): IQuickFiltersConfig[] { + const nameKey = dotMetricsEnabled ? 'k8s.job.name' : 'k8s_job_name'; + const namespaceKey = dotMetricsEnabled + ? 'k8s.namespace.name' + : 'k8s_namespace_name'; + const clusterKey = dotMetricsEnabled ? 'k8s.cluster.name' : 'k8s_cluster_name'; + const metricName = dotMetricsEnabled + ? 'k8s.pod.cpu.utilization' + : 'k8s_pod_cpu_utilization'; + + return [ + { + type: FiltersType.CHECKBOX, + title: 'Job Name', + attributeKey: { + key: nameKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + id: `${nameKey}--string--resource--true`, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Namespace Name', + attributeKey: { + key: namespaceKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + { + type: FiltersType.CHECKBOX, + title: 'Cluster Name', + attributeKey: { + key: clusterKey, + dataType: DataTypes.String, + type: 'resource', + isColumn: false, + isJSON: false, + }, + aggregateOperator: 'noop', + aggregateAttribute: metricName, + dataSource: DataSource.METRICS, + defaultOpen: true, + }, + ]; +} export const getInvalidValueTooltipText = ( entity: K8sCategory, diff --git a/frontend/src/container/InfraMonitoringK8s/utils.tsx b/frontend/src/container/InfraMonitoringK8s/utils.tsx index fae703aaf8..976bda2ffa 100644 --- a/frontend/src/container/InfraMonitoringK8s/utils.tsx +++ b/frontend/src/container/InfraMonitoringK8s/utils.tsx @@ -299,6 +299,19 @@ export const getK8sPodsListColumns = ( return updatedColumnsConfig as ColumnType[]; }; +const dotToUnder: Record = { + 'k8s.cronjob.name': 'k8s_cronjob_name', + 'k8s.daemonset.name': 'k8s_daemonset_name', + 'k8s.deployment.name': 'k8s_deployment_name', + 'k8s.job.name': 'k8s_job_name', + 'k8s.namespace.name': 'k8s_namespace_name', + 'k8s.node.name': 'k8s_node_name', + 'k8s.pod.name': 'k8s_pod_name', + 'k8s.pod.uid': 'k8s_pod_uid', + 'k8s.statefulset.name': 'k8s_statefulset_name', + 'k8s.cluster.name': 'k8s_cluster_name', +}; + const getGroupByEle = ( pod: K8sPodsData, groupBy: IBuilderQuery['groupBy'], @@ -306,7 +319,13 @@ const getGroupByEle = ( const groupByValues: string[] = []; groupBy.forEach((group) => { - groupByValues.push(pod.meta[group.key as keyof typeof pod.meta]); + const rawKey = group.key as string; + + // Choose mapped key if present, otherwise use rawKey + const metaKey = (dotToUnder[rawKey] ?? rawKey) as keyof typeof pod.meta; + const value = pod.meta[metaKey]; + + groupByValues.push(value); }); return ( diff --git a/frontend/src/container/LogDetailedView/InfraMetrics/NodeMetrics.tsx b/frontend/src/container/LogDetailedView/InfraMetrics/NodeMetrics.tsx index 8c46d572fd..b62bd3c5b6 100644 --- a/frontend/src/container/LogDetailedView/InfraMetrics/NodeMetrics.tsx +++ b/frontend/src/container/LogDetailedView/InfraMetrics/NodeMetrics.tsx @@ -15,6 +15,8 @@ import { SuccessResponse } from 'types/api'; import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange'; import uPlot from 'uplot'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { getHostQueryPayload, getNodeQueryPayload, @@ -49,12 +51,23 @@ function NodeMetrics({ }; }, [logLineTimestamp]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const queryPayloads = useMemo(() => { if (nodeName) { - return getNodeQueryPayload(clusterName, nodeName, start, end); + return getNodeQueryPayload( + clusterName, + nodeName, + start, + end, + dotMetricsEnabled, + ); } - return getHostQueryPayload(hostName, start, end); - }, [nodeName, hostName, clusterName, start, end]); + return getHostQueryPayload(hostName, start, end, dotMetricsEnabled); + }, [nodeName, hostName, clusterName, start, end, dotMetricsEnabled]); const widgetInfo = nodeName ? nodeWidgetInfo : hostWidgetInfo; const queries = useQueries( diff --git a/frontend/src/container/LogDetailedView/InfraMetrics/PodMetrics.tsx b/frontend/src/container/LogDetailedView/InfraMetrics/PodMetrics.tsx index bb6ff0b654..00cdb4d196 100644 --- a/frontend/src/container/LogDetailedView/InfraMetrics/PodMetrics.tsx +++ b/frontend/src/container/LogDetailedView/InfraMetrics/PodMetrics.tsx @@ -8,6 +8,7 @@ import { useResizeObserver } from 'hooks/useDimensions'; import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults'; import { getUPlotChartOptions } from 'lib/uPlotLib/getUplotChartOptions'; import { getUPlotChartData } from 'lib/uPlotLib/utils/getUplotChartData'; +import { useAppContext } from 'providers/App/App'; import { useTimezone } from 'providers/Timezone'; import { useMemo, useRef } from 'react'; import { useQueries, UseQueryResult } from 'react-query'; @@ -15,6 +16,7 @@ import { SuccessResponse } from 'types/api'; import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange'; import uPlot from 'uplot'; +import { FeatureKeys } from '../../../constants/features'; import { getPodQueryPayload, podWidgetInfo } from './constants'; function PodMetrics({ @@ -41,9 +43,15 @@ function PodMetrics({ verticalLineTimestamp: logTimestamp.unix(), }; }, [logLineTimestamp]); + + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const queryPayloads = useMemo( - () => getPodQueryPayload(clusterName, podName, start, end), - [clusterName, end, podName, start], + () => getPodQueryPayload(clusterName, podName, start, end, dotMetricsEnabled), + [clusterName, end, podName, start, dotMetricsEnabled], ); const queries = useQueries( queryPayloads.map((payload) => ({ diff --git a/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts b/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts index 39130e7f56..ea9ada6d8e 100644 --- a/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts +++ b/frontend/src/container/LogDetailedView/InfraMetrics/constants.ts @@ -10,2953 +10,2645 @@ export const getPodQueryPayload = ( podName: string, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6e050953', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '60fe5e62', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '9b92756a-b445-45f8-90f4-d26f3ef28f8f', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'a4250695', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '3b2bc32b', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'a22c1e03-4876-4b3e-9a96-a3c3a28f9c0f', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '8426b52f', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '2f67240c', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '8c4667e1', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: 'b16e7306', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'in', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A*100/B', - legend: '{{k8s_pod_name}}', - queryName: 'F1', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '7bb3a6f5-d1c6-4f2e-9cc9-7dcc46db398f', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_cpu_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_cpu_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '0a862947', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: 'cd13fbf0', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: 'usage - {{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_cpu_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_cpu_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: 'bfb8acf7', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: 'e09ba819', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'in', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: 'limit - {{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A*100/B', - legend: '{{k8s_pod_name}}', - queryName: 'F1', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '6d5ccd81-0ea1-4fb9-a66b-7f0fe2f15165', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'ea3df3e7', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '39b21fe0', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'in', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_request--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_request', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '7401a4b9', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '7cdad1cb', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A*100/B', - legend: '{{k8s_pod_name}}', - queryName: 'F1', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '4d03a0ff-4fa5-4b19-b397-97f80ba9e0ac', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sClusterNameKey = dotMetricsEnabled + ? 'k8s.cluster.name' + : 'k8s_cluster_name'; + const k8sPodNameKey = dotMetricsEnabled ? 'k8s.pod.name' : 'k8s_pod_name'; + const containerCpuUtilKey = dotMetricsEnabled + ? 'container.cpu.utilization' + : 'container_cpu_utilization'; + const containerMemUsageKey = dotMetricsEnabled + ? 'container.memory.usage' + : 'container_memory_usage'; + const k8sContainerCpuReqKey = dotMetricsEnabled + ? 'k8s.container.cpu_request' + : 'k8s_container_cpu_request'; + const k8sContainerCpuLimitKey = dotMetricsEnabled + ? 'k8s.container.cpu_limit' + : 'k8s_container_cpu_limit'; + const k8sContainerMemReqKey = dotMetricsEnabled + ? 'k8s.container.memory_request' + : 'k8s_container_memory_request'; + const k8sContainerMemLimitKey = dotMetricsEnabled + ? 'k8s.container.memory_limit' + : 'k8s_container_memory_limit'; + const k8sPodFsAvailKey = dotMetricsEnabled + ? 'k8s.pod.filesystem.available' + : 'k8s_pod_filesystem_available'; + const k8sPodFsCapKey = dotMetricsEnabled + ? 'k8s.pod.filesystem.capacity' + : 'k8s_pod_filesystem_capacity'; + const k8sPodNetIoKey = dotMetricsEnabled + ? 'k8s.pod.network.io' + : 'k8s_pod_network_io'; + const podLegendTemplate = dotMetricsEnabled + ? '{{k8s.pod.name}}' + : '{{k8s_pod_name}}'; + const podLegendUsage = dotMetricsEnabled + ? 'usage - {{k8s.pod.name}}' + : 'usage - {{k8s_pod_name}}'; + const podLegendLimit = dotMetricsEnabled + ? 'limit - {{k8s.pod.name}}' + : 'limit - {{k8s_pod_name}}'; - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'container_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'container_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'f2a3175c', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerCpuUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '6e050953', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: 'fc17ff21', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', + { + id: '60fe5e62', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, }, - op: '=', - value: podName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: podLegendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_container_memory_limit--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_container_memory_limit', - type: 'Gauge', - }, - aggregateOperator: 'latest', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '175e96b7', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '1d9fbe48', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: 'in', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'k8s_pod_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'latest', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A*100/B', - legend: '{{k8s_pod_name}}', - queryName: 'F1', - }, - ], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '9b92756a-b445-45f8-90f4-d26f3ef28f8f', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'ad491f19-0f83-4dd4-bb8f-bec295c18d1b', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_filesystem_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_filesystem_available', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '877385bf', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '877385cd', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', - }, - op: '=', - value: podName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_usage--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + key: containerMemUsageKey, + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_filesystem_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_filesystem_capacity', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '877385bf', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'a4250695', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: '877385cd', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', + { + id: '3b2bc32b', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, }, - op: '=', - value: podName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: podLegendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'a22c1e03-4876-4b3e-9a96-a3c3a28f9c0f', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_cpu_utilization--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_pod_name', - type: 'tag', + key: containerCpuUtilKey, + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: '(B-A)/B', - legend: '{{k8s_pod_name}}', - queryName: 'F1', - }, - ], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '16908d4e-1565-4847-8d87-01ebb8fc494a', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - fillGaps: false, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_pod_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_pod_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '877385bf', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: '8426b52f', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: '9613b4da', - key: { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', + { + id: '2f67240c', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, }, - op: '=', - value: podName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_pod_name--string--tag--false', - isColumn: false, - key: 'k8s_pod_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuReqKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{k8s_pod_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '8c4667e1', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: 'b16e7306', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'in', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A*100/B', + legend: podLegendTemplate, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '7bb3a6f5-d1c6-4f2e-9cc9-7dcc46db398f', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '4b255d6d-4cde-474d-8866-f4418583c18b', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_cpu_utilization--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerCpuUtilKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: '0a862947', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: 'cd13fbf0', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: podLegendUsage, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_cpu_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerCpuLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'bfb8acf7', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: 'e09ba819', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'in', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: podLegendLimit, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A*100/B', + legend: podLegendTemplate, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '6d5ccd81-0ea1-4fb9-a66b-7f0fe2f15165', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'ea3df3e7', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '39b21fe0', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'in', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_request--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemReqKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '7401a4b9', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '7cdad1cb', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A*100/B', + legend: podLegendTemplate, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '4d03a0ff-4fa5-4b19-b397-97f80ba9e0ac', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'container_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: containerMemUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'f2a3175c', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: 'fc17ff21', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_container_memory_limit--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sContainerMemLimitKey, + type: 'Gauge', + }, + aggregateOperator: 'latest', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '175e96b7', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '1d9fbe48', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: 'in', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'latest', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A*100/B', + legend: podLegendTemplate, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'ad491f19-0f83-4dd4-bb8f-bec295c18d1b', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_filesystem_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodFsAvailKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: '877385bf', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '877385cd', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_filesystem_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sPodFsCapKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: '877385bf', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '877385cd', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: '(B-A)/B', + legend: podLegendTemplate, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '16908d4e-1565-4847-8d87-01ebb8fc494a', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + fillGaps: false, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_pod_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sPodNetIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: '877385bf', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, + }, + { + id: '9613b4da', + key: { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + op: '=', + value: podName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_pod_name--string--tag--false', + isColumn: false, + key: k8sPodNameKey, + type: 'tag', + }, + ], + having: [], + legend: podLegendTemplate, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '4b255d6d-4cde-474d-8866-f4418583c18b', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + ]; +}; export const getNodeQueryPayload = ( clusterName: string, nodeName: string, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_cpu_time--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_cpu_time', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '91223422', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', - }, - op: '=', - value: clusterName, - }, - { - id: '91223422', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: 'in', - value: nodeName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const k8sClusterNameKey = dotMetricsEnabled + ? 'k8s.cluster.name' + : 'k8s_cluster_name'; + const k8sNodeNameKey = dotMetricsEnabled ? 'k8s.node.name' : 'k8s_node_name'; + const k8sNodeCpuTimeKey = dotMetricsEnabled + ? 'k8s.node.cpu.time' + : 'k8s_node_cpu_time'; + const k8sNodeAllocCpuKey = dotMetricsEnabled + ? 'k8s.node.allocatable_cpu' + : 'k8s_node_allocatable_cpu'; + const k8sNodeMemWsKey = dotMetricsEnabled + ? 'k8s.node.memory.working_set' + : 'k8s_node_memory_working_set'; + const k8sNodeAllocMemKey = dotMetricsEnabled + ? 'k8s.node.allocatable_memory' + : 'k8s_node_allocatable_memory'; + const k8sNodeNetIoKey = dotMetricsEnabled + ? 'k8s.node.network.io' + : 'k8s_node_network_io'; + const k8sNodeFsAvailKey = dotMetricsEnabled + ? 'k8s.node.filesystem.available' + : 'k8s_node_filesystem_available'; + const k8sNodeFsCapKey = dotMetricsEnabled + ? 'k8s.node.filesystem.capacity' + : 'k8s_node_filesystem_capacity'; + const podLegend = dotMetricsEnabled + ? '{{k8s.node.name}}' + : '{{k8s_node_name}}'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_cpu_time--float64--Sum--true', + isColumn: true, isJSON: false, - key: 'k8s_node_name', - type: 'tag', + key: k8sNodeCpuTimeKey, + type: 'Sum', }, - ], - having: [], - legend: '{{k8s_node_name}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_cpu--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_cpu', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '9700f1d4', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'c_cluster', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: 'in', - value: nodeName, + { + id: 'c_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: podLegend, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_cpu--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'k8s_node_name', - type: 'tag', + key: k8sNodeAllocCpuKey, + type: 'Gauge', }, - ], - having: [], - legend: '{{k8s_node_name}}', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: '{{k8s_node_name}}', - queryName: 'F1', - }, - ], + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'cpu_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + isJSON: false, + key: k8sNodeNameKey, + type: 'tag', + }, + ], + having: [], + legend: podLegend, + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: podLegend, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '259295b5-774d-4b2e-8a4f-e5dd63e6c38d', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '259295b5-774d-4b2e-8a4f-e5dd63e6c38d', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + fillGaps: false, + formatForWeb: false, + start, + end, }, - variables: {}, - fillGaps: false, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_memory_working_set--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_memory_working_set', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'a9f58cf3', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_memory_working_set--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeMemWsKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'mem_cluster', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: '8430c9a0', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + { + id: 'mem_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, }, - op: 'in', - value: nodeName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_allocatable_memory--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeAllocMemKey, + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_allocatable_memory--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_allocatable_memory', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: 'cb274856', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'alloc_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, }, - op: 'in', - value: nodeName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: '{{k8s_node_name}}', - queryName: 'F1', - }, - ], + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: podLegend, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '486af4da-2a1a-4b8f-992c-eba098d3a6f9', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '486af4da-2a1a-4b8f-992c-eba098d3a6f9', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + fillGaps: false, + formatForWeb: false, + start, + end, }, - variables: {}, - fillGaps: false, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '91223422', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: k8sNodeNetIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'net_cluster', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, + { + id: 'net_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'interface--string--tag--false', + isColumn: false, + key: 'interface', + type: 'tag', }, { - id: '66308505', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', - }, - op: 'in', - value: nodeName, + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: `${podLegend}-{{interface}}-{{direction}}`, + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'interface--string--tag--false', - isColumn: false, - key: 'interface', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', - }, - ], - having: [], - legend: '{{k8s_node_name}}-{{interface}}-{{direction}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'b56143c0-7d2f-4425-97c5-65ad6fc87366', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'b56143c0-7d2f-4425-97c5-65ad6fc87366', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_available--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_available', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: '91223422', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_available--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFsAvailKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'fs_cluster', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: 'a5dffef6', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + { + id: 'fs_node', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, }, - op: 'in', - value: nodeName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'k8s_node_filesystem_capacity--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: k8sNodeFsCapKey, + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'k8s_node_filesystem_capacity--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'k8s_node_filesystem_capacity', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '91223422', - key: { - dataType: DataTypes.String, - id: 'k8s_cluster_name--string--tag--false', - isColumn: false, - key: 'k8s_cluster_name', - type: 'tag', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'fs_clusterB', + key: { + dataType: DataTypes.String, + id: 'k8s_cluster_name--string--tag--false', + isColumn: false, + key: k8sClusterNameKey, + type: 'tag', + }, + op: '=', + value: clusterName, }, - op: '=', - value: clusterName, - }, - { - id: 'c79d5a16', - key: { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', + { + id: 'fs_nodeB', + key: { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', + }, + op: 'in', + value: nodeName, }, - op: 'in', - value: nodeName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'k8s_node_name--string--tag--false', + isColumn: false, + key: k8sNodeNameKey, + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'sum', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'k8s_node_name--string--tag--false', - isColumn: false, - key: 'k8s_node_name', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'sum', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: '(B-A)/B', - legend: '{{k8s_node_name}}', - queryName: 'F1', - }, - ], + ], + queryFormulas: [ + { + disabled: false, + expression: '(B-A)/B', + legend: podLegend, + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '57eeac15-615c-4a71-9c61-8e0c0c76b045', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '57eeac15-615c-4a71-9c61-8e0c0c76b045', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + ]; +}; export const getHostQueryPayload = ( hostName: string, start: number, end: number, -): GetQueryResultsProps[] => [ - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_cpu_time--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_cpu_time', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'A', - filters: { - items: [ - { - id: 'ad316791', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', - }, - op: '=', - value: hostName, - }, - ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'state--string--tag--false', - isColumn: false, + dotMetricsEnabled: boolean, +): GetQueryResultsProps[] => { + const hostNameKey = dotMetricsEnabled ? 'host.name' : 'host_name'; + const cpuTimeKey = dotMetricsEnabled ? 'system.cpu.time' : 'system_cpu_time'; + const memUsageKey = dotMetricsEnabled + ? 'system.memory.usage' + : 'system_memory_usage'; + const load1mKey = dotMetricsEnabled + ? 'system.cpu.load_average.1m' + : 'system_cpu_load_average_1m'; + const load5mKey = dotMetricsEnabled + ? 'system.cpu.load_average.5m' + : 'system_cpu_load_average_5m'; + const load15mKey = dotMetricsEnabled + ? 'system.cpu.load_average.15m' + : 'system_cpu_load_average_15m'; + const netIoKey = dotMetricsEnabled ? 'system.network.io' : 'system_network_io'; + const netPktsKey = dotMetricsEnabled + ? 'system.network.packets' + : 'system_network_packets'; + const netErrKey = dotMetricsEnabled + ? 'system.network.errors' + : 'system_network_errors'; + const netDropKey = dotMetricsEnabled + ? 'system.network.dropped' + : 'system_network_dropped'; + const netConnKey = dotMetricsEnabled + ? 'system.network.connections' + : 'system_network_connections'; + const diskIoKey = dotMetricsEnabled ? 'system.disk.io' : 'system_disk_io'; + const diskOpTimeKey = dotMetricsEnabled + ? 'system.disk.operation_time' + : 'system_disk_operation_time'; + const diskPendingKey = dotMetricsEnabled + ? 'system.disk.pending_operations' + : 'system_disk_pending_operations'; + + return [ + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_cpu_time--float64--Sum--true', + isColumn: true, isJSON: false, - key: 'state', - type: 'tag', + key: cpuTimeKey, + type: 'Sum', }, - ], - having: [], - legend: '{{state}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_cpu_time--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_cpu_time', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: true, - expression: 'B', - filters: { - items: [ - { - id: '6baf116b', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'A', + filters: { + items: [ + { + id: 'cpu_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'state--string--tag--false', + isColumn: false, + isJSON: false, + key: 'state', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{state}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [], - having: [], - legend: '{{state}}', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [ - { - disabled: false, - expression: 'A/B', - legend: '{{state}}', - queryName: 'F1', - }, - ], + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_cpu_time--float64--Sum--true', + isColumn: true, + isJSON: false, + key: cpuTimeKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: true, + expression: 'B', + filters: { + items: [ + { + id: 'cpu_f2', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: '{{state}}', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [ + { + disabled: false, + expression: 'A/B', + legend: '{{state}}', + queryName: 'F1', + }, + ], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '315b15fa-ff0c-442f-89f8-2bf4fb1af2f2', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '315b15fa-ff0c-442f-89f8-2bf4fb1af2f2', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_memory_usage--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_memory_usage', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '8026009e', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_memory_usage--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: memUsageKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'mem_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'state--string--tag--false', + isColumn: false, + isJSON: false, + key: 'state', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{state}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'state--string--tag--false', - isColumn: false, - isJSON: false, - key: 'state', - type: 'tag', - }, - ], - having: [], - legend: '{{state}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '40218bfb-a9b7-4974-aead-5bf666e139bf', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '40218bfb-a9b7-4974-aead-5bf666e139bf', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_cpu_load_average_1m--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_cpu_load_average_1m', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '4167fbb1', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_cpu_load_average_1m--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: load1mKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'load1m_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: '1m', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: '1m', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_cpu_load_average_5m--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_cpu_load_average_5m', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [ - { - id: '0c2cfeca', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_cpu_load_average_5m--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: load5mKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { + items: [ + { + id: 'load5m_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: '5m', + limit: 30, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: '5m', - limit: 30, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_cpu_load_average_15m--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_cpu_load_average_15m', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'C', - filters: { - items: [ - { - id: '28693375', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_cpu_load_average_15m--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: load15mKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'C', + filters: { + items: [ + { + id: 'load15m_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, - }, - ], - op: 'AND', + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: '15m', + limit: 30, + orderBy: [], + queryName: 'C', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: '15m', - limit: 30, - orderBy: [], - queryName: 'C', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '8e6485ea-7018-43b0-ab27-b210f77b59ad', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '8e6485ea-7018-43b0-ab27-b210f77b59ad', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_network_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_network_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '3a03bc80', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_network_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: netIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'netio_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', }, ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - ], - having: [ - { - columnName: 'SUM(system_network_io)', - op: '>', - value: 0, - }, - ], - legend: '{{device}}::{{direction}}', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '47173220-44df-4ef6-87f4-31e333c180c7', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_network_packets--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_network_packets', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ + having: [ { - id: '3082ef53', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', - }, - op: '=', - value: hostName, + columnName: `SUM(${netIoKey})`, + op: '>', + value: 0, }, ], - op: 'AND', + legend: '{{device}}::{{direction}}', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - ], - having: [], - legend: '{{device}}::{{direction}}', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '47173220-44df-4ef6-87f4-31e333c180c7', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '62eedbc6-c8ad-4d13-80a8-129396e1d1dc', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_network_errors--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_network_errors', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '8859bc50', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_network_packets--float64--Sum--true', + isColumn: true, + isJSON: false, + key: netPktsKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'netpkts_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{device}}::{{direction}}', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - ], - having: [], - legend: '{{device}}::{{direction}}', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '62eedbc6-c8ad-4d13-80a8-129396e1d1dc', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '5ddb1b38-53bb-46f5-b4fe-fe832d6b9b24', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_network_dropped--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_network_dropped', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '40fec2e3', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_network_errors--float64--Sum--true', + isColumn: true, + isJSON: false, + key: netErrKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'neterr_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{device}}::{{direction}}', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - ], - having: [], - legend: '{{device}}::{{direction}}', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '5ddb1b38-53bb-46f5-b4fe-fe832d6b9b24', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'a849bcce-7684-4852-9134-530b45419b8f', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_network_connections--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_network_connections', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '87f665b5', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_network_dropped--float64--Sum--true', + isColumn: true, + isJSON: false, + key: netDropKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'netdrop_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{device}}::{{direction}}', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'protocol--string--tag--false', - isColumn: false, - isJSON: false, - key: 'protocol', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'state--string--tag--false', - isColumn: false, - isJSON: false, - key: 'state', - type: 'tag', - }, - ], - having: [], - legend: '{{protocol}}::{{state}}', - limit: 30, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'a849bcce-7684-4852-9134-530b45419b8f', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'ab685a3d-fa4c-4663-8d94-c452e59038f3', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_disk_io--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_disk_io', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: '6039199f', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_network_connections--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: netConnKey, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'netconn_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'protocol--string--tag--false', + isColumn: false, + isJSON: false, + key: 'protocol', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'state--string--tag--false', + isColumn: false, + isJSON: false, + key: 'state', + type: 'tag', }, ], - op: 'AND', + having: [], + legend: '{{protocol}}::{{state}}', + limit: 30, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'avg', }, - functions: [], - groupBy: [], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'ab685a3d-fa4c-4663-8d94-c452e59038f3', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '9bd40b51-0790-4cdd-9718-551b2ded5926', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_disk_operation_time--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_disk_operation_time', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'd21dc017', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_disk_io--float64--Sum--true', + isColumn: true, + isJSON: false, + key: diskIoKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'diskio_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '9bd40b51-0790-4cdd-9718-551b2ded5926', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, + }, + variables: {}, + formatForWeb: false, + start, + end, + }, + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_disk_operation_time--float64--Sum--true', + isColumn: true, + isJSON: false, + key: diskOpTimeKey, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'diskop_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, + }, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'direction--string--tag--false', + isColumn: false, + isJSON: false, + key: 'direction', + type: 'tag', }, ], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [ - { - columnName: 'SUM(system_disk_operation_time)', - op: '>', - value: 0, - }, - ], - legend: '{{device}}::{{direction}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], - }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '9c6d18ad-89ff-4e38-a15a-440e72ed6ca8', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, - }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_disk_pending_operations--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'system_disk_pending_operations', - type: 'Gauge', - }, - aggregateOperator: 'max', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ + having: [ { - id: 'a1023af9', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', - }, - op: '=', - value: hostName, + columnName: `SUM(${diskOpTimeKey})`, + op: '>', + value: 0, }, ], - op: 'AND', + legend: '{{device}}::{{direction}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - ], - having: [ - { - columnName: 'SUM(system_disk_pending_operations)', - op: '>', - value: 0, - }, - ], - legend: '{{device}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'max', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: '9c6d18ad-89ff-4e38-a15a-440e72ed6ca8', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: 'f4cfc2a5-78fc-42cc-8f4a-194c8c916132', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, - { - selectedTime: 'GLOBAL_TIME', - graphType: PANEL_TYPES.TIME_SERIES, - query: { - builder: { - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'system_disk_operation_time--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'system_disk_operation_time', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [ - { - id: 'd21dc017', - key: { - dataType: DataTypes.String, - id: 'host_name--string--tag--false', - isColumn: false, - isJSON: false, - key: 'host_name', - type: 'tag', + { + selectedTime: 'GLOBAL_TIME', + graphType: PANEL_TYPES.TIME_SERIES, + query: { + builder: { + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + id: 'system_disk_pending_operations--float64--Gauge--true', + isColumn: true, + isJSON: false, + key: diskPendingKey, + type: 'Gauge', + }, + aggregateOperator: 'max', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [ + { + id: 'diskpend_f1', + key: { + dataType: DataTypes.String, + id: 'host_name--string--tag--false', + isColumn: false, + isJSON: false, + key: hostNameKey, + type: 'tag', + }, + op: '=', + value: hostName, }, - op: '=', - value: hostName, + ], + op: 'AND', + }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'device--string--tag--false', + isColumn: false, + isJSON: false, + key: 'device', + type: 'tag', }, ], - op: 'AND', + having: [ + { + columnName: `SUM(${diskPendingKey})`, + op: '>', + value: 0, + }, + ], + legend: '{{device}}', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'max', }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'device--string--tag--false', - isColumn: false, - isJSON: false, - key: 'device', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'direction--string--tag--false', - isColumn: false, - isJSON: false, - key: 'direction', - type: 'tag', - }, - ], - having: [ - { - columnName: 'SUM(system_disk_operation_time)', - op: '>', - value: 0, - }, - ], - legend: '{{device}}::{{direction}}', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - queryFormulas: [], + ], + queryFormulas: [], + }, + clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }], + id: 'f4cfc2a5-78fc-42cc-8f4a-194c8c916132', + promql: [{ disabled: false, legend: '', name: 'A', query: '' }], + queryType: EQueryType.QUERY_BUILDER, }, - clickhouse_sql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - id: '9c6d18ad-89ff-4e38-a15a-440e72ed6ca8', - promql: [ - { - disabled: false, - legend: '', - name: 'A', - query: '', - }, - ], - queryType: EQueryType.QUERY_BUILDER, + variables: {}, + formatForWeb: false, + start, + end, }, - variables: {}, - formatForWeb: false, - start, - end, - }, -]; + ]; +}; export const podWidgetInfo = [ { diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts index f3124f0ad1..31beb654f0 100644 --- a/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts +++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/DBCallQueries.ts @@ -21,6 +21,7 @@ export const databaseCallsRPS = ({ servicename, legend, tagFilterItems, + dotMetricsEnabled, }: DatabaseCallsRPSProps): QueryBuilderData => { const autocompleteData: BaseAutocompleteData[] = [ { @@ -34,7 +35,7 @@ export const databaseCallsRPS = ({ { dataType: DataTypes.String, isColumn: false, - key: 'db_system', + key: dotMetricsEnabled ? WidgetKeys.Db_system : WidgetKeys.Db_system_norm, type: 'tag', }, ]; @@ -43,7 +44,9 @@ export const databaseCallsRPS = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -75,6 +78,7 @@ export const databaseCallsRPS = ({ export const databaseCallsAvgDuration = ({ servicename, tagFilterItems, + dotMetricsEnabled, }: DatabaseCallProps): QueryBuilderData => { const autocompleteDataA: BaseAutocompleteData = { key: WidgetKeys.SignozDbLatencySum, @@ -93,7 +97,9 @@ export const databaseCallsAvgDuration = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts index 6a7ab65906..a0b8d2674a 100644 --- a/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts +++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/ExternalQueries.ts @@ -33,6 +33,7 @@ export const externalCallErrorPercent = ({ servicename, legend, tagFilterItems, + dotMetricsEnabled, }: ExternalCallDurationByAddressProps): QueryBuilderData => { const autocompleteDataA: BaseAutocompleteData = { key: WidgetKeys.SignozExternalCallLatencyCount, @@ -51,7 +52,9 @@ export const externalCallErrorPercent = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -62,7 +65,7 @@ export const externalCallErrorPercent = ({ { id: '', key: { - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled ? WidgetKeys.StatusCode : WidgetKeys.StatusCodeNorm, dataType: DataTypes.Int64, isColumn: false, type: MetricsType.Tag, @@ -76,7 +79,9 @@ export const externalCallErrorPercent = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -121,6 +126,7 @@ export const externalCallErrorPercent = ({ export const externalCallDuration = ({ servicename, tagFilterItems, + dotMetricsEnabled, }: ExternalCallProps): QueryBuilderData => { const autocompleteDataA: BaseAutocompleteData = { dataType: DataTypes.Float64, @@ -144,7 +150,9 @@ export const externalCallDuration = ({ key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -184,6 +192,7 @@ export const externalCallRpsByAddress = ({ servicename, legend, tagFilterItems, + dotMetricsEnabled, }: ExternalCallDurationByAddressProps): QueryBuilderData => { const autocompleteData: BaseAutocompleteData[] = [ { @@ -200,7 +209,9 @@ export const externalCallRpsByAddress = ({ key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -231,6 +242,7 @@ export const externalCallDurationByAddress = ({ servicename, legend, tagFilterItems, + dotMetricsEnabled, }: ExternalCallDurationByAddressProps): QueryBuilderData => { const autocompleteDataA: BaseAutocompleteData = { dataType: DataTypes.Float64, @@ -253,7 +265,9 @@ export const externalCallDurationByAddress = ({ key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts index 0d2c05a349..977f1e05ea 100644 --- a/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts +++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/OverviewQueries.ts @@ -37,10 +37,18 @@ export const latency = ({ tagFilterItems, isSpanMetricEnable = false, topLevelOperationsRoute, + dotMetricsEnabled, }: LatencyProps): QueryBuilderData => { + const signozLatencyBucketMetrics = dotMetricsEnabled + ? WidgetKeys.Signoz_latency_bucket + : WidgetKeys.Signoz_latency_bucket_norm; + + const signozMetricsServiceName = dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm; const newAutoCompleteData: BaseAutocompleteData = { key: isSpanMetricEnable - ? WidgetKeys.Signoz_latency_bucket + ? signozLatencyBucketMetrics : WidgetKeys.DurationNano, dataType: DataTypes.Float64, isColumn: true, @@ -53,7 +61,7 @@ export const latency = ({ { id: '', key: { - key: isSpanMetricEnable ? WidgetKeys.Service_name : WidgetKeys.ServiceName, + key: isSpanMetricEnable ? signozMetricsServiceName : WidgetKeys.ServiceName, dataType: DataTypes.String, type: isSpanMetricEnable ? MetricsType.Resource : MetricsType.Tag, isColumn: !isSpanMetricEnable, @@ -295,23 +303,30 @@ export const apDexMetricsQueryBuilderQueries = ({ threashold, delta, metricsBuckets, + dotMetricsEnabled, }: ApDexMetricsQueryBuilderQueriesProps): QueryBuilderData => { const autoCompleteDataA: BaseAutocompleteData = { - key: WidgetKeys.SignozLatencyCount, + key: dotMetricsEnabled + ? WidgetKeys.SignozLatencyCount + : WidgetKeys.SignozLatencyCountNorm, dataType: DataTypes.Float64, isColumn: true, type: '', }; const autoCompleteDataB: BaseAutocompleteData = { - key: WidgetKeys.Signoz_latency_bucket, + key: dotMetricsEnabled + ? WidgetKeys.Signoz_latency_bucket + : WidgetKeys.Signoz_latency_bucket_norm, dataType: DataTypes.Float64, isColumn: true, type: '', }; const autoCompleteDataC: BaseAutocompleteData = { - key: WidgetKeys.Signoz_latency_bucket, + key: dotMetricsEnabled + ? WidgetKeys.Signoz_latency_bucket + : WidgetKeys.Signoz_latency_bucket_norm, dataType: DataTypes.Float64, isColumn: true, type: '', @@ -321,7 +336,9 @@ export const apDexMetricsQueryBuilderQueries = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Tag, @@ -347,7 +364,7 @@ export const apDexMetricsQueryBuilderQueries = ({ { id: '', key: { - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled ? WidgetKeys.StatusCode : WidgetKeys.StatusCodeNorm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Tag, @@ -369,7 +386,9 @@ export const apDexMetricsQueryBuilderQueries = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Tag, @@ -406,7 +425,7 @@ export const apDexMetricsQueryBuilderQueries = ({ { id: '', key: { - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled ? WidgetKeys.StatusCode : WidgetKeys.StatusCodeNorm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Tag, @@ -417,7 +436,9 @@ export const apDexMetricsQueryBuilderQueries = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Tag, @@ -482,10 +503,13 @@ export const operationPerSec = ({ servicename, tagFilterItems, topLevelOperations, + dotMetricsEnabled, }: OperationPerSecProps): QueryBuilderData => { const autocompleteData: BaseAutocompleteData[] = [ { - key: WidgetKeys.SignozLatencyCount, + key: dotMetricsEnabled + ? WidgetKeys.SignozLatencyCount + : WidgetKeys.SignozLatencyCountNorm, dataType: DataTypes.Float64, isColumn: true, type: '', @@ -497,7 +521,9 @@ export const operationPerSec = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -540,6 +566,7 @@ export const errorPercentage = ({ servicename, tagFilterItems, topLevelOperations, + dotMetricsEnabled, }: OperationPerSecProps): QueryBuilderData => { const autocompleteDataA: BaseAutocompleteData = { key: WidgetKeys.SignozCallsTotal, @@ -560,7 +587,9 @@ export const errorPercentage = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -582,7 +611,9 @@ export const errorPercentage = ({ { id: '', key: { - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.StatusCodeNorm, dataType: DataTypes.Int64, isColumn: false, type: MetricsType.Tag, @@ -597,7 +628,9 @@ export const errorPercentage = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, diff --git a/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts b/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts index 18f0d07a88..d996ebac5a 100644 --- a/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts +++ b/frontend/src/container/MetricsApplication/MetricsPageQueries/TopOperationQueries.ts @@ -21,9 +21,12 @@ import { getQueryBuilderQuerieswithFormula } from './MetricsPageQueriesFactory'; export const topOperationQueries = ({ servicename, + dotMetricsEnabled, }: TopOperationQueryFactoryProps): QueryBuilderData => { const latencyAutoCompleteData: BaseAutocompleteData = { - key: WidgetKeys.Signoz_latency_bucket, + key: dotMetricsEnabled + ? WidgetKeys.Signoz_latency_bucket + : WidgetKeys.Signoz_latency_bucket_norm, dataType: DataTypes.Float64, isColumn: true, type: '', @@ -37,7 +40,9 @@ export const topOperationQueries = ({ }; const numOfCallAutoCompleteData: BaseAutocompleteData = { - key: WidgetKeys.SignozLatencyCount, + key: dotMetricsEnabled + ? WidgetKeys.SignozLatencyCount + : WidgetKeys.SignozLatencyCountNorm, dataType: DataTypes.Float64, isColumn: true, type: '', @@ -47,7 +52,9 @@ export const topOperationQueries = ({ { id: '', key: { - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, dataType: DataTypes.String, isColumn: false, type: MetricsType.Resource, @@ -63,7 +70,9 @@ export const topOperationQueries = ({ key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -74,7 +83,7 @@ export const topOperationQueries = ({ key: { dataType: DataTypes.Int64, isColumn: false, - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled ? WidgetKeys.StatusCode : WidgetKeys.StatusCodeNorm, type: MetricsType.Tag, }, op: OPERATORS.IN, diff --git a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx index 45da3bfd58..ea6592817b 100644 --- a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx @@ -11,6 +11,7 @@ import { import useResourceAttribute from 'hooks/useResourceAttribute'; import { convertRawQueriesToTraceSelectedTags, + getResourceDeploymentKeys, resourceAttributesToTagFilterItems, } from 'hooks/useResourceAttribute/utils'; import { useSafeNavigate } from 'hooks/useSafeNavigate'; @@ -26,6 +27,8 @@ import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData'; import { EQueryType } from 'types/common/dashboard'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { GraphTitle, MENU_ITEMS, SERVICE_CHART_ID } from '../constant'; import { getWidgetQueryBuilder } from '../MetricsApplication.factory'; import { Card, GraphContainer, Row } from '../styles'; @@ -80,7 +83,12 @@ function DBCall(): JSX.Element { [queries], ); - const legend = '{{db_system}}'; + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + + const legend = dotMetricsEnabled ? '{{db.system}}' : '{{db_system}}'; const databaseCallsRPSWidget = useMemo( () => @@ -92,6 +100,7 @@ function DBCall(): JSX.Element { servicename, legend, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -102,7 +111,7 @@ function DBCall(): JSX.Element { id: SERVICE_CHART_ID.dbCallsRPS, fillSpans: false, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled, legend], ); const databaseCallsAverageDurationWidget = useMemo( () => @@ -113,6 +122,7 @@ function DBCall(): JSX.Element { builder: databaseCallsAvgDuration({ servicename, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -123,7 +133,7 @@ function DBCall(): JSX.Element { id: GraphTitle.DATABASE_CALLS_AVG_DURATION, fillSpans: true, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled], ); const stepInterval = useMemo( @@ -141,7 +151,7 @@ function DBCall(): JSX.Element { useEffect(() => { if (!logEventCalledRef.current) { const selectedEnvironments = queries.find( - (val) => val.tagKey === 'resource_deployment_environment', + (val) => val.tagKey === getResourceDeploymentKeys(dotMetricsEnabled), )?.tagValue; logEvent('APM: Service detail page visited', { diff --git a/frontend/src/container/MetricsApplication/Tabs/External.tsx b/frontend/src/container/MetricsApplication/Tabs/External.tsx index 501c63e76f..b77a8b8109 100644 --- a/frontend/src/container/MetricsApplication/Tabs/External.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/External.tsx @@ -13,6 +13,7 @@ import { import useResourceAttribute from 'hooks/useResourceAttribute'; import { convertRawQueriesToTraceSelectedTags, + getResourceDeploymentKeys, resourceAttributesToTagFilterItems, } from 'hooks/useResourceAttribute/utils'; import { useSafeNavigate } from 'hooks/useSafeNavigate'; @@ -28,6 +29,8 @@ import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse'; import { EQueryType } from 'types/common/dashboard'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { GraphTitle, legend, MENU_ITEMS } from '../constant'; import { getWidgetQueryBuilder } from '../MetricsApplication.factory'; import { Card, GraphContainer, Row } from '../styles'; @@ -75,6 +78,10 @@ function External(): JSX.Element { handleNonInQueryRange(resourceAttributesToTagFilterItems(queries)) || [], [queries], ); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; const externalCallErrorWidget = useMemo( () => @@ -86,6 +93,7 @@ function External(): JSX.Element { servicename, legend: legend.address, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -95,7 +103,7 @@ function External(): JSX.Element { yAxisUnit: '%', id: GraphTitle.EXTERNAL_CALL_ERROR_PERCENTAGE, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled], ); const selectedTraceTags = useMemo( @@ -112,6 +120,7 @@ function External(): JSX.Element { builder: externalCallDuration({ servicename, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -122,7 +131,7 @@ function External(): JSX.Element { id: GraphTitle.EXTERNAL_CALL_DURATION, fillSpans: true, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled], ); const errorApmToTraceQuery = useGetAPMToTracesQueries({ @@ -158,7 +167,7 @@ function External(): JSX.Element { useEffect(() => { if (!logEventCalledRef.current) { const selectedEnvironments = queries.find( - (val) => val.tagKey === 'resource_deployment_environment', + (val) => val.tagKey === getResourceDeploymentKeys(dotMetricsEnabled), )?.tagValue; logEvent('APM: Service detail page visited', { @@ -181,6 +190,7 @@ function External(): JSX.Element { servicename, legend: legend.address, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -191,7 +201,7 @@ function External(): JSX.Element { id: GraphTitle.EXTERNAL_CALL_RPS_BY_ADDRESS, fillSpans: true, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled], ); const externalCallDurationAddressWidget = useMemo( @@ -204,6 +214,7 @@ function External(): JSX.Element { servicename, legend: legend.address, tagFilterItems, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -214,7 +225,7 @@ function External(): JSX.Element { id: GraphTitle.EXTERNAL_CALL_DURATION_BY_ADDRESS, fillSpans: true, }), - [servicename, tagFilterItems], + [servicename, tagFilterItems, dotMetricsEnabled], ); const apmToTraceQuery = useGetAPMToTracesQueries({ diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx index 1492924249..b68a0cfd83 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx @@ -11,6 +11,7 @@ import { getQueryString } from 'container/SideNav/helper'; import useResourceAttribute from 'hooks/useResourceAttribute'; import { convertRawQueriesToTraceSelectedTags, + getResourceDeploymentKeys, resourceAttributesToTagFilterItems, } from 'hooks/useResourceAttribute/utils'; import { useSafeNavigate } from 'hooks/useSafeNavigate'; @@ -92,12 +93,15 @@ function Application(): JSX.Element { // eslint-disable-next-line react-hooks/exhaustive-deps [handleSetTimeStamp], ); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; const logEventCalledRef = useRef(false); useEffect(() => { if (!logEventCalledRef.current) { const selectedEnvironments = queries.find( - (val) => val.tagKey === 'resource_deployment_environment', + (val) => val.tagKey === getResourceDeploymentKeys(dotMetricsEnabled), )?.tagValue; logEvent('APM: Service detail page visited', { @@ -155,6 +159,7 @@ function Application(): JSX.Element { servicename, tagFilterItems, topLevelOperations: topLevelOperationsRoute, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -164,7 +169,7 @@ function Application(): JSX.Element { yAxisUnit: 'ops', id: SERVICE_CHART_ID.rps, }), - [servicename, tagFilterItems, topLevelOperationsRoute], + [servicename, tagFilterItems, topLevelOperationsRoute, dotMetricsEnabled], ); const errorPercentageWidget = useMemo( @@ -177,6 +182,7 @@ function Application(): JSX.Element { servicename, tagFilterItems, topLevelOperations: topLevelOperationsRoute, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -187,7 +193,7 @@ function Application(): JSX.Element { id: SERVICE_CHART_ID.errorPercentage, fillSpans: true, }), - [servicename, tagFilterItems, topLevelOperationsRoute], + [servicename, tagFilterItems, topLevelOperationsRoute, dotMetricsEnabled], ); const stepInterval = useMemo( diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx index dcd01270ee..f267545bbe 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Overview/ApDex/ApDexMetrics.tsx @@ -20,6 +20,8 @@ import { useParams } from 'react-router-dom'; import { EQueryType } from 'types/common/dashboard'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../../../../constants/features'; +import { useAppContext } from '../../../../../providers/App/App'; import { IServiceName } from '../../types'; import { ApDexMetricsProps } from './types'; @@ -34,7 +36,10 @@ function ApDexMetrics({ }: ApDexMetricsProps): JSX.Element { const { servicename: encodedServiceName } = useParams(); const servicename = decodeURIComponent(encodedServiceName); - + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; const apDexMetricsWidget = useMemo( () => getWidgetQueryBuilder({ @@ -48,6 +53,7 @@ function ApDexMetrics({ threashold: thresholdValue || 0, delta: delta || false, metricsBuckets: metricsBuckets || [], + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -73,6 +79,7 @@ function ApDexMetrics({ tagFilterItems, thresholdValue, topLevelOperationsRoute, + dotMetricsEnabled, ], ); diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx index 0b05246acc..fde5ac6946 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Overview/ServiceOverview.tsx @@ -56,6 +56,10 @@ function ServiceOverview({ [isSpanMetricEnable, queries], ); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const latencyWidget = useMemo( () => getWidgetQueryBuilder({ @@ -67,6 +71,7 @@ function ServiceOverview({ tagFilterItems, isSpanMetricEnable, topLevelOperationsRoute, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), @@ -76,7 +81,13 @@ function ServiceOverview({ yAxisUnit: 'ns', id: SERVICE_CHART_ID.latency, }), - [isSpanMetricEnable, servicename, tagFilterItems, topLevelOperationsRoute], + [ + isSpanMetricEnable, + servicename, + tagFilterItems, + topLevelOperationsRoute, + dotMetricsEnabled, + ], ); const isQueryEnabled = diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx index ed77512d89..30c99b9052 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Overview/TopOperationMetrics.tsx @@ -18,6 +18,8 @@ import { EQueryType } from 'types/common/dashboard'; import { GlobalReducer } from 'types/reducer/globalTime'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; import { IServiceName } from '../types'; import { title } from './config'; import ColumnWithLink from './TableRenderer/ColumnWithLink'; @@ -40,6 +42,11 @@ function TopOperationMetrics(): JSX.Element { convertRawQueriesToTraceSelectedTags(queries) || [], ); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const keyOperationWidget = useMemo( () => getWidgetQueryBuilder({ @@ -48,13 +55,14 @@ function TopOperationMetrics(): JSX.Element { promql: [], builder: topOperationQueries({ servicename, + dotMetricsEnabled, }), clickhouse_sql: [], id: uuid(), }, panelTypes: PANEL_TYPES.TABLE, }), - [servicename], + [servicename, dotMetricsEnabled], ); const updatedQuery = useStepInterval(keyOperationWidget.query); diff --git a/frontend/src/container/MetricsApplication/Tabs/types.ts b/frontend/src/container/MetricsApplication/Tabs/types.ts index 4dcb3bc01e..29032e704c 100644 --- a/frontend/src/container/MetricsApplication/Tabs/types.ts +++ b/frontend/src/container/MetricsApplication/Tabs/types.ts @@ -10,6 +10,7 @@ export interface IServiceName { export interface TopOperationQueryFactoryProps { servicename: IServiceName['servicename']; + dotMetricsEnabled: boolean; } export interface ExternalCallDurationByAddressProps extends ExternalCallProps { @@ -19,6 +20,7 @@ export interface ExternalCallDurationByAddressProps extends ExternalCallProps { export interface ExternalCallProps { servicename: IServiceName['servicename']; tagFilterItems: TagFilterItem[]; + dotMetricsEnabled: boolean; } export interface BuilderQueriesProps { @@ -50,6 +52,7 @@ export interface OperationPerSecProps { servicename: IServiceName['servicename']; tagFilterItems: TagFilterItem[]; topLevelOperations: string[]; + dotMetricsEnabled: boolean; } export interface LatencyProps { @@ -57,6 +60,7 @@ export interface LatencyProps { tagFilterItems: TagFilterItem[]; isSpanMetricEnable?: boolean; topLevelOperationsRoute: string[]; + dotMetricsEnabled: boolean; } export interface ApDexProps { @@ -74,4 +78,5 @@ export interface TableRendererProps { export interface ApDexMetricsQueryBuilderQueriesProps extends ApDexProps { delta: boolean; metricsBuckets: number[]; + dotMetricsEnabled: boolean; } diff --git a/frontend/src/container/MetricsApplication/constant.ts b/frontend/src/container/MetricsApplication/constant.ts index 1052a8d09a..957a6d9f89 100644 --- a/frontend/src/container/MetricsApplication/constant.ts +++ b/frontend/src/container/MetricsApplication/constant.ts @@ -85,12 +85,15 @@ export enum WidgetKeys { HasError = 'hasError', Address = 'address', DurationNano = 'durationNano', - StatusCode = 'status_code', + StatusCodeNorm = 'status_code', + StatusCode = 'status.code', Operation = 'operation', OperationName = 'operationName', - Service_name = 'service_name', + Service_name_norm = 'service_name', + Service_name = 'service.name', ServiceName = 'serviceName', - SignozLatencyCount = 'signoz_latency_count', + SignozLatencyCountNorm = 'signoz_latency_count', + SignozLatencyCount = 'signoz_latency.count', SignozDBLatencyCount = 'signoz_db_latency_count', DatabaseCallCount = 'signoz_database_call_count', DatabaseCallLatencySum = 'signoz_database_call_latency_sum', @@ -98,7 +101,10 @@ export enum WidgetKeys { SignozCallsTotal = 'signoz_calls_total', SignozExternalCallLatencyCount = 'signoz_external_call_latency_count', SignozExternalCallLatencySum = 'signoz_external_call_latency_sum', - Signoz_latency_bucket = 'signoz_latency_bucket', + Signoz_latency_bucket_norm = 'signoz_latency_bucket', + Signoz_latency_bucket = 'signoz_latency.bucket', + Db_system = 'db.system', + Db_system_norm = 'db_system', } export const topOperationMetricsDownloadOptions: DownloadOptions = { diff --git a/frontend/src/container/MetricsApplication/types.ts b/frontend/src/container/MetricsApplication/types.ts index 5f53204d27..3229ccfb23 100644 --- a/frontend/src/container/MetricsApplication/types.ts +++ b/frontend/src/container/MetricsApplication/types.ts @@ -25,10 +25,11 @@ export interface NavigateToTraceProps { } export interface DatabaseCallsRPSProps extends DatabaseCallProps { - legend: '{{db_system}}'; + legend: string; } export interface DatabaseCallProps { servicename: IServiceName['servicename']; tagFilterItems: TagFilterItem[]; + dotMetricsEnabled: boolean; } diff --git a/frontend/src/container/MetricsExplorer/Inspect/__tests__/Inspect.test.tsx b/frontend/src/container/MetricsExplorer/Inspect/__tests__/Inspect.test.tsx index c346420a7e..22a8a474c9 100644 --- a/frontend/src/container/MetricsExplorer/Inspect/__tests__/Inspect.test.tsx +++ b/frontend/src/container/MetricsExplorer/Inspect/__tests__/Inspect.test.tsx @@ -5,11 +5,13 @@ import { InspectMetricsSeries } from 'api/metricsExplorer/getInspectMetricsDetai import { MetricType } from 'api/metricsExplorer/getMetricsList'; import * as useInspectMetricsHooks from 'hooks/metricsExplorer/useGetInspectMetricsDetails'; import * as useGetMetricDetailsHooks from 'hooks/metricsExplorer/useGetMetricDetails'; +import * as appContextHooks from 'providers/App/App'; import { QueryClient, QueryClientProvider } from 'react-query'; import { Provider } from 'react-redux'; import store from 'store'; import ROUTES from '../../../../constants/routes'; +import { LicenseEvent } from '../../../../types/api/licensesV3/getActive'; import Inspect from '../Inspect'; import { InspectionStep } from '../types'; @@ -27,6 +29,30 @@ const mockTimeSeries: InspectMetricsSeries[] = [ }, ]; +jest.spyOn(appContextHooks, 'useAppContext').mockReturnValue({ + user: { + role: 'admin', + }, + activeLicenseV3: { + event_queue: { + created_at: '0', + event: LicenseEvent.NO_EVENT, + scheduled_at: '0', + status: '', + updated_at: '0', + }, + license: { + license_key: 'test-license-key', + license_type: 'trial', + org_id: 'test-org-id', + plan_id: 'test-plan-id', + plan_name: 'test-plan-name', + plan_type: 'trial', + plan_version: 'test-plan-version', + }, + }, +} as any); + jest.spyOn(useGetMetricDetailsHooks, 'useGetMetricDetails').mockReturnValue({ data: { metricDetails: { diff --git a/frontend/src/container/MetricsExplorer/Inspect/__tests__/QueryBuilder.test.tsx b/frontend/src/container/MetricsExplorer/Inspect/__tests__/QueryBuilder.test.tsx index 35e694d68c..389a726873 100644 --- a/frontend/src/container/MetricsExplorer/Inspect/__tests__/QueryBuilder.test.tsx +++ b/frontend/src/container/MetricsExplorer/Inspect/__tests__/QueryBuilder.test.tsx @@ -1,11 +1,13 @@ /* eslint-disable react/jsx-props-no-spreading */ import { render, screen } from '@testing-library/react'; import { MetricType } from 'api/metricsExplorer/getMetricsList'; +import * as appContextHooks from 'providers/App/App'; import { QueryClient, QueryClientProvider } from 'react-query'; import { Provider } from 'react-redux'; import store from 'store'; import ROUTES from '../../../../constants/routes'; +import { LicenseEvent } from '../../../../types/api/licensesV3/getActive'; import QueryBuilder from '../QueryBuilder'; import { InspectionStep, @@ -20,6 +22,30 @@ jest.mock('react-router-dom', () => ({ }), })); +jest.spyOn(appContextHooks, 'useAppContext').mockReturnValue({ + user: { + role: 'admin', + }, + activeLicenseV3: { + event_queue: { + created_at: '0', + event: LicenseEvent.NO_EVENT, + scheduled_at: '0', + status: '', + updated_at: '0', + }, + license: { + license_key: 'test-license-key', + license_type: 'trial', + org_id: 'test-org-id', + plan_id: 'test-plan-id', + plan_name: 'test-plan-name', + plan_type: 'trial', + plan_version: 'test-plan-version', + }, + }, +} as any); + const queryClient = new QueryClient(); describe('QueryBuilder', () => { diff --git a/frontend/src/container/MetricsExplorer/Views/Views.tsx b/frontend/src/container/MetricsExplorer/Views/Views.tsx deleted file mode 100644 index 4b2bf65263..0000000000 --- a/frontend/src/container/MetricsExplorer/Views/Views.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import * as Sentry from '@sentry/react'; -import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback'; - -function Views(): JSX.Element { - return ( - }> - Views - - ); -} - -export default Views; diff --git a/frontend/src/container/MetricsExplorer/Views/index.ts b/frontend/src/container/MetricsExplorer/Views/index.ts deleted file mode 100644 index 7893d1b90a..0000000000 --- a/frontend/src/container/MetricsExplorer/Views/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Views from './Views'; - -export default Views; diff --git a/frontend/src/container/PipelinePage/PipelineListsView/AddNewPipeline/index.tsx b/frontend/src/container/PipelinePage/PipelineListsView/AddNewPipeline/index.tsx index ba2938251c..a52858645d 100644 --- a/frontend/src/container/PipelinePage/PipelineListsView/AddNewPipeline/index.tsx +++ b/frontend/src/container/PipelinePage/PipelineListsView/AddNewPipeline/index.tsx @@ -1,6 +1,6 @@ -import { Button, Divider, Form, Modal } from 'antd'; +import { Button, Divider, Form, FormInstance, Modal } from 'antd'; import { useAppContext } from 'providers/App/App'; -import React, { useCallback, useEffect, useMemo } from 'react'; +import React, { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { ActionMode, ActionType, PipelineData } from 'types/api/pipeline/def'; import { v4 } from 'uuid'; @@ -10,6 +10,7 @@ import { getEditedDataSource, getRecordIndex } from '../utils'; import { renderPipelineForm } from './utils'; function AddNewPipeline({ + form, isActionType, setActionType, selectedPipelineData, @@ -17,22 +18,12 @@ function AddNewPipeline({ setCurrPipelineData, currPipelineData, }: AddNewPipelineProps): JSX.Element { - const [form] = Form.useForm(); const { t } = useTranslation('pipeline'); const { user } = useAppContext(); const isEdit = isActionType === 'edit-pipeline'; const isAdd = isActionType === 'add-pipeline'; - useEffect(() => { - if (isEdit) { - form.setFieldsValue(selectedPipelineData); - } - if (isAdd) { - form.resetFields(); - } - }, [form, isEdit, isAdd, selectedPipelineData]); - const onFinish = (values: PipelineData): void => { const newPipeLineData: PipelineData = { id: v4(), @@ -135,6 +126,7 @@ function AddNewPipeline({ } interface AddNewPipelineProps { + form: FormInstance; isActionType: string; setActionType: (actionType?: ActionType) => void; selectedPipelineData: PipelineData | undefined; diff --git a/frontend/src/container/PipelinePage/PipelineListsView/PipelineListsView.tsx b/frontend/src/container/PipelinePage/PipelineListsView/PipelineListsView.tsx index 43051f894c..71b353defe 100644 --- a/frontend/src/container/PipelinePage/PipelineListsView/PipelineListsView.tsx +++ b/frontend/src/container/PipelinePage/PipelineListsView/PipelineListsView.tsx @@ -1,7 +1,7 @@ import './styles.scss'; import { ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { Card, Modal, Table, Typography } from 'antd'; +import { Card, Form, Modal, Table, Typography } from 'antd'; import { ExpandableConfig } from 'antd/es/table/interface'; import logEvent from 'api/common/logEvent'; import savePipeline from 'api/pipeline/post'; @@ -95,6 +95,7 @@ function PipelineListsView({ pipelineData, refetchPipelineLists, }: PipelineListsViewProps): JSX.Element { + const [pipelineForm] = Form.useForm(); const { t } = useTranslation(['pipeline', 'common']); const [modal, contextHolder] = Modal.useModal(); const { notifications } = useNotifications(); @@ -179,8 +180,9 @@ function PipelineListsView({ (record: PipelineData) => (): void => { setActionType(ActionType.EditPipeline); setSelectedPipelineData(record); + pipelineForm.setFieldsValue(record); }, - [setActionType], + [setActionType, pipelineForm], ); const pipelineDeleteHandler = useCallback( @@ -382,12 +384,13 @@ function PipelineListsView({ const addNewPipelineHandler = useCallback((): void => { setActionType(ActionType.AddPipeline); + pipelineForm.resetFields(); logEvent('Logs: Pipelines: Clicked Add New Pipeline', { source: 'signoz-ui', }); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [setActionType]); + }, [setActionType, pipelineForm]); const footer = useCallback((): JSX.Element | undefined => { if (isEditingActionMode) { @@ -495,6 +498,7 @@ function PipelineListsView({ <> {contextHolder} { matchMedia(); }); +function AddNewPipelineWrapper(): JSX.Element { + const setActionType = jest.fn(); + const selectedPipelineData = pipelineMockData[0]; + const isActionType = 'add-pipeline'; + const [pipelineForm] = Form.useForm(); + + return ( + + ); +} + describe('PipelinePage container test', () => { it('should render AddNewPipeline section', () => { - const setActionType = jest.fn(); - const selectedPipelineData = pipelineMockData[0]; - const isActionType = 'add-pipeline'; - - const { asFragment } = render( - , - ); + const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); }); diff --git a/frontend/src/container/PipelinePage/tests/PipelineListsView.test.tsx b/frontend/src/container/PipelinePage/tests/PipelineListsView.test.tsx index e75c5634e5..2145de152f 100644 --- a/frontend/src/container/PipelinePage/tests/PipelineListsView.test.tsx +++ b/frontend/src/container/PipelinePage/tests/PipelineListsView.test.tsx @@ -1,4 +1,5 @@ /* eslint-disable sonarjs/no-duplicate-string */ +import { screen } from '@testing-library/react'; import { findByText, fireEvent, render, waitFor } from 'tests/test-utils'; import { pipelineApiResponseMockData } from '../mocks/pipeline'; @@ -243,4 +244,34 @@ describe('PipelinePage container test', () => { expect(saveBtn).toBeInTheDocument(); await fireEvent.click(saveBtn); }); + + it('should have populated form fields when edit pipeline is clicked', async () => { + render( + , + ); + + // content assertion + expect(document.querySelectorAll('[data-icon="edit"]').length).toBe(2); + + // expand action + const expandIcon = document.querySelectorAll( + '.ant-table-row-expand-icon-cell > span[class*="anticon-right"]', + ); + expect(expandIcon.length).toBe(2); + await fireEvent.click(expandIcon[0]); + + const editBtn = document.querySelectorAll('[data-icon="edit"]'); + // click on edit btn + await fireEvent.click(editBtn[0] as HTMLElement); + + // to have length 2 + expect(screen.queryAllByText('source = nginx').length).toBe(2); + }); }); diff --git a/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx b/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx index dc22801cea..14b8b5852f 100644 --- a/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx +++ b/frontend/src/container/QueryBuilder/filters/QueryBuilderSearch/index.tsx @@ -51,6 +51,8 @@ import { getUserOperatingSystem, UserOperatingSystem } from 'utils/getUserOS'; import { popupContainer } from 'utils/selectPopupContainer'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; import { selectStyle } from './config'; import { PLACEHOLDER } from './constant'; import ExampleQueriesRendererForLogs from './ExampleQueriesRendererForLogs'; @@ -85,6 +87,11 @@ function QueryBuilderSearch({ const [isEditingTag, setIsEditingTag] = useState(false); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const { updateTag, handleClearTag, @@ -104,6 +111,7 @@ function QueryBuilderSearch({ exampleQueries, } = useAutoComplete( query, + dotMetricsEnabled, whereClauseConfig, isLogsExplorerPage, isInfraMonitoring, @@ -121,6 +129,7 @@ function QueryBuilderSearch({ const { sourceKeys, handleRemoveSourceKey } = useFetchKeysAndValues( searchValue, query, + dotMetricsEnabled, searchKey, isLogsExplorerPage, isInfraMonitoring, diff --git a/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx b/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx index 93264dc4dd..a3c32d9901 100644 --- a/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx +++ b/frontend/src/container/ResourceAttributesFilter/ResourceAttributesFilter.tsx @@ -9,12 +9,15 @@ import { convertMetricKeyToTrace, getEnvironmentTagKeys, getEnvironmentTagValues, + getResourceDeploymentKeys, } from 'hooks/useResourceAttribute/utils'; import { ReactNode, useEffect, useMemo, useState } from 'react'; import { SelectOption } from 'types/common/select'; import { popupContainer } from 'utils/selectPopupContainer'; import { v4 as uuid } from 'uuid'; +import { FeatureKeys } from '../../constants/features'; +import { useAppContext } from '../../providers/App/App'; import QueryChip from './components/QueryChip'; import { QueryChipItem, SearchContainer } from './styles'; @@ -39,24 +42,27 @@ function ResourceAttributesFilter({ SelectOption[] >([]); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + + const resourceDeploymentKey = getResourceDeploymentKeys(dotMetricsEnabled); + const [selectedEnvironments, setSelectedEnvironments] = useState([]); const queriesExcludingEnvironment = useMemo( - () => - queries.filter( - (query) => query.tagKey !== 'resource_deployment_environment', - ), - [queries], + () => queries.filter((query) => query.tagKey !== resourceDeploymentKey), + [queries, resourceDeploymentKey], ); const isEmpty = useMemo( () => isResourceEmpty(queriesExcludingEnvironment, staging, selectedQuery), [queriesExcludingEnvironment, selectedQuery, staging], ); - useEffect(() => { const resourceDeploymentEnvironmentQuery = queries.filter( - (query) => query.tagKey === 'resource_deployment_environment', + (query) => query.tagKey === resourceDeploymentKey, ); if (resourceDeploymentEnvironmentQuery?.length > 0) { @@ -64,17 +70,17 @@ function ResourceAttributesFilter({ } else { setSelectedEnvironments([]); } - }, [queries]); + }, [queries, resourceDeploymentKey]); useEffect(() => { - getEnvironmentTagKeys().then((tagKeys) => { + getEnvironmentTagKeys(dotMetricsEnabled).then((tagKeys) => { if (tagKeys && Array.isArray(tagKeys) && tagKeys.length > 0) { - getEnvironmentTagValues().then((tagValues) => { + getEnvironmentTagValues(dotMetricsEnabled).then((tagValues) => { setEnvironments(tagValues); }); } }); - }, []); + }, [dotMetricsEnabled]); return (
diff --git a/frontend/src/container/ResourceAttributesFilter/components/QueryChip/QueryChip.tsx b/frontend/src/container/ResourceAttributesFilter/components/QueryChip/QueryChip.tsx index b2babd78b5..ac7a95f171 100644 --- a/frontend/src/container/ResourceAttributesFilter/components/QueryChip/QueryChip.tsx +++ b/frontend/src/container/ResourceAttributesFilter/components/QueryChip/QueryChip.tsx @@ -1,5 +1,10 @@ -import { convertMetricKeyToTrace } from 'hooks/useResourceAttribute/utils'; +import { + convertMetricKeyToTrace, + getResourceDeploymentKeys, +} from 'hooks/useResourceAttribute/utils'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; import { QueryChipContainer, QueryChipItem } from '../../styles'; import { IQueryChipProps } from './types'; @@ -8,12 +13,17 @@ function QueryChip({ queryData, onClose }: IQueryChipProps): JSX.Element { onClose(queryData.id); }; + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + return ( {convertMetricKeyToTrace(queryData.tagKey)} {queryData.operator} {queryData.tagValue.join(', ')} diff --git a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsApplication.tsx b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsApplication.tsx index 4d5889b909..4098b1d4d5 100644 --- a/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsApplication.tsx +++ b/frontend/src/container/ServiceApplication/ServiceMetrics/ServiceMetricsApplication.tsx @@ -3,6 +3,8 @@ import { useSelector } from 'react-redux'; import { AppState } from 'store/reducers'; import { GlobalReducer } from 'types/reducer/globalTime'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { ServiceMetricsProps } from '../types'; import { getQueryRangeRequestData } from '../utils'; import ServiceMetricTable from './ServiceMetricTable'; @@ -15,6 +17,11 @@ function ServiceMetricsApplication({ GlobalReducer >((state) => state.globalTime); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const queryRangeRequestData = useMemo( () => getQueryRangeRequestData({ @@ -22,8 +29,15 @@ function ServiceMetricsApplication({ minTime, maxTime, globalSelectedInterval, + dotMetricsEnabled, }), - [globalSelectedInterval, maxTime, minTime, topLevelOperations], + [ + globalSelectedInterval, + maxTime, + minTime, + topLevelOperations, + dotMetricsEnabled, + ], ); return ( { const p99AutoCompleteData: BaseAutocompleteData = { dataType: DataTypes.Float64, isColumn: true, - key: WidgetKeys.Signoz_latency_bucket, + key: dotMetricsEnabled + ? WidgetKeys.Signoz_latency_bucket + : WidgetKeys.Signoz_latency_bucket_norm, type: '', }; @@ -54,7 +57,9 @@ export const serviceMetricsQuery = ( key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -79,7 +84,9 @@ export const serviceMetricsQuery = ( key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -90,7 +97,7 @@ export const serviceMetricsQuery = ( key: { dataType: DataTypes.Int64, isColumn: false, - key: WidgetKeys.StatusCode, + key: dotMetricsEnabled ? WidgetKeys.StatusCode : WidgetKeys.StatusCodeNorm, type: MetricsType.Tag, }, op: OPERATORS.IN, @@ -115,7 +122,9 @@ export const serviceMetricsQuery = ( key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -140,7 +149,9 @@ export const serviceMetricsQuery = ( key: { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Resource, }, op: OPERATORS.IN, @@ -195,7 +206,9 @@ export const serviceMetricsQuery = ( { dataType: DataTypes.String, isColumn: false, - key: WidgetKeys.Service_name, + key: dotMetricsEnabled + ? WidgetKeys.Service_name + : WidgetKeys.Service_name_norm, type: MetricsType.Tag, }, ]; diff --git a/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx b/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx index 59c7a294bb..8b5c4c3e1b 100644 --- a/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx +++ b/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx @@ -5,7 +5,10 @@ import { SKIP_ONBOARDING } from 'constants/onboarding'; import useErrorNotification from 'hooks/useErrorNotification'; import { useQueryService } from 'hooks/useQueryService'; import useResourceAttribute from 'hooks/useResourceAttribute'; -import { convertRawQueriesToTraceSelectedTags } from 'hooks/useResourceAttribute/utils'; +import { + convertRawQueriesToTraceSelectedTags, + getResourceDeploymentKeys, +} from 'hooks/useResourceAttribute/utils'; import { isUndefined } from 'lodash-es'; import { useEffect, useMemo, useRef, useState } from 'react'; import { useSelector } from 'react-redux'; @@ -13,6 +16,8 @@ import { AppState } from 'store/reducers'; import { GlobalReducer } from 'types/reducer/globalTime'; import { Tags } from 'types/reducer/trace'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import SkipOnBoardingModal from '../SkipOnBoardModal'; import ServiceTraceTable from './ServiceTracesTable'; @@ -34,6 +39,11 @@ function ServiceTraces(): JSX.Element { selectedTags, }); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + useErrorNotification(error); const services = data || []; @@ -51,7 +61,7 @@ function ServiceTraces(): JSX.Element { useEffect(() => { if (!logEventCalledRef.current && !isUndefined(data)) { const selectedEnvironments = queries.find( - (val) => val.tagKey === 'resource_deployment_environment', + (val) => val.tagKey === getResourceDeploymentKeys(dotMetricsEnabled), )?.tagValue; const rps = data.reduce((total, service) => total + service.callRate, 0); diff --git a/frontend/src/container/ServiceApplication/types.ts b/frontend/src/container/ServiceApplication/types.ts index 4733b3053a..077ef90034 100644 --- a/frontend/src/container/ServiceApplication/types.ts +++ b/frontend/src/container/ServiceApplication/types.ts @@ -29,6 +29,7 @@ export interface GetQueryRangeRequestDataProps { maxTime: number; minTime: number; globalSelectedInterval: Time | TimeV2 | CustomTimeType; + dotMetricsEnabled: boolean; } export interface GetServiceListFromQueryProps { diff --git a/frontend/src/container/ServiceApplication/utils.ts b/frontend/src/container/ServiceApplication/utils.ts index f82c2df562..aef4cbb5f6 100644 --- a/frontend/src/container/ServiceApplication/utils.ts +++ b/frontend/src/container/ServiceApplication/utils.ts @@ -28,6 +28,7 @@ export const getQueryRangeRequestData = ({ maxTime, minTime, globalSelectedInterval, + dotMetricsEnabled, }: GetQueryRangeRequestDataProps): GetQueryResultsProps[] => { const requestData: GetQueryResultsProps[] = []; topLevelOperations.forEach((operation) => { @@ -35,7 +36,7 @@ export const getQueryRangeRequestData = ({ query: { queryType: EQueryType.QUERY_BUILDER, promql: [], - builder: serviceMetricsQuery(operation), + builder: serviceMetricsQuery(operation, dotMetricsEnabled), clickhouse_sql: [], id: uuid(), }, diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sClustersList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sClustersList.ts index 9b248688c7..55ee6df8c0 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sClustersList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sClustersList.ts @@ -17,6 +17,7 @@ type UseGetK8sClustersList = ( >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -28,6 +29,7 @@ export const useGetK8sClustersList: UseGetK8sClustersList = ( options, headers, + dotMetricsEnabled?: boolean, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -45,7 +47,8 @@ export const useGetK8sClustersList: UseGetK8sClustersList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sClustersList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sClustersList(requestData, signal, headers, dotMetricsEnabled), ...options, diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts index 5dde5d62fd..747603f3d4 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts @@ -17,6 +17,7 @@ type UseGetK8sDaemonSetsList = ( >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -28,6 +29,7 @@ export const useGetK8sDaemonSetsList: UseGetK8sDaemonSetsList = ( options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -45,7 +47,8 @@ export const useGetK8sDaemonSetsList: UseGetK8sDaemonSetsList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sDaemonSetsList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sDaemonSetsList(requestData, signal, headers, dotMetricsEnabled), ...options, diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sDeploymentsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sDeploymentsList.ts index 0b075c330d..ab3ceb4e23 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sDeploymentsList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sDeploymentsList.ts @@ -15,6 +15,7 @@ type UseGetK8sDeploymentsList = ( Error >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -24,6 +25,7 @@ export const useGetK8sDeploymentsList: UseGetK8sDeploymentsList = ( requestData, options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -41,7 +43,8 @@ export const useGetK8sDeploymentsList: UseGetK8sDeploymentsList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sDeploymentsList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sDeploymentsList(requestData, signal, headers, dotMetricsEnabled), ...options, queryKey, }); diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts index 942dc19bfe..962816b11a 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts @@ -17,6 +17,7 @@ type UseGetK8sJobsList = ( >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -28,6 +29,7 @@ export const useGetK8sJobsList: UseGetK8sJobsList = ( options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -42,7 +44,8 @@ export const useGetK8sJobsList: UseGetK8sJobsList = ( }, [options?.queryKey, requestData]); return useQuery | ErrorResponse, Error>({ - queryFn: ({ signal }) => getK8sJobsList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sJobsList(requestData, signal, headers, dotMetricsEnabled), ...options, diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sNamespacesList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sNamespacesList.ts index 24763b4657..611a153bb9 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sNamespacesList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sNamespacesList.ts @@ -15,6 +15,7 @@ type UseGetK8sNamespacesList = ( Error >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -24,6 +25,7 @@ export const useGetK8sNamespacesList: UseGetK8sNamespacesList = ( requestData, options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -41,7 +43,8 @@ export const useGetK8sNamespacesList: UseGetK8sNamespacesList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sNamespacesList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sNamespacesList(requestData, signal, headers, dotMetricsEnabled), ...options, queryKey, }); diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts index f88ffa113c..eda2d790b1 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sNodesList.ts @@ -15,6 +15,7 @@ type UseGetK8sNodesList = ( Error >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -24,6 +25,7 @@ export const useGetK8sNodesList: UseGetK8sNodesList = ( requestData, options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -38,7 +40,8 @@ export const useGetK8sNodesList: UseGetK8sNodesList = ( }, [options?.queryKey, requestData]); return useQuery | ErrorResponse, Error>({ - queryFn: ({ signal }) => getK8sNodesList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sNodesList(requestData, signal, headers, dotMetricsEnabled), ...options, queryKey, }); diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sPodsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sPodsList.ts index b7d4a4d6e7..274861242c 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sPodsList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sPodsList.ts @@ -15,6 +15,7 @@ type UseGetK8sPodsList = ( Error >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -24,6 +25,7 @@ export const useGetK8sPodsList: UseGetK8sPodsList = ( requestData, options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -38,7 +40,8 @@ export const useGetK8sPodsList: UseGetK8sPodsList = ( }, [options?.queryKey, requestData]); return useQuery | ErrorResponse, Error>({ - queryFn: ({ signal }) => getK8sPodsList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sPodsList(requestData, signal, headers, dotMetricsEnabled), ...options, queryKey, }); diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts index 941942cba1..b1684a207d 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts @@ -17,6 +17,7 @@ type UseGetK8sStatefulSetsList = ( >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -28,6 +29,7 @@ export const useGetK8sStatefulSetsList: UseGetK8sStatefulSetsList = ( options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -45,7 +47,8 @@ export const useGetK8sStatefulSetsList: UseGetK8sStatefulSetsList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sStatefulSetsList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sStatefulSetsList(requestData, signal, headers, dotMetricsEnabled), ...options, diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts index bc1c4961ea..5519ab8396 100644 --- a/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts +++ b/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts @@ -15,6 +15,7 @@ type UseGetK8sVolumesList = ( Error >, headers?: Record, + dotMetricsEnabled?: boolean, ) => UseQueryResult< SuccessResponse | ErrorResponse, Error @@ -24,6 +25,7 @@ export const useGetK8sVolumesList: UseGetK8sVolumesList = ( requestData, options, headers, + dotMetricsEnabled, ) => { const queryKey = useMemo(() => { if (options?.queryKey && Array.isArray(options.queryKey)) { @@ -41,7 +43,8 @@ export const useGetK8sVolumesList: UseGetK8sVolumesList = ( SuccessResponse | ErrorResponse, Error >({ - queryFn: ({ signal }) => getK8sVolumesList(requestData, signal, headers), + queryFn: ({ signal }) => + getK8sVolumesList(requestData, signal, headers, dotMetricsEnabled), ...options, queryKey, }); diff --git a/frontend/src/hooks/queryBuilder/useAutoComplete.ts b/frontend/src/hooks/queryBuilder/useAutoComplete.ts index 9977e328ae..c1903e0cd9 100644 --- a/frontend/src/hooks/queryBuilder/useAutoComplete.ts +++ b/frontend/src/hooks/queryBuilder/useAutoComplete.ts @@ -27,6 +27,7 @@ export type WhereClauseConfig = { export const useAutoComplete = ( query: IBuilderQuery, + dotMetricsEnabled: boolean, whereClauseConfig?: WhereClauseConfig, shouldUseSuggestions?: boolean, isInfraMonitoring?: boolean, @@ -39,6 +40,7 @@ export const useAutoComplete = ( const { keys, results, isFetching, exampleQueries } = useFetchKeysAndValues( searchValue, query, + dotMetricsEnabled, searchKey, shouldUseSuggestions, isInfraMonitoring, diff --git a/frontend/src/hooks/queryBuilder/useFetchKeysAndValues.ts b/frontend/src/hooks/queryBuilder/useFetchKeysAndValues.ts index b566f4330a..a690afe91f 100644 --- a/frontend/src/hooks/queryBuilder/useFetchKeysAndValues.ts +++ b/frontend/src/hooks/queryBuilder/useFetchKeysAndValues.ts @@ -4,8 +4,8 @@ import { getAttributesValues } from 'api/queryBuilder/getAttributesValues'; import { DATA_TYPE_VS_ATTRIBUTE_VALUES_KEY } from 'constants/queryBuilder'; import { DEBOUNCE_DELAY } from 'constants/queryBuilderFilterConfig'; import { + GetK8sEntityToAggregateAttribute, K8sCategory, - K8sEntityToAggregateAttributeMapping, } from 'container/InfraMonitoringK8s/constants'; import { getRemovePrefixFromKey, @@ -50,6 +50,7 @@ type IuseFetchKeysAndValues = { export const useFetchKeysAndValues = ( searchValue: string, query: IBuilderQuery, + dotMetricsEnabled: boolean, searchKey: string, shouldUseSuggestions?: boolean, isInfraMonitoring?: boolean, @@ -123,7 +124,7 @@ export const useFetchKeysAndValues = ( aggregateOperator: query.aggregateOperator, aggregateAttribute: isInfraMonitoring && entity - ? K8sEntityToAggregateAttributeMapping[entity] + ? GetK8sEntityToAggregateAttribute(entity, dotMetricsEnabled) : query.aggregateAttribute.key, tagType: query.aggregateAttribute.type ?? null, }, @@ -219,7 +220,7 @@ export const useFetchKeysAndValues = ( aggregateOperator: 'noop', dataSource: query.dataSource, aggregateAttribute: - K8sEntityToAggregateAttributeMapping[entity] || + GetK8sEntityToAggregateAttribute(entity, dotMetricsEnabled) || query.aggregateAttribute.key, attributeKey: filterAttributeKey?.key ?? tagKey, filterAttributeKeyDataType: diff --git a/frontend/src/hooks/useResourceAttribute/ResourceProvider.tsx b/frontend/src/hooks/useResourceAttribute/ResourceProvider.tsx index d7f712f563..bb4a024191 100644 --- a/frontend/src/hooks/useResourceAttribute/ResourceProvider.tsx +++ b/frontend/src/hooks/useResourceAttribute/ResourceProvider.tsx @@ -7,6 +7,8 @@ import { encode } from 'js-base64'; import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'; import { useLocation } from 'react-router-dom'; +import { FeatureKeys } from '../../constants/features'; +import { useAppContext } from '../../providers/App/App'; import { whilelistedKeys } from './config'; import { ResourceContext } from './context'; import { ResourceAttributesFilterMachine } from './machine'; @@ -18,6 +20,7 @@ import { import { createQuery, getResourceAttributeQueriesFromURL, + getResourceDeploymentKeys, GetTagKeys, GetTagValues, mappingWithRoutesAndKeys, @@ -53,6 +56,11 @@ function ResourceProvider({ children }: Props): JSX.Element { } }; + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const dispatchQueries = useCallback( (queries: IResourceAttribute[]): void => { urlQuery.set( @@ -70,7 +78,7 @@ function ResourceProvider({ children }: Props): JSX.Element { actions: { onSelectTagKey: () => { handleLoading(true); - GetTagKeys() + GetTagKeys(dotMetricsEnabled) .then((tagKeys) => { const options = mappingWithRoutesAndKeys(pathname, tagKeys); @@ -141,10 +149,10 @@ function ResourceProvider({ children }: Props): JSX.Element { const handleEnvironmentChange = useCallback( (environments: string[]): void => { - const staging = ['resource_deployment_environment', 'IN']; + const staging = [getResourceDeploymentKeys(dotMetricsEnabled), 'IN']; const queriesCopy = queries.filter( - (query) => query.tagKey !== 'resource_deployment_environment', + (query) => query.tagKey !== getResourceDeploymentKeys(dotMetricsEnabled), ); if (environments && Array.isArray(environments) && environments.length > 0) { @@ -159,7 +167,7 @@ function ResourceProvider({ children }: Props): JSX.Element { send('RESET'); }, - [dispatchQueries, queries, send], + [dispatchQueries, dotMetricsEnabled, queries, send], ); const handleClose = useCallback( diff --git a/frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.test.tsx b/frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.test.tsx index 2c4b3731a1..a63e318b70 100644 --- a/frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.test.tsx +++ b/frontend/src/hooks/useResourceAttribute/__tests__/useResourceAttribute.test.tsx @@ -1,10 +1,14 @@ import { act, renderHook, waitFor } from '@testing-library/react'; import { createMemoryHistory } from 'history'; +import { AppProvider } from 'providers/App/App'; +import { QueryClient, QueryClientProvider } from 'react-query'; import { Router } from 'react-router-dom'; import ResourceProvider from '../ResourceProvider'; import useResourceAttribute from '../useResourceAttribute'; +const queryClient = new QueryClient(); + jest.mock('hooks/useSafeNavigate', () => ({ useSafeNavigate: (): any => ({ safeNavigate: jest.fn(), @@ -17,9 +21,13 @@ describe('useResourceAttribute component hook', () => { initialEntries: ['/inital-url?tab=overview'], }); const wrapper = ({ children }: { children: any }): JSX.Element => ( - - {children} - + + + + {children} + + + ); const { result } = renderHook(() => useResourceAttribute(), { wrapper }); diff --git a/frontend/src/hooks/useResourceAttribute/utils.ts b/frontend/src/hooks/useResourceAttribute/utils.ts index 9c644221ec..d0878c6f2b 100644 --- a/frontend/src/hooks/useResourceAttribute/utils.ts +++ b/frontend/src/hooks/useResourceAttribute/utils.ts @@ -146,7 +146,17 @@ export const OperatorSchema: IOption[] = OperatorConversions.map( }), ); -export const GetTagKeys = async (): Promise => { +export const getResourceDeploymentKeys = ( + dotMetricsEnabled: boolean, +): string => { + if (dotMetricsEnabled) return 'resource_deployment.environment'; + return 'resource_deployment_environment'; +}; + +export const GetTagKeys = async ( + dotMetricsEnabled: boolean, +): Promise => { + const resourceDeploymentKey = getResourceDeploymentKeys(dotMetricsEnabled); const { payload } = await getResourceAttributesTagKeys({ metricName: 'signoz_calls_total', match: 'resource_', @@ -159,17 +169,19 @@ export const GetTagKeys = async (): Promise => { payload.data.attributeKeys?.map((attributeKey) => attributeKey.key) || []; return keys - .filter((tagKey: string) => tagKey !== 'resource_deployment_environment') + .filter((tagKey: string) => tagKey !== resourceDeploymentKey) .map((tagKey: string) => ({ label: convertMetricKeyToTrace(tagKey), value: tagKey, })); }; -export const getEnvironmentTagKeys = async (): Promise => { +export const getEnvironmentTagKeys = async ( + dotMetricsEnabled: boolean, +): Promise => { const { payload } = await getResourceAttributesTagKeys({ metricName: 'signoz_calls_total', - match: 'resource_deployment_environment', + match: getResourceDeploymentKeys(dotMetricsEnabled), }); if (!payload || !payload?.data) { return []; @@ -182,9 +194,11 @@ export const getEnvironmentTagKeys = async (): Promise => { })); }; -export const getEnvironmentTagValues = async (): Promise => { +export const getEnvironmentTagValues = async ( + dotMetricsEnabled: boolean, +): Promise => { const { payload } = await getResourceAttributesTagValues({ - tagKey: 'resource_deployment_environment', + tagKey: getResourceDeploymentKeys(dotMetricsEnabled), metricName: 'signoz_calls_total', }); diff --git a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricColumnGraphs.tsx b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricColumnGraphs.tsx index a2c1cdc48f..44da6fb45b 100644 --- a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricColumnGraphs.tsx +++ b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricColumnGraphs.tsx @@ -4,22 +4,24 @@ import { useIsDarkMode } from 'hooks/useDarkMode'; import { useTranslation } from 'react-i18next'; import { Widgets } from 'types/api/dashboard/getAll'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; import MetricPageGridGraph from './MetricPageGraph'; import { - averageRequestLatencyWidgetData, - brokerCountWidgetData, - brokerNetworkThroughputWidgetData, - bytesConsumedWidgetData, - consumerFetchRateWidgetData, - consumerGroupMemberWidgetData, - consumerLagByGroupWidgetData, - consumerOffsetWidgetData, - ioWaitTimeWidgetData, - kafkaProducerByteRateWidgetData, - messagesConsumedWidgetData, - producerFetchRequestPurgatoryWidgetData, - requestResponseWidgetData, - requestTimesWidgetData, + getAverageRequestLatencyWidgetData, + getBrokerCountWidgetData, + getBrokerNetworkThroughputWidgetData, + getBytesConsumedWidgetData, + getConsumerFetchRateWidgetData, + getConsumerGroupMemberWidgetData, + getConsumerLagByGroupWidgetData, + getConsumerOffsetWidgetData, + getIoWaitTimeWidgetData, + getKafkaProducerByteRateWidgetData, + getMessagesConsumedWidgetData, + getProducerFetchRequestPurgatoryWidgetData, + getRequestResponseWidgetData, + getRequestTimesWidgetData, } from './MetricPageUtil'; interface MetricSectionProps { @@ -71,15 +73,20 @@ function MetricColumnGraphs({ }): JSX.Element { const { t } = useTranslation('messagingQueues'); + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const metricsData = [ { title: t('metricGraphCategory.brokerMetrics.title'), description: t('metricGraphCategory.brokerMetrics.description'), graphCount: [ - brokerCountWidgetData, - requestTimesWidgetData, - producerFetchRequestPurgatoryWidgetData, - brokerNetworkThroughputWidgetData, + getBrokerCountWidgetData(dotMetricsEnabled), + getRequestTimesWidgetData(dotMetricsEnabled), + getProducerFetchRequestPurgatoryWidgetData(dotMetricsEnabled), + getBrokerNetworkThroughputWidgetData(dotMetricsEnabled), ], id: 'broker-metrics', }, @@ -87,11 +94,11 @@ function MetricColumnGraphs({ title: t('metricGraphCategory.producerMetrics.title'), description: t('metricGraphCategory.producerMetrics.description'), graphCount: [ - ioWaitTimeWidgetData, - requestResponseWidgetData, - averageRequestLatencyWidgetData, - kafkaProducerByteRateWidgetData, - bytesConsumedWidgetData, + getIoWaitTimeWidgetData(dotMetricsEnabled), + getRequestResponseWidgetData(dotMetricsEnabled), + getAverageRequestLatencyWidgetData(dotMetricsEnabled), + getKafkaProducerByteRateWidgetData(dotMetricsEnabled), + getBytesConsumedWidgetData(dotMetricsEnabled), ], id: 'producer-metrics', }, @@ -99,11 +106,11 @@ function MetricColumnGraphs({ title: t('metricGraphCategory.consumerMetrics.title'), description: t('metricGraphCategory.consumerMetrics.description'), graphCount: [ - consumerOffsetWidgetData, - consumerGroupMemberWidgetData, - consumerLagByGroupWidgetData, - consumerFetchRateWidgetData, - messagesConsumedWidgetData, + getConsumerOffsetWidgetData(dotMetricsEnabled), + getConsumerGroupMemberWidgetData(dotMetricsEnabled), + getConsumerLagByGroupWidgetData(dotMetricsEnabled), + getConsumerFetchRateWidgetData(dotMetricsEnabled), + getMessagesConsumedWidgetData(dotMetricsEnabled), ], id: 'consumer-metrics', }, diff --git a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx index 43c83fd018..aaf18d86ea 100644 --- a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx +++ b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPage.tsx @@ -10,17 +10,19 @@ import { useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Widgets } from 'types/api/dashboard/getAll'; +import { FeatureKeys } from '../../../../constants/features'; +import { useAppContext } from '../../../../providers/App/App'; import MetricColumnGraphs from './MetricColumnGraphs'; import MetricPageGridGraph from './MetricPageGraph'; import { - cpuRecentUtilizationWidgetData, - currentOffsetPartitionWidgetData, - insyncReplicasWidgetData, - jvmGcCollectionsElapsedWidgetData, - jvmGCCountWidgetData, - jvmMemoryHeapWidgetData, - oldestOffsetWidgetData, - partitionCountPerTopicWidgetData, + getCpuRecentUtilizationWidgetData, + getCurrentOffsetPartitionWidgetData, + getInsyncReplicasWidgetData, + getJvmGcCollectionsElapsedWidgetData, + getJvmGCCountWidgetData, + getJvmMemoryHeapWidgetData, + getOldestOffsetWidgetData, + getPartitionCountPerTopicWidgetData, } from './MetricPageUtil'; interface CollapsibleMetricSectionProps { @@ -95,6 +97,11 @@ function MetricPage(): JSX.Element { })); }; + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const { t } = useTranslation('messagingQueues'); const metricSections = [ @@ -103,10 +110,10 @@ function MetricPage(): JSX.Element { title: t('metricGraphCategory.brokerJVMMetrics.title'), description: t('metricGraphCategory.brokerJVMMetrics.description'), graphCount: [ - jvmGCCountWidgetData, - jvmGcCollectionsElapsedWidgetData, - cpuRecentUtilizationWidgetData, - jvmMemoryHeapWidgetData, + getJvmGCCountWidgetData(dotMetricsEnabled), + getJvmGcCollectionsElapsedWidgetData(dotMetricsEnabled), + getCpuRecentUtilizationWidgetData(dotMetricsEnabled), + getJvmMemoryHeapWidgetData(dotMetricsEnabled), ], }, { @@ -114,10 +121,10 @@ function MetricPage(): JSX.Element { title: t('metricGraphCategory.partitionMetrics.title'), description: t('metricGraphCategory.partitionMetrics.description'), graphCount: [ - partitionCountPerTopicWidgetData, - currentOffsetPartitionWidgetData, - oldestOffsetWidgetData, - insyncReplicasWidgetData, + getPartitionCountPerTopicWidgetData(dotMetricsEnabled), + getCurrentOffsetPartitionWidgetData(dotMetricsEnabled), + getOldestOffsetWidgetData(dotMetricsEnabled), + getInsyncReplicasWidgetData(dotMetricsEnabled), ], }, ]; diff --git a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil.ts b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil.ts index 66999c77ae..fdb304b970 100644 --- a/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil.ts +++ b/frontend/src/pages/MessagingQueues/MQDetails/MetricPage/MetricPageUtil.ts @@ -79,1023 +79,1145 @@ export function getWidgetQuery( }; } -export const requestTimesWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_request_time_avg--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_request_time_avg', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request Times', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Request Times', - description: - 'This metric is used to measure the average latency experienced by requests across the Kafka broker.', - }), -); - -export const brokerCountWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_brokers--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_brokers', - type: 'Gauge', - }, - aggregateOperator: 'sum', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Broker count', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'sum', - }, - ], - title: 'Broker Count', - description: 'Total number of active brokers in the Kafka cluster.\n', - }), -); - -export const producerFetchRequestPurgatoryWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_purgatory_size--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_purgatory_size', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Producer and Fetch Request Purgatory', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Producer and Fetch Request Purgatory', - description: - 'Measures the number of requests that Kafka brokers have received but cannot immediately fulfill', - }), -); - -export const brokerNetworkThroughputWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: - 'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Broker Network Throughput', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Broker Network Throughput', - description: - 'Helps gauge the data throughput from the Kafka broker to consumer clients, focusing on the network usage associated with serving messages to consumers.', - }), -); - -export const ioWaitTimeWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_producer_io_waittime_total--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'kafka_producer_io_waittime_total', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'I/O Wait Time', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - title: 'I/O Wait Time', - description: - 'This metric measures the total time that producers are in an I/O wait state, indicating potential bottlenecks in data transmission from producers to Kafka brokers.', - }), -); - -export const requestResponseWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_producer_request_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_producer_request_rate', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Request Rate', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_producer_response_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_producer_response_rate', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'B', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Response Rate', - limit: null, - orderBy: [], - queryName: 'B', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Request and Response Rate', - description: - "Indicates how many requests the producer is sending per second, reflecting the intensity of the producer's interaction with the Kafka cluster. Also, helps Kafka administrators gauge the responsiveness of brokers to producer requests.", - }), -); - -export const averageRequestLatencyWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_producer_request_latency_avg--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_producer_request_latency_avg', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Average Request Latency', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Average Request Latency', - description: - 'Helps Kafka administrators and developers understand the average latency experienced by producer requests.', - }), -); - -export const kafkaProducerByteRateWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_producer_byte_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_producer_byte_rate', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, +export const getRequestTimesWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + // choose key based on flag + key: dotMetricsEnabled + ? 'kafka.request.time.avg' + : 'kafka_request_time_avg', + // mirror into the id as well + id: 'kafka_request_time_avg--float64--Gauge--true', + isColumn: true, isJSON: false, - key: 'topic', - type: 'tag', + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'kafka_producer_byte_rate', - description: - 'Helps measure the data output rate from the producer, indicating the load a producer is placing on Kafka brokers.', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { + items: [], + op: 'AND', + }, + functions: [], + groupBy: [], + having: [], + legend: 'Request Times', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Request Times', + description: + 'This metric is used to measure the average latency experienced by requests across the Kafka broker.', + }), + ); -export const bytesConsumedWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_bytes_consumed_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_bytes_consumed_rate', - type: 'Gauge', +export const getBrokerCountWidgetData = (dotMetricsEnabled: boolean): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled ? 'kafka.brokers' : 'kafka_brokers', + id: 'kafka_brokers--float64--Gauge--true', + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'sum', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Broker count', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'sum', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Bytes Consumed', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Bytes Consumed', - description: - 'Helps Kafka administrators monitor the data consumption rate of a consumer group, showing how much data (in bytes) is being read from the Kafka cluster over time.', - }), -); + ], + title: 'Broker Count', + description: 'Total number of active brokers in the Kafka cluster.', + }), + ); -export const consumerOffsetWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_group_offset--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_group_offset', - type: 'Gauge', +export const getProducerFetchRequestPurgatoryWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + // inline ternary based on dotMetricsEnabled + key: dotMetricsEnabled ? 'kafka.purgatory.size' : 'kafka_purgatory_size', + id: `${ + dotMetricsEnabled ? 'kafka.purgatory.size' : 'kafka_purgatory_size' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Producer and Fetch Request Purgatory', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'group--string--tag--false', - isColumn: false, - isJSON: false, - key: 'group', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, - isJSON: false, - key: 'topic', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'partition--string--tag--false', - isColumn: false, - isJSON: false, - key: 'partition', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Consumer Offset', - description: 'Current offset of each consumer group for each topic partition', - }), -); + ], + title: 'Producer and Fetch Request Purgatory', + description: + 'Measures the number of requests that Kafka brokers have received but cannot immediately fulfill', + }), + ); -export const consumerGroupMemberWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_group_members--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_group_members', - type: 'Gauge', - }, - aggregateOperator: 'sum', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'group--string--tag--false', - isColumn: false, +export const getBrokerNetworkThroughputWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + // inline ternary based on dotMetricsEnabled + key: dotMetricsEnabled + ? 'kafka_server_brokertopicmetrics_total_replicationbytesinpersec_oneminuterate' + : 'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate', + id: `${ + dotMetricsEnabled + ? 'kafka_server_brokertopicmetrics_total_replicationbytesinpersec_oneminuterate' + : 'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'group', - type: 'tag', + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'sum', - }, - ], - title: 'Consumer Group Members', - description: 'Number of active users in each group', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Broker Network Throughput', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Broker Network Throughput', + description: + 'Helps gauge the data throughput from the Kafka broker to consumer clients, focusing on the network usage associated with serving messages to consumers.', + }), + ); -export const consumerLagByGroupWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_group_lag--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_group_lag', - type: 'Gauge', +export const getIoWaitTimeWidgetData = (dotMetricsEnabled: boolean): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + // inline ternary based on dotMetricsEnabled + key: dotMetricsEnabled + ? 'kafka.producer.io_waittime_total' + : 'kafka_producer_io_waittime_total', + id: `${ + dotMetricsEnabled + ? 'kafka.producer.io_waittime_total' + : 'kafka_producer_io_waittime_total' + }--float64--Sum--true`, + isColumn: true, + isJSON: false, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'I/O Wait Time', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'group--string--tag--false', - isColumn: false, - isJSON: false, - key: 'group', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, - isJSON: false, - key: 'topic', - type: 'tag', - }, - { - dataType: DataTypes.String, - id: 'partition--string--tag--false', - isColumn: false, - isJSON: false, - key: 'partition', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Consumer Lag by Group', - description: - 'Helps Kafka administrators assess whether consumer groups are keeping up with the incoming data stream or falling behind', - }), -); + ], + title: 'I/O Wait Time', + description: + 'This metric measures the total time that producers are in an I/O wait state, indicating potential bottlenecks in data transmission from producers to Kafka brokers.', + }), + ); -export const consumerFetchRateWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_fetch_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_fetch_rate', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'service_name--string--tag--false', - isColumn: false, +export const getRequestResponseWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.producer.request_rate' + : 'kafka_producer_request_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.producer.request_rate' + : 'kafka_producer_request_rate' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'service_name', - type: 'tag', + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Consumer Fetch Rate', - description: - 'Metric measures the rate at which fetch requests are made by a Kafka consumer to the broker, typically in requests per second.', - }), -); - -export const messagesConsumedWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_consumer_records_consumed_rate--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_consumer_records_consumed_rate', - type: 'Gauge', + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Request Rate', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'Messages Consumed', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Messages Consumed', - description: - 'Measures the rate at which a Kafka consumer is consuming records (messages) per second from Kafka brokers.', - }), -); - -export const jvmGCCountWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'jvm_gc_collections_count--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'jvm_gc_collections_count', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'JVM GC Count', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - title: 'JVM GC Count', - description: - 'Tracks the total number of garbage collection (GC) events that have occurred in the Java Virtual Machine (JVM).', - }), -); - -export const jvmGcCollectionsElapsedWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'jvm_gc_collections_elapsed--float64--Sum--true', - isColumn: true, - isJSON: false, - key: 'jvm_gc_collections_elapsed', - type: 'Sum', - }, - aggregateOperator: 'rate', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'garbagecollector', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'rate', - }, - ], - title: 'jvm_gc_collections_elapsed', - description: - 'Measures the total time (usually in milliseconds) spent on garbage collection (GC) events in the Java Virtual Machine (JVM).', - }), -); - -export const cpuRecentUtilizationWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'jvm_cpu_recent_utilization--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'jvm_cpu_recent_utilization', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'CPU utilization', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'CPU Recent Utilization', - description: - 'This metric measures the recent CPU usage by the Java Virtual Machine (JVM), typically expressed as a percentage.', - }), -); - -export const jvmMemoryHeapWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'jvm_memory_heap_max--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'jvm_memory_heap_max', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [], - having: [], - legend: 'JVM memory heap', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'JVM memory heap', - description: - 'The metric represents the maximum amount of heap memory available to the Java Virtual Machine (JVM)', - }), -); - -export const partitionCountPerTopicWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_topic_partitions--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_topic_partitions', - type: 'Gauge', - }, - aggregateOperator: 'sum', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.producer.response_rate' + : 'kafka_producer_response_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.producer.response_rate' + : 'kafka_producer_response_rate' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'topic', - type: 'tag', + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'sum', - stepInterval: 60, - timeAggregation: 'sum', - }, - ], - title: 'Partition Count per Topic', - description: 'Number of partitions for each topic', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'B', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Response Rate', + limit: null, + orderBy: [], + queryName: 'B', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Request and Response Rate', + description: + "Indicates how many requests the producer is sending per second, reflecting the intensity of the producer's interaction with the Kafka cluster. Also, helps Kafka administrators gauge the responsiveness of brokers to producer requests.", + }), + ); -export const currentOffsetPartitionWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_partition_current_offset--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_partition_current_offset', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, +export const getAverageRequestLatencyWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.producer.request_latency_avg' + : 'kafka_producer_request_latency_avg', + id: `${ + dotMetricsEnabled + ? 'kafka.producer.request_latency_avg' + : 'kafka_producer_request_latency_avg' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'topic', - type: 'tag', + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'partition--string--tag--false', - isColumn: false, - isJSON: false, - key: 'partition', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Current Offset ( Partition )', - description: - 'Current offset of each partition, showing the latest position in each partition', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Average Request Latency', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Average Request Latency', + description: + 'Helps Kafka administrators and developers understand the average latency experienced by producer requests.', + }), + ); -export const oldestOffsetWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_partition_oldest_offset--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_partition_oldest_offset', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, +export const getKafkaProducerByteRateWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.producer.byte_rate' + : 'kafka_producer_byte_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.producer.byte_rate' + : 'kafka_producer_byte_rate' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'topic', - type: 'tag', + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'partition--string--tag--false', - isColumn: false, - isJSON: false, - key: 'partition', - type: 'tag', - }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'Oldest Offset (Partition)', - description: - 'Oldest offset of each partition to identify log retention and offset range.', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: dotMetricsEnabled + ? 'kafka.producer.byte_rate' + : 'kafka_producer_byte_rate', + description: + 'Helps measure the data output rate from the producer, indicating the load a producer is placing on Kafka brokers.', + }), + ); -export const insyncReplicasWidgetData = getWidgetQueryBuilder( - getWidgetQuery({ - queryData: [ - { - aggregateAttribute: { - dataType: DataTypes.Float64, - id: 'kafka_partition_replicas_in_sync--float64--Gauge--true', - isColumn: true, - isJSON: false, - key: 'kafka_partition_replicas_in_sync', - type: 'Gauge', - }, - aggregateOperator: 'avg', - dataSource: DataSource.METRICS, - disabled: false, - expression: 'A', - filters: { - items: [], - op: 'AND', - }, - functions: [], - groupBy: [ - { - dataType: DataTypes.String, - id: 'topic--string--tag--false', - isColumn: false, +export const getBytesConsumedWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer.bytes_consumed_rate' + : 'kafka_consumer_bytes_consumed_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer.bytes_consumed_rate' + : 'kafka_consumer_bytes_consumed_rate' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'topic', - type: 'tag', + type: 'Gauge', }, - { - dataType: DataTypes.String, - id: 'partition--string--tag--false', - isColumn: false, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Bytes Consumed', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + // Use kebab-case title as requested + title: 'Bytes Consumed', + description: + 'Helps Kafka administrators monitor the data consumption rate of a consumer group, showing how much data (in bytes) is being read from the Kafka cluster over time.', + }), + ); + +export const getConsumerOffsetWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer_group.offset' + : 'kafka_consumer_group_offset', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer_group.offset' + : 'kafka_consumer_group_offset' + }--float64--Gauge--true`, + isColumn: true, isJSON: false, - key: 'partition', - type: 'tag', + type: 'Gauge', }, - ], - having: [], - legend: '', - limit: null, - orderBy: [], - queryName: 'A', - reduceTo: 'avg', - spaceAggregation: 'avg', - stepInterval: 60, - timeAggregation: 'avg', - }, - ], - title: 'In-Sync Replicas (ISR)', - description: - 'Count of in-sync replicas for each partition to ensure data availability.', - }), -); + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'group--string--tag--false', + isColumn: false, + isJSON: false, + key: 'group', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'partition--string--tag--false', + isColumn: false, + isJSON: false, + key: 'partition', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Consumer Offset', + description: + 'Current offset of each consumer group for each topic partition', + }), + ); + +export const getConsumerGroupMemberWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer_group.members' + : 'kafka_consumer_group_members', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer_group.members' + : 'kafka_consumer_group_members' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'sum', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'group--string--tag--false', + isColumn: false, + isJSON: false, + key: 'group', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'sum', + }, + ], + title: 'Consumer Group Members', + description: 'Number of active users in each group', + }), + ); + +export const getConsumerLagByGroupWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer_group.lag' + : 'kafka_consumer_group_lag', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer_group.lag' + : 'kafka_consumer_group_lag' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'group--string--tag--false', + isColumn: false, + isJSON: false, + key: 'group', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'partition--string--tag--false', + isColumn: false, + isJSON: false, + key: 'partition', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Consumer Lag by Group', + description: + 'Helps Kafka administrators assess whether consumer groups are keeping up with the incoming data stream or falling behind', + }), + ); + +export const getConsumerFetchRateWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer.fetch_rate' + : 'kafka_consumer_fetch_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer.fetch_rate' + : 'kafka_consumer_fetch_rate' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'service_name--string--tag--false', + isColumn: false, + isJSON: false, + key: dotMetricsEnabled ? 'service.name' : 'service_name', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Consumer Fetch Rate', + description: + 'Metric measures the rate at which fetch requests are made by a Kafka consumer to the broker, typically in requests per second.', + }), + ); + +export const getMessagesConsumedWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.consumer.records_consumed_rate' + : 'kafka_consumer_records_consumed_rate', + id: `${ + dotMetricsEnabled + ? 'kafka.consumer.records_consumed_rate' + : 'kafka_consumer_records_consumed_rate' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'Messages Consumed', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Messages Consumed', + description: + 'Measures the rate at which a Kafka consumer is consuming records (messages) per second from Kafka brokers.', + }), + ); + +export const getJvmGCCountWidgetData = (dotMetricsEnabled: boolean): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'jvm.gc.collections.count' + : 'jvm_gc_collections_count', + id: `${ + dotMetricsEnabled + ? 'jvm.gc.collections.count' + : 'jvm_gc_collections_count' + }--float64--Sum--true`, + isColumn: true, + isJSON: false, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'JVM GC Count', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + title: 'JVM GC Count', + description: + 'Tracks the total number of garbage collection (GC) events that have occurred in the Java Virtual Machine (JVM).', + }), + ); + +export const getJvmGcCollectionsElapsedWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'jvm.gc.collections.elapsed' + : 'jvm_gc_collections_elapsed', + id: `${ + dotMetricsEnabled + ? 'jvm.gc.collections.elapsed' + : 'jvm_gc_collections_elapsed' + }--float64--Sum--true`, + isColumn: true, + isJSON: false, + type: 'Sum', + }, + aggregateOperator: 'rate', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'garbagecollector', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'rate', + }, + ], + title: dotMetricsEnabled + ? 'jvm.gc.collections.elapsed' + : 'jvm_gc_collections_elapsed', + description: + 'Measures the total time (usually in milliseconds) spent on garbage collection (GC) events in the Java Virtual Machine (JVM).', + }), + ); + +export const getCpuRecentUtilizationWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'jvm.cpu.recent_utilization' + : 'jvm_cpu_recent_utilization', + id: `${ + dotMetricsEnabled + ? 'jvm.cpu.recent_utilization' + : 'jvm_cpu_recent_utilization' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'CPU utilization', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'CPU Recent Utilization', + description: + 'This metric measures the recent CPU usage by the Java Virtual Machine (JVM), typically expressed as a percentage.', + }), + ); + +export const getJvmMemoryHeapWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled ? 'jvm.memory.heap.max' : 'jvm_memory_heap_max', + id: `${ + dotMetricsEnabled ? 'jvm.memory.heap.max' : 'jvm_memory_heap_max' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [], + having: [], + legend: 'JVM memory heap', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'JVM memory heap', + description: + 'The metric represents the maximum amount of heap memory available to the Java Virtual Machine (JVM)', + }), + ); + +export const getPartitionCountPerTopicWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.topic.partitions' + : 'kafka_topic_partitions', + id: `${ + dotMetricsEnabled ? 'kafka.topic.partitions' : 'kafka_topic_partitions' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'sum', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'sum', + stepInterval: 60, + timeAggregation: 'sum', + }, + ], + title: 'Partition Count per Topic', + description: 'Number of partitions for each topic', + }), + ); + +export const getCurrentOffsetPartitionWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.partition.current_offset' + : 'kafka_partition_current_offset', + id: `${ + dotMetricsEnabled + ? 'kafka.partition.current_offset' + : 'kafka_partition_current_offset' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'partition--string--tag--false', + isColumn: false, + isJSON: false, + key: 'partition', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Current Offset ( Partition )', + description: + 'Current offset of each partition, showing the latest position in each partition', + }), + ); + +export const getOldestOffsetWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.partition.oldest_offset' + : 'kafka_partition_oldest_offset', + id: `${ + dotMetricsEnabled + ? 'kafka.partition.oldest_offset' + : 'kafka_partition_oldest_offset' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'partition--string--tag--false', + isColumn: false, + isJSON: false, + key: 'partition', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'Oldest Offset (Partition)', + description: + 'Oldest offset of each partition to identify log retention and offset range.', + }), + ); + +export const getInsyncReplicasWidgetData = ( + dotMetricsEnabled: boolean, +): Widgets => + getWidgetQueryBuilder( + getWidgetQuery({ + queryData: [ + { + aggregateAttribute: { + dataType: DataTypes.Float64, + key: dotMetricsEnabled + ? 'kafka.partition.replicas_in_sync' + : 'kafka_partition_replicas_in_sync', + id: `${ + dotMetricsEnabled + ? 'kafka.partition.replicas_in_sync' + : 'kafka_partition_replicas_in_sync' + }--float64--Gauge--true`, + isColumn: true, + isJSON: false, + type: 'Gauge', + }, + aggregateOperator: 'avg', + dataSource: DataSource.METRICS, + disabled: false, + expression: 'A', + filters: { items: [], op: 'AND' }, + functions: [], + groupBy: [ + { + dataType: DataTypes.String, + id: 'topic--string--tag--false', + isColumn: false, + isJSON: false, + key: 'topic', + type: 'tag', + }, + { + dataType: DataTypes.String, + id: 'partition--string--tag--false', + isColumn: false, + isJSON: false, + key: 'partition', + type: 'tag', + }, + ], + having: [], + legend: '', + limit: null, + orderBy: [], + queryName: 'A', + reduceTo: 'avg', + spaceAggregation: 'avg', + stepInterval: 60, + timeAggregation: 'avg', + }, + ], + title: 'In-Sync Replicas (ISR)', + description: + 'Count of in-sync replicas for each partition to ensure data availability.', + }), + ); diff --git a/frontend/src/pages/MessagingQueues/MQGraph/MQConfigOptions.tsx b/frontend/src/pages/MessagingQueues/MQGraph/MQConfigOptions.tsx index da83a197fc..72e384460c 100644 --- a/frontend/src/pages/MessagingQueues/MQGraph/MQConfigOptions.tsx +++ b/frontend/src/pages/MessagingQueues/MQGraph/MQConfigOptions.tsx @@ -13,6 +13,8 @@ import { useState } from 'react'; import { useHistory, useLocation } from 'react-router-dom'; import { useCopyToClipboard } from 'react-use'; +import { FeatureKeys } from '../../../constants/features'; +import { useAppContext } from '../../../providers/App/App'; import { useGetAllConfigOptions } from './useGetAllConfigOptions'; type ConfigOptionType = 'group' | 'topic' | 'partition'; @@ -38,11 +40,19 @@ const useConfigOptions = ( isFetching: boolean; options: DefaultOptionType[]; } => { + const { featureFlags } = useAppContext(); + const dotMetricsEnabled = + featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED) + ?.active || false; + const [searchText, setSearchText] = useState(''); - const { isFetching, options } = useGetAllConfigOptions({ - attributeKey: type, - searchText, - }); + const { isFetching, options } = useGetAllConfigOptions( + { + attributeKey: type, + searchText, + }, + dotMetricsEnabled, + ); const handleDebouncedSearch = useDebouncedFn((searchText): void => { setSearchText(searchText as string); }, 500); diff --git a/frontend/src/pages/MessagingQueues/MQGraph/useGetAllConfigOptions.ts b/frontend/src/pages/MessagingQueues/MQGraph/useGetAllConfigOptions.ts index f3370512bc..aa070d6758 100644 --- a/frontend/src/pages/MessagingQueues/MQGraph/useGetAllConfigOptions.ts +++ b/frontend/src/pages/MessagingQueues/MQGraph/useGetAllConfigOptions.ts @@ -17,16 +17,19 @@ export interface GetAllConfigOptionsResponse { export function useGetAllConfigOptions( props: ConfigOptions, + dotMetricsEnabled: boolean, ): GetAllConfigOptionsResponse { const { attributeKey, searchText } = props; const { data, isLoading } = useQuery( ['attributesValues', attributeKey, searchText], - async () => { + async (): Promise => { const { payload } = await getAttributesValues({ aggregateOperator: 'avg', dataSource: DataSource.METRICS, - aggregateAttribute: 'kafka_consumer_group_lag', + aggregateAttribute: dotMetricsEnabled + ? 'kafka.consumer_group.lag' + : 'kafka_consumer_group_lag', attributeKey, searchText: searchText ?? '', filterAttributeKeyDataType: DataTypes.String, diff --git a/frontend/src/pages/MetricsExplorer/MetricsExplorerPage.tsx b/frontend/src/pages/MetricsExplorer/MetricsExplorerPage.tsx index 1b416d4f64..7a13a65ac9 100644 --- a/frontend/src/pages/MetricsExplorer/MetricsExplorerPage.tsx +++ b/frontend/src/pages/MetricsExplorer/MetricsExplorerPage.tsx @@ -5,12 +5,12 @@ import { TabRoutes } from 'components/RouteTab/types'; import history from 'lib/history'; import { useLocation } from 'react-use'; -import { Explorer, Summary } from './constants'; +import { Explorer, Summary, Views } from './constants'; function MetricsExplorerPage(): JSX.Element { const { pathname } = useLocation(); - const routes: TabRoutes[] = [Summary, Explorer]; + const routes: TabRoutes[] = [Summary, Explorer, Views]; return (
diff --git a/frontend/src/pages/MetricsExplorer/constants.tsx b/frontend/src/pages/MetricsExplorer/constants.tsx index a1c12d0906..daad1775b5 100644 --- a/frontend/src/pages/MetricsExplorer/constants.tsx +++ b/frontend/src/pages/MetricsExplorer/constants.tsx @@ -2,8 +2,8 @@ import { TabRoutes } from 'components/RouteTab/types'; import ROUTES from 'constants/routes'; import ExplorerPage from 'container/MetricsExplorer/Explorer'; import SummaryPage from 'container/MetricsExplorer/Summary'; -import ViewsPage from 'container/MetricsExplorer/Views'; import { BarChart2, Compass, TowerControl } from 'lucide-react'; +import SaveView from 'pages/SaveView'; export const Summary: TabRoutes = { Component: SummaryPage, @@ -28,7 +28,7 @@ export const Explorer: TabRoutes = { }; export const Views: TabRoutes = { - Component: ViewsPage, + Component: SaveView, name: (
Views diff --git a/frontend/src/pages/SaveView/constants.ts b/frontend/src/pages/SaveView/constants.ts index a6d55b1cb9..e07b3c8876 100644 --- a/frontend/src/pages/SaveView/constants.ts +++ b/frontend/src/pages/SaveView/constants.ts @@ -5,6 +5,7 @@ export const SOURCEPAGE_VS_ROUTES: { } = { logs: ROUTES.LOGS_EXPLORER, traces: ROUTES.TRACES_EXPLORER, + metrics: ROUTES.METRICS_EXPLORER_EXPLORER, } as const; export const ROUTES_VS_SOURCEPAGE: { @@ -12,4 +13,5 @@ export const ROUTES_VS_SOURCEPAGE: { } = { [ROUTES.LOGS_SAVE_VIEWS]: 'logs', [ROUTES.TRACES_SAVE_VIEWS]: 'traces', + [ROUTES.METRICS_EXPLORER_VIEWS]: 'metrics', } as const; diff --git a/frontend/src/tests/test-utils.tsx b/frontend/src/tests/test-utils.tsx index f58b818ec0..c07ae853ee 100644 --- a/frontend/src/tests/test-utils.tsx +++ b/frontend/src/tests/test-utils.tsx @@ -243,7 +243,8 @@ export function getAppContextMock( ...appContextOverrides, }; } -function AllTheProviders({ + +export function AllTheProviders({ children, role, // Accept the role as a prop appContextOverrides, @@ -254,20 +255,19 @@ function AllTheProviders({ }): ReactElement { return ( - - - - + + + + - {/* Use the mock store with the provided role */} {children} - - - - + + + + ); } diff --git a/pkg/prometheus/clickhouseprometheus/client.go b/pkg/prometheus/clickhouseprometheus/client.go index d98caafb30..779b8fc7af 100644 --- a/pkg/prometheus/clickhouseprometheus/client.go +++ b/pkg/prometheus/clickhouseprometheus/client.go @@ -3,6 +3,7 @@ package clickhouseprometheus import ( "context" "fmt" + "github.com/SigNoz/signoz/pkg/query-service/constants" "strconv" "strings" @@ -98,9 +99,15 @@ func (client *client) queryToClickhouseQuery(_ context.Context, query *prompb.Qu var args []any conditions = append(conditions, fmt.Sprintf("metric_name = $%d", argCount+1)) conditions = append(conditions, "temporality IN ['Cumulative', 'Unspecified']") - conditions = append(conditions, "__normalized = true") conditions = append(conditions, fmt.Sprintf("unix_milli >= %d AND unix_milli < %d", start, end)) + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + + conditions = append(conditions, fmt.Sprintf("__normalized = %v", normalized)) + args = append(args, metricName) for _, m := range query.Matchers { switch m.Type { diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index 08d0dcc0af..799bf74fb6 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -3003,18 +3003,22 @@ func (r *ClickHouseReader) QueryDashboardVars(ctx context.Context, query string) return &result, nil } -func (r *ClickHouseReader) GetMetricAggregateAttributes(ctx context.Context, orgID valuer.UUID, req *v3.AggregateAttributeRequest, skipDotNames bool, skipSignozMetrics bool) (*v3.AggregateAttributeResponse, error) { +func (r *ClickHouseReader) GetMetricAggregateAttributes(ctx context.Context, orgID valuer.UUID, req *v3.AggregateAttributeRequest, skipSignozMetrics bool) (*v3.AggregateAttributeResponse, error) { var query string var err error var rows driver.Rows var response v3.AggregateAttributeResponse + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } - query = fmt.Sprintf("SELECT metric_name, type, is_monotonic, temporality FROM %s.%s WHERE metric_name ILIKE $1 GROUP BY metric_name, type, is_monotonic, temporality", signozMetricDBName, signozTSTableNameV41Day) + query = fmt.Sprintf("SELECT metric_name, type, is_monotonic, temporality FROM %s.%s WHERE metric_name ILIKE $1 and __normalized = $2 GROUP BY metric_name, type, is_monotonic, temporality", signozMetricDBName, signozTSTableNameV41Day) if req.Limit != 0 { query = query + fmt.Sprintf(" LIMIT %d;", req.Limit) } - rows, err = r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText)) + rows, err = r.db.Query(ctx, query, fmt.Sprintf("%%%s%%", req.SearchText), normalized) if err != nil { zap.L().Error("Error while executing query", zap.Error(err)) @@ -3030,11 +3034,8 @@ func (r *ClickHouseReader) GetMetricAggregateAttributes(ctx context.Context, org if err := rows.Scan(&metricName, &typ, &isMonotonic, &temporality); err != nil { return nil, fmt.Errorf("error while scanning rows: %s", err.Error()) } - if skipDotNames && strings.Contains(metricName, ".") { - continue - } - if skipSignozMetrics && strings.HasPrefix(metricName, "signoz_") { + if skipSignozMetrics && strings.HasPrefix(metricName, "signoz") { continue } @@ -3077,12 +3078,17 @@ func (r *ClickHouseReader) GetMetricAttributeKeys(ctx context.Context, req *v3.F var rows driver.Rows var response v3.FilterAttributeKeyResponse + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + // skips the internal attributes i.e attributes starting with __ - query = fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE metric_name=$1 AND unix_milli >= $2 AND __normalized = true GROUP BY tagKeys) WHERE distinctTagKey ILIKE $3 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day) + query = fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE metric_name=$1 AND unix_milli >= $2 AND __normalized = $3 GROUP BY tagKeys) WHERE distinctTagKey ILIKE $4 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day) if req.Limit != 0 { query = query + fmt.Sprintf(" LIMIT %d;", req.Limit) } - rows, err = r.db.Query(ctx, query, req.AggregateAttribute, common.PastDayRoundOff(), fmt.Sprintf("%%%s%%", req.SearchText)) + rows, err = r.db.Query(ctx, query, req.AggregateAttribute, common.PastDayRoundOff(), normalized, fmt.Sprintf("%%%s%%", req.SearchText)) if err != nil { zap.L().Error("Error while executing query", zap.Error(err)) return nil, fmt.Errorf("error while executing query: %s", err.Error()) @@ -3113,16 +3119,19 @@ func (r *ClickHouseReader) GetMetricAttributeValues(ctx context.Context, req *v3 var rows driver.Rows var attributeValues v3.FilterAttributeValueResponse - query = fmt.Sprintf("SELECT JSONExtractString(labels, $1) AS tagValue FROM %s.%s WHERE metric_name IN $2 AND JSONExtractString(labels, $3) ILIKE $4 AND unix_milli >= $5 GROUP BY tagValue", signozMetricDBName, signozTSTableNameV41Day) + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + + query = fmt.Sprintf("SELECT JSONExtractString(labels, $1) AS tagValue FROM %s.%s WHERE metric_name IN $2 AND JSONExtractString(labels, $3) ILIKE $4 AND unix_milli >= $5 AND __normalized=$6 GROUP BY tagValue", signozMetricDBName, signozTSTableNameV41Day) if req.Limit != 0 { query = query + fmt.Sprintf(" LIMIT %d;", req.Limit) } names := []string{req.AggregateAttribute} - if _, ok := metrics.MetricsUnderTransition[req.AggregateAttribute]; ok { - names = append(names, metrics.MetricsUnderTransition[req.AggregateAttribute]) - } + names = append(names, metrics.GetTransitionedMetric(req.AggregateAttribute, normalized)) - rows, err = r.db.Query(ctx, query, req.FilterAttributeKey, names, req.FilterAttributeKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff()) + rows, err = r.db.Query(ctx, query, req.FilterAttributeKey, names, req.FilterAttributeKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff(), normalized) if err != nil { zap.L().Error("Error while executing query", zap.Error(err)) @@ -4992,15 +5001,19 @@ func (r *ClickHouseReader) SubscribeToQueryProgress( return r.queryProgressTracker.SubscribeToQueryProgress(queryId) } -func (r *ClickHouseReader) GetAllMetricFilterAttributeKeys(ctx context.Context, req *metrics_explorer.FilterKeyRequest, skipDotNames bool) (*[]v3.AttributeKey, *model.ApiError) { +func (r *ClickHouseReader) GetAllMetricFilterAttributeKeys(ctx context.Context, req *metrics_explorer.FilterKeyRequest) (*[]v3.AttributeKey, *model.ApiError) { var rows driver.Rows var response []v3.AttributeKey - query := fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE unix_milli >= $1 GROUP BY tagKeys) WHERE distinctTagKey ILIKE $2 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day) + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + query := fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE unix_milli >= $1 and __normalized = $2 GROUP BY tagKeys) WHERE distinctTagKey ILIKE $3 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day) if req.Limit != 0 { query = query + fmt.Sprintf(" LIMIT %d;", req.Limit) } valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) - rows, err := r.db.Query(valueCtx, query, common.PastDayRoundOff(), fmt.Sprintf("%%%s%%", req.SearchText)) //only showing past day data + rows, err := r.db.Query(valueCtx, query, common.PastDayRoundOff(), normalized, fmt.Sprintf("%%%s%%", req.SearchText)) //only showing past day data if err != nil { zap.L().Error("Error while executing query", zap.Error(err)) return nil, &model.ApiError{Typ: "ClickHouseError", Err: err} @@ -5011,9 +5024,6 @@ func (r *ClickHouseReader) GetAllMetricFilterAttributeKeys(ctx context.Context, if err := rows.Scan(&attributeKey); err != nil { return nil, &model.ApiError{Typ: "ClickHouseError", Err: err} } - if skipDotNames && strings.Contains(attributeKey, ".") { - continue - } key := v3.AttributeKey{ Key: attributeKey, DataType: v3.AttributeKeyDataTypeString, // https://github.com/OpenObservability/OpenMetrics/blob/main/proto/openmetrics_data_model.proto#L64-L72. @@ -5033,13 +5043,17 @@ func (r *ClickHouseReader) GetAllMetricFilterAttributeValues(ctx context.Context var err error var rows driver.Rows var attributeValues []string + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } - query = fmt.Sprintf("SELECT JSONExtractString(labels, $1) AS tagValue FROM %s.%s WHERE JSONExtractString(labels, $2) ILIKE $3 AND unix_milli >= $4 GROUP BY tagValue", signozMetricDBName, signozTSTableNameV41Day) + query = fmt.Sprintf("SELECT JSONExtractString(labels, $1) AS tagValue FROM %s.%s WHERE JSONExtractString(labels, $2) ILIKE $3 AND unix_milli >= $4 AND __normalized = $5 GROUP BY tagValue", signozMetricDBName, signozTSTableNameV41Day) if req.Limit != 0 { query = query + fmt.Sprintf(" LIMIT %d;", req.Limit) } valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) - rows, err = r.db.Query(valueCtx, query, req.FilterKey, req.FilterKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff()) //only showing past day data + rows, err = r.db.Query(valueCtx, query, req.FilterKey, req.FilterKey, fmt.Sprintf("%%%s%%", req.SearchText), common.PastDayRoundOff(), normalized) //only showing past day data if err != nil { zap.L().Error("Error while executing query", zap.Error(err)) @@ -5176,6 +5190,11 @@ func (r *ClickHouseReader) GetAttributesForMetricName(ctx context.Context, metri whereClause = "AND " + strings.Join(conditions, " AND ") } } + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + const baseQueryTemplate = ` SELECT kv.1 AS key, @@ -5183,12 +5202,14 @@ SELECT length(groupUniqArray(10000)(kv.2)) AS valueCount FROM %s.%s ARRAY JOIN arrayFilter(x -> NOT startsWith(x.1, '__'), JSONExtractKeysAndValuesRaw(labels)) AS kv -WHERE metric_name = ? AND __normalized=true %s` +WHERE metric_name = ? AND __normalized=? %s` var args []interface{} args = append(args, metricName) tableName := signozTSTableNameV41Week + args = append(args, normalized) + if start != nil && end != nil { st, en, tsTable, _ := utils.WhichTSTableToUse(*start, *end) *start, *end, tableName = st, en, tsTable @@ -5264,6 +5285,11 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. orderByClauseFirstQuery = fmt.Sprintf("ORDER BY %s %s", req.OrderBy.ColumnName, req.OrderBy.Order) } + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + // Determine which tables to use start, end, tsTable, localTsTable := utils.WhichTSTableToUse(req.Start, req.End) sampleTable, countExp := utils.WhichSampleTableToUse(req.Start, req.End) @@ -5278,8 +5304,8 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. uniq(metric_name) OVER() AS total FROM %s.%s AS t WHERE unix_milli BETWEEN ? AND ? - AND NOT startsWith(metric_name, 'signoz_') - AND __normalized = true + AND NOT startsWith(metric_name, 'signoz') + AND __normalized = ? %s GROUP BY t.metric_name %s @@ -5287,6 +5313,7 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. signozMetricDBName, tsTable, whereClause, orderByClauseFirstQuery, firstQueryLimit, req.Offset) args = append(args, start, end) + args = append(args, normalized) valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) begin := time.Now() rows, err := r.db.Query(valueCtx, metricsQuery, args...) @@ -5346,7 +5373,7 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. SELECT fingerprint FROM %s.%s WHERE metric_name IN (%s) - AND __normalized = true + AND __normalized = ? AND unix_milli BETWEEN ? AND ? %s GROUP BY fingerprint @@ -5361,6 +5388,7 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. metricsList, whereClause, )) + args = append(args, normalized) args = append(args, start, end) args = append(args, req.Start, req.End) } else { @@ -5455,6 +5483,11 @@ func (r *ClickHouseReader) ListSummaryMetrics(ctx context.Context, orgID valuer. func (r *ClickHouseReader) GetMetricsTimeSeriesPercentage(ctx context.Context, req *metrics_explorer.TreeMapMetricsRequest) (*[]metrics_explorer.TreeMapResponseItem, *model.ApiError) { var args []interface{} + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + // Build filters dynamically conditions, _ := utils.BuildFilterConditions(&req.Filters, "") whereClause := "" @@ -5475,9 +5508,9 @@ func (r *ClickHouseReader) GetMetricsTimeSeriesPercentage(ctx context.Context, r uniq(fingerprint) AS total_value, (SELECT uniq(fingerprint) FROM %s.%s - WHERE unix_milli BETWEEN ? AND ? AND __normalized = true) AS total_time_series + WHERE unix_milli BETWEEN ? AND ? AND __normalized = ?) AS total_time_series FROM %s.%s - WHERE unix_milli BETWEEN ? AND ? AND NOT startsWith(metric_name, 'signoz_') AND __normalized = true %s + WHERE unix_milli BETWEEN ? AND ? AND NOT startsWith(metric_name, 'signoz') AND __normalized = ? %s GROUP BY metric_name ) ORDER BY percentage DESC @@ -5491,8 +5524,10 @@ func (r *ClickHouseReader) GetMetricsTimeSeriesPercentage(ctx context.Context, r ) args = append(args, - start, end, // For total_time_series subquery + start, end, + normalized, // For total_time_series subquery start, end, // For main query + normalized, ) valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) @@ -5532,6 +5567,11 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req whereClause = "AND " + strings.Join(conditions, " AND ") } + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + // Determine time range and tables to use start, end, tsTable, localTsTable := utils.WhichTSTableToUse(req.Start, req.End) sampleTable, countExp := utils.WhichSampleTableToUse(req.Start, req.End) @@ -5543,7 +5583,7 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req uniq(ts.fingerprint) AS timeSeries FROM %s.%s AS ts WHERE NOT startsWith(ts.metric_name, 'signoz_') - AND __normalized = true + AND __normalized = ? AND unix_milli BETWEEN ? AND ? %s GROUP BY ts.metric_name @@ -5554,7 +5594,7 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) begin := time.Now() - rows, err := r.db.Query(valueCtx, metricsQuery, start, end) + rows, err := r.db.Query(valueCtx, metricsQuery, normalized, start, end) duration := time.Since(begin) zap.L().Info("Time taken to execute samples percentage metric name query to reduce search space", zap.String("query", metricsQuery), zap.Any("start", start), zap.Any("end", end), zap.Duration("duration", duration)) if err != nil { @@ -5626,13 +5666,13 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req FROM %s.%s AS ts WHERE ts.metric_name IN (%s) AND unix_milli BETWEEN ? AND ? - AND __normalized = true + AND __normalized = ? %s GROUP BY ts.fingerprint )`, signozMetricDBName, localTsTable, metricsList, whereClause, )) - args = append(args, start, end) + args = append(args, start, end, normalized) } // Apply metric filtering after all conditions @@ -5682,6 +5722,11 @@ func (r *ClickHouseReader) GetMetricsSamplesPercentage(ctx context.Context, req func (r *ClickHouseReader) GetNameSimilarity(ctx context.Context, req *metrics_explorer.RelatedMetricsRequest) (map[string]metrics_explorer.RelatedMetricsScore, *model.ApiError) { start, end, tsTable, _ := utils.WhichTSTableToUse(req.Start, req.End) + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + query := fmt.Sprintf(` SELECT metric_name, @@ -5692,15 +5737,15 @@ func (r *ClickHouseReader) GetNameSimilarity(ctx context.Context, req *metrics_e FROM %s.%s WHERE metric_name != ? AND unix_milli BETWEEN ? AND ? - AND NOT startsWith(metric_name, 'signoz_') - AND __normalized = true + AND NOT startsWith(metric_name, 'signoz') + AND __normalized = ? GROUP BY metric_name ORDER BY name_similarity DESC LIMIT 30;`, signozMetricDBName, tsTable) valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) - rows, err := r.db.Query(valueCtx, query, req.CurrentMetricName, req.CurrentMetricName, req.CurrentMetricName, start, end) + rows, err := r.db.Query(valueCtx, query, req.CurrentMetricName, req.CurrentMetricName, req.CurrentMetricName, start, end, normalized) if err != nil { return nil, &model.ApiError{Typ: "ClickHouseError", Err: err} } @@ -5730,6 +5775,11 @@ func (r *ClickHouseReader) GetNameSimilarity(ctx context.Context, req *metrics_e func (r *ClickHouseReader) GetAttributeSimilarity(ctx context.Context, req *metrics_explorer.RelatedMetricsRequest) (map[string]metrics_explorer.RelatedMetricsScore, *model.ApiError) { start, end, tsTable, _ := utils.WhichTSTableToUse(req.Start, req.End) + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + // Get target labels extractedLabelsQuery := fmt.Sprintf(` SELECT @@ -5741,12 +5791,12 @@ func (r *ClickHouseReader) GetAttributeSimilarity(ctx context.Context, req *metr AND unix_milli between ? and ? AND NOT startsWith(kv.1, '__') AND NOT startsWith(metric_name, 'signoz_') - AND __normalized = true + AND __normalized = ? GROUP BY label_key LIMIT 50`, signozMetricDBName, tsTable) valueCtx := context.WithValue(ctx, "clickhouse_max_threads", constants.MetricsExplorerClickhouseThreads) - rows, err := r.db.Query(valueCtx, extractedLabelsQuery, req.CurrentMetricName, start, end) + rows, err := r.db.Query(valueCtx, extractedLabelsQuery, req.CurrentMetricName, start, end, normalized) if err != nil { return nil, &model.ApiError{Typ: "ClickHouseError", Err: err} } @@ -5819,7 +5869,7 @@ func (r *ClickHouseReader) GetAttributeSimilarity(ctx context.Context, req *metr WHERE rand() %% 100 < 10 AND unix_milli between ? and ? AND NOT startsWith(metric_name, 'signoz_') - AND __normalized = true + AND __normalized = ? GROUP BY metric_name ORDER BY weighted_match_count DESC, raw_match_count DESC LIMIT 30 @@ -5827,7 +5877,7 @@ func (r *ClickHouseReader) GetAttributeSimilarity(ctx context.Context, req *metr targetKeysList, targetValuesList, priorityListString, 2, signozMetricDBName, tsTable) - rows, err = r.db.Query(valueCtx, candidateLabelsQuery, start, end) + rows, err = r.db.Query(valueCtx, candidateLabelsQuery, start, end, normalized) if err != nil { return nil, &model.ApiError{Typ: "ClickHouseError", Err: err} } diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go index 8fff0690ad..8c6a6366fb 100644 --- a/pkg/query-service/app/http_handler.go +++ b/pkg/query-service/app/http_handler.go @@ -7,6 +7,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/SigNoz/signoz/pkg/query-service/constants" "io" "math" "net/http" @@ -29,7 +30,6 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/app/cloudintegrations/services" "github.com/SigNoz/signoz/pkg/query-service/app/integrations" "github.com/SigNoz/signoz/pkg/query-service/app/metricsexplorer" - "github.com/SigNoz/signoz/pkg/query-service/constants" "github.com/SigNoz/signoz/pkg/signoz" "github.com/SigNoz/signoz/pkg/valuer" "github.com/prometheus/prometheus/promql" @@ -1198,7 +1198,31 @@ func prepareQuery(r *http.Request) (string, error) { if tmplErr != nil { return "", tmplErr } - return queryBuf.String(), nil + + if !constants.IsDotMetricsEnabled { + return queryBuf.String(), nil + } + + query = queryBuf.String() + + // Now handle $var replacements (simple string replace) + keys := make([]string, 0, len(vars)) + for k := range vars { + keys = append(keys, k) + } + + sort.Slice(keys, func(i, j int) bool { + return len(keys[i]) > len(keys[j]) + }) + + newQuery := query + for _, k := range keys { + placeholder := "$" + k + v := vars[k] + newQuery = strings.ReplaceAll(newQuery, placeholder, v) + } + + return newQuery, nil } func (aH *APIHandler) queryDashboardVarsV2(w http.ResponseWriter, r *http.Request) { @@ -1996,6 +2020,12 @@ func (aH *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) { } } } + if constants.IsDotMetricsEnabled { + featureSet = append(featureSet, &featuretypes.GettableFeature{ + Name: featuretypes.DotMetricsEnabled, + Active: true, + }) + } aH.Respond(w, featureSet) } @@ -2503,6 +2533,12 @@ func (aH *APIHandler) onboardKafka(w http.ResponseWriter, r *http.Request) { } } } + var kafkaConsumerFetchLatencyAvg string = "kafka_consumer_fetch_latency_avg" + var kafkaConsumerLag string = "kafka_consumer_group_lag" + if constants.IsDotMetricsEnabled { + kafkaConsumerLag = "kafka.consumer_group.lag" + kafkaConsumerFetchLatencyAvg = "kafka.consumer.fetch_latency_avg" + } if !fetchLatencyState && !consumerLagState { entries = append(entries, kafka.OnboardingResponse{ @@ -2513,27 +2549,28 @@ func (aH *APIHandler) onboardKafka(w http.ResponseWriter, r *http.Request) { } if !fetchLatencyState { + entries = append(entries, kafka.OnboardingResponse{ - Attribute: "kafka_consumer_fetch_latency_avg", + Attribute: kafkaConsumerFetchLatencyAvg, Message: "Metric kafka_consumer_fetch_latency_avg is not present in the given time range.", Status: "0", }) } else { entries = append(entries, kafka.OnboardingResponse{ - Attribute: "kafka_consumer_fetch_latency_avg", + Attribute: kafkaConsumerFetchLatencyAvg, Status: "1", }) } if !consumerLagState { entries = append(entries, kafka.OnboardingResponse{ - Attribute: "kafka_consumer_group_lag", + Attribute: kafkaConsumerLag, Message: "Metric kafka_consumer_group_lag is not present in the given time range.", Status: "0", }) } else { entries = append(entries, kafka.OnboardingResponse{ - Attribute: "kafka_consumer_group_lag", + Attribute: kafkaConsumerLag, Status: "1", }) } @@ -4327,7 +4364,7 @@ func (aH *APIHandler) autocompleteAggregateAttributes(w http.ResponseWriter, r * switch req.DataSource { case v3.DataSourceMetrics: - response, err = aH.reader.GetMetricAggregateAttributes(r.Context(), orgID, req, true, false) + response, err = aH.reader.GetMetricAggregateAttributes(r.Context(), orgID, req, false) case v3.DataSourceLogs: response, err = aH.reader.GetLogAggregateAttributes(r.Context(), req) case v3.DataSourceTraces: diff --git a/pkg/query-service/app/inframetrics/clusters.go b/pkg/query-service/app/inframetrics/clusters.go index b5425c9906..08860609fb 100644 --- a/pkg/query-service/app/inframetrics/clusters.go +++ b/pkg/query-service/app/inframetrics/clusters.go @@ -16,12 +16,12 @@ import ( ) var ( - metricToUseForClusters = "k8s_node_cpu_utilization" + metricToUseForClusters = GetDotMetrics("k8s_node_cpu_utilization") - clusterAttrsToEnrich = []string{"k8s_cluster_name"} + clusterAttrsToEnrich = []string{GetDotMetrics("k8s_cluster_name")} // TODO(srikanthccv): change this to k8s_cluster_uid after showing the missing data banner - k8sClusterUIDAttrKey = "k8s_cluster_name" + k8sClusterUIDAttrKey = GetDotMetrics("k8s_cluster_name") queryNamesForClusters = map[string][]string{ "cpu": {"A"}, diff --git a/pkg/query-service/app/inframetrics/common.go b/pkg/query-service/app/inframetrics/common.go index 8f7a6bab4b..7ee1edbd63 100644 --- a/pkg/query-service/app/inframetrics/common.go +++ b/pkg/query-service/app/inframetrics/common.go @@ -1,6 +1,7 @@ package inframetrics import ( + "fmt" "strings" "time" @@ -8,42 +9,239 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/model" ) +var dotMetricMap = map[string]string{ + "system_cpu_time": "system.cpu.time", + "system_memory_usage": "system.memory.usage", + "system_cpu_load_average_15m": "system.cpu.load_average.15m", + "host_name": "host.name", + "k8s_cluster_name": "k8s.cluster.name", + "k8s_node_name": "k8s.node.name", + "k8s_node_cpu_utilization": "k8s.node.cpu.utilization", + "k8s_pod_cpu_utilization": "k8s.pod.cpu.utilization", + "k8s_pod_memory_usage": "k8s.pod.memory.usage", + "k8s_pod_cpu_request_utilization": "k8s.pod.cpu_request_utilization", + "k8s_pod_memory_request_utilization": "k8s.pod.memory_request_utilization", + "k8s_pod_cpu_limit_utilization": "k8s.pod.cpu_limit_utilization", + "k8s_pod_memory_limit_utilization": "k8s.pod.memory_limit_utilization", + "k8s_container_restarts": "k8s.container.restarts", + "k8s_pod_phase": "k8s.pod.phase", + "k8s_node_allocatable_cpu": "k8s.node.allocatable_cpu", + "k8s_node_allocatable_memory": "k8s.node.allocatable_memory", + "k8s_node_memory_usage": "k8s.node.memory.usage", + "k8s_node_condition_ready": "k8s.node.condition_ready", + "k8s_daemonset_desired_scheduled_nodes": "k8s.daemonset.desired_scheduled_nodes", + "k8s_daemonset_current_scheduled_nodes": "k8s.daemonset.current_scheduled_nodes", + "k8s_deployment_desired": "k8s.deployment.desired", + "k8s_deployment_available": "k8s.deployment.available", + "k8s_job_desired_successful_pods": "k8s.job.desired_successful_pods", + "k8s_job_active_pods": "k8s.job.active_pods", + "k8s_job_failed_pods": "k8s.job.failed_pods", + "k8s_job_successful_pods": "k8s.job.successful_pods", + "k8s_statefulset_desired_pods": "k8s.statefulset.desired_pods", + "k8s_statefulset_current_pods": "k8s.statefulset.current_pods", + "k8s_namespace_name": "k8s.namespace.name", + "k8s_deployment_name": "k8s.deployment.name", + "k8s_cronjob_name": "k8s.cronjob.name", + "k8s_job_name": "k8s.job.name", + "k8s_daemonset_name": "k8s.daemonset.name", + "os_type": "os.type", + "process_cgroup": "process.cgroup", + "process_pid": "process.pid", + "process_parent_pid": "process.parent_pid", + "process_owner": "process.owner", + "process_executable_path": "process.executable.path", + "process_executable_name": "process.executable.name", + "process_command_line": "process.command_line", + "process_command": "process.command", + "process_memory_usage": "process.memory.usage", + "k8s_persistentvolumeclaim_name": "k8s.persistentvolumeclaim.name", + "k8s_volume_available": "k8s.volume.available", + "k8s_volume_capacity": "k8s.volume.capacity", + "k8s_volume_inodes": "k8s.volume.inodes", + "k8s_volume_inodes_free": "k8s.volume.inodes.free", + // add additional mappings as needed + + "k8s_pod_uid": "k8s.pod.uid", + "k8s_pod_name": "k8s.pod.name", + "k8s_container_name": "k8s.container.name", + "container_id": "container.id", + "k8s_volume_name": "k8s.volume.name", + "k8s_volume_type": "k8s.volume.type", + "aws_volume_id": "aws.volume.id", + "fs_type": "fs.type", + "partition": "partition", + "gce_pd_name": "gce.pd.name", + "glusterfs_endpoints_name": "glusterfs.endpoints.name", + "glusterfs_path": "glusterfs.path", + "interface": "interface", + "direction": "direction", + + "k8s_node_cpu_usage": "k8s.node.cpu.usage", + "k8s_node_cpu_time": "k8s.node.cpu.time", + "k8s_node_memory_available": "k8s.node.memory.available", + "k8s_node_memory_rss": "k8s.node.memory.rss", + "k8s_node_memory_working_set": "k8s.node.memory.working_set", + "k8s_node_memory_page_faults": "k8s.node.memory.page_faults", + "k8s_node_memory_major_page_faults": "k8s.node.memory.major_page_faults", + "k8s_node_filesystem_available": "k8s.node.filesystem.available", + "k8s_node_filesystem_capacity": "k8s.node.filesystem.capacity", + "k8s_node_filesystem_usage": "k8s.node.filesystem.usage", + "k8s_node_network_io": "k8s.node.network.io", + "k8s_node_network_errors": "k8s.node.network.errors", + "k8s_node_uptime": "k8s.node.uptime", + + "k8s_pod_cpu_usage": "k8s.pod.cpu.usage", + "k8s_pod_cpu_time": "k8s.pod.cpu.time", + "k8s_pod_memory_available": "k8s.pod.memory.available", + "k8s_pod_cpu_node_utilization": "k8s.pod.cpu.node.utilization", + "k8s_pod_memory_node_utilization": "k8s.pod.memory.node.utilization", + "k8s_pod_memory_rss": "k8s.pod.memory.rss", + "k8s_pod_memory_working_set": "k8s.pod.memory.working_set", + "k8s_pod_memory_page_faults": "k8s.pod.memory.page_faults", + "k8s_pod_memory_major_page_faults": "k8s.pod.memory.major_page_faults", + "k8s_pod_filesystem_available": "k8s.pod.filesystem.available", + "k8s_pod_filesystem_capacity": "k8s.pod.filesystem.capacity", + "k8s_pod_filesystem_usage": "k8s.pod.filesystem.usage", + "k8s_pod_network_io": "k8s.pod.network.io", + "k8s_pod_network_errors": "k8s.pod.network.errors", + "k8s_pod_uptime": "k8s.pod.uptime", + + "container_cpu_usage": "container.cpu.usage", + "container_cpu_utilization": "container.cpu.utilization", + "container_cpu_time": "container.cpu.time", + "container_memory_available": "container.memory.available", + "container_memory_usage": "container.memory.usage", + "k8s_container_cpu_node_utilization": "k8s.container.cpu.node.utilization", + "k8s_container_cpu_limit_utilization": "k8s.container.cpu_limit_utilization", + "k8s_container_cpu_request_utilization": "k8s.container.cpu_request_utilization", + "k8s_container_memory_node_utilization": "k8s.container.memory.node.utilization", + "k8s_container_memory_limit_utilization": "k8s.container.memory_limit_utilization", + "k8s_container_memory_request_utilization": "k8s.container.memory_request_utilization", + "container_memory_rss": "container.memory.rss", + "container_memory_working_set": "container.memory.working_set", + "container_memory_page_faults": "container.memory.page_faults", + "container_memory_major_page_faults": "container.memory.major_page_faults", + "container_filesystem_available": "container.filesystem.available", + "container_filesystem_capacity": "container.filesystem.capacity", + "container_filesystem_usage": "container.filesystem.usage", + "container_uptime": "container.uptime", + + "k8s_volume_inodes_used": "k8s.volume.inodes.used", + + "k8s_namespace_uid": "k8s.namespace.uid", + "container_image_name": "container.image.name", + "container_image_tag": "container.image.tag", + "k8s_pod_qos_class": "k8s.pod.qos_class", + "k8s_replicaset_name": "k8s.replicaset.name", + "k8s_replicaset_uid": "k8s.replicaset.uid", + "k8s_replicationcontroller_name": "k8s.replicationcontroller.name", + "k8s_replicationcontroller_uid": "k8s.replicationcontroller.uid", + "k8s_resourcequota_uid": "k8s.resourcequota.uid", + "k8s_resourcequota_name": "k8s.resourcequota.name", + "k8s_statefulset_uid": "k8s.statefulset.uid", + "k8s_statefulset_name": "k8s.statefulset.name", + "k8s_deployment_uid": "k8s.deployment.uid", + "k8s_cronjob_uid": "k8s.cronjob.uid", + "k8s_daemonset_uid": "k8s.daemonset.uid", + "k8s_hpa_uid": "k8s.hpa.uid", + "k8s_hpa_name": "k8s.hpa.name", + "k8s_hpa_scaletargetref_kind": "k8s.hpa.scaletargetref.kind", + "k8s_hpa_scaletargetref_name": "k8s.hpa.scaletargetref.name", + "k8s_hpa_scaletargetref_apiversion": "k8s.hpa.scaletargetref.apiversion", + "k8s_job_uid": "k8s.job.uid", + "k8s_kubelet_version": "k8s.kubelet.version", + "container_runtime": "container.runtime", + "container_runtime_version": "container.runtime.version", + "os_description": "os.description", + "openshift_clusterquota_uid": "openshift.clusterquota.uid", + "openshift_clusterquota_name": "openshift.clusterquota.name", + "k8s_container_status_last_terminated_reason": "k8s.container.status.last_terminated_reason", + + "resource": "resource", + "condition": "condition", + + "k8s_container_cpu_request": "k8s.container.cpu_request", + "k8s_container_cpu_limit": "k8s.container.cpu_limit", + "k8s_container_memory_request": "k8s.container.memory_request", + "k8s_container_memory_limit": "k8s.container.memory_limit", + "k8s_container_storage_request": "k8s.container.storage_request", + "k8s_container_storage_limit": "k8s.container.storage_limit", + "k8s_container_ephemeralstorage_request": "k8s.container.ephemeralstorage_request", + "k8s_container_ephemeralstorage_limit": "k8s.container.ephemeralstorage_limit", + "k8s_container_ready": "k8s.container.ready", + + "k8s_pod_status_reason": "k8s.pod.status_reason", + + "k8s_cronjob_active_jobs": "k8s.cronjob.active_jobs", + + "k8s_daemonset_misscheduled_nodes": "k8s.daemonset.misscheduled_nodes", + "k8s_daemonset_ready_nodes": "k8s.daemonset.ready_nodes", + + "k8s_hpa_max_replicas": "k8s.hpa.max_replicas", + "k8s_hpa_min_replicas": "k8s.hpa.min_replicas", + "k8s_hpa_current_replicas": "k8s.hpa.current_replicas", + "k8s_hpa_desired_replicas": "k8s.hpa.desired_replicas", + + "k8s_job_max_parallel_pods": "k8s.job.max_parallel_pods", + + "k8s_namespace_phase": "k8s.namespace.phase", + + "k8s_replicaset_desired": "k8s.replicaset.desired", + "k8s_replicaset_available": "k8s.replicaset.available", + + "k8s_replication_controller_desired": "k8s.replication_controller.desired", + "k8s_replication_controller_available": "k8s.replication_controller.available", + + "k8s_resource_quota_hard_limit": "k8s.resource_quota.hard_limit", + "k8s_resource_quota_used": "k8s.resource_quota.used", + + "k8s_statefulset_updated_pods": "k8s.statefulset.updated_pods", + + "k8s_node_condition": "k8s.node.condition", +} + +const fromWhereQuery = ` +FROM %s.%s +WHERE metric_name IN (%s) + AND unix_milli >= toUnixTimestamp(now() - toIntervalMinute(60)) * 1000 +` + var ( // TODO(srikanthccv): import metadata yaml from receivers and use generated files to check the metrics podMetricNamesToCheck = []string{ - "k8s_pod_cpu_utilization", - "k8s_pod_memory_usage", - "k8s_pod_cpu_request_utilization", - "k8s_pod_memory_request_utilization", - "k8s_pod_cpu_limit_utilization", - "k8s_pod_memory_limit_utilization", - "k8s_container_restarts", - "k8s_pod_phase", + GetDotMetrics("k8s_pod_cpu_utilization"), + GetDotMetrics("k8s_pod_memory_usage"), + GetDotMetrics("k8s_pod_cpu_request_utilization"), + GetDotMetrics("k8s_pod_memory_request_utilization"), + GetDotMetrics("k8s_pod_cpu_limit_utilization"), + GetDotMetrics("k8s_pod_memory_limit_utilization"), + GetDotMetrics("k8s_container_restarts"), + GetDotMetrics("k8s_pod_phase"), } nodeMetricNamesToCheck = []string{ - "k8s_node_cpu_utilization", - "k8s_node_allocatable_cpu", - "k8s_node_memory_usage", - "k8s_node_allocatable_memory", - "k8s_node_condition_ready", + GetDotMetrics("k8s_node_cpu_utilization"), + GetDotMetrics("k8s_node_allocatable_cpu"), + GetDotMetrics("k8s_node_memory_usage"), + GetDotMetrics("k8s_node_allocatable_memory"), + GetDotMetrics("k8s_node_condition_ready"), } clusterMetricNamesToCheck = []string{ - "k8s_daemonset_desired_scheduled_nodes", - "k8s_daemonset_current_scheduled_nodes", - "k8s_deployment_desired", - "k8s_deployment_available", - "k8s_job_desired_successful_pods", - "k8s_job_active_pods", - "k8s_job_failed_pods", - "k8s_job_successful_pods", - "k8s_statefulset_desired_pods", - "k8s_statefulset_current_pods", + GetDotMetrics("k8s_daemonset_desired_scheduled_nodes"), + GetDotMetrics("k8s_daemonset_current_scheduled_nodes"), + GetDotMetrics("k8s_deployment_desired"), + GetDotMetrics("k8s_deployment_available"), + GetDotMetrics("k8s_job_desired_successful_pods"), + GetDotMetrics("k8s_job_active_pods"), + GetDotMetrics("k8s_job_failed_pods"), + GetDotMetrics("k8s_job_successful_pods"), + GetDotMetrics("k8s_statefulset_desired_pods"), + GetDotMetrics("k8s_statefulset_current_pods"), } optionalPodMetricNamesToCheck = []string{ - "k8s_pod_cpu_request_utilization", - "k8s_pod_memory_request_utilization", - "k8s_pod_cpu_limit_utilization", - "k8s_pod_memory_limit_utilization", + GetDotMetrics("k8s_pod_cpu_request_utilization"), + GetDotMetrics("k8s_pod_memory_request_utilization"), + GetDotMetrics("k8s_pod_cpu_limit_utilization"), + GetDotMetrics("k8s_pod_memory_limit_utilization"), } // did they ever send _any_ pod metrics? @@ -68,22 +266,40 @@ var ( ` // there should be [cluster, node, namespace, one of (deployment, statefulset, daemonset, cronjob, job)] for each pod - isSendingRequiredMetadataQuery = ` - SELECT any(JSONExtractString(labels, 'k8s_cluster_name')) as k8s_cluster_name, - any(JSONExtractString(labels, 'k8s_node_name')) as k8s_node_name, - any(JSONExtractString(labels, 'k8s_namespace_name')) as k8s_namespace_name, - any(JSONExtractString(labels, 'k8s_deployment_name')) as k8s_deployment_name, - any(JSONExtractString(labels, 'k8s_statefulset_name')) as k8s_statefulset_name, - any(JSONExtractString(labels, 'k8s_daemonset_name')) as k8s_daemonset_name, - any(JSONExtractString(labels, 'k8s_cronjob_name')) as k8s_cronjob_name, - any(JSONExtractString(labels, 'k8s_job_name')) as k8s_job_name, - JSONExtractString(labels, 'k8s_pod_name') as k8s_pod_name - FROM %s.%s WHERE metric_name IN (%s) - AND (unix_milli >= (toUnixTimestamp(now() - toIntervalMinute(60)) * 1000)) - AND JSONExtractString(labels, 'k8s_namespace_name') NOT IN ('kube-system', 'kube-public', 'kube-node-lease', 'metallb-system') - GROUP BY k8s_pod_name - LIMIT 1 BY k8s_cluster_name, k8s_node_name, k8s_namespace_name -` + + selectQuery = fmt.Sprintf(` +SELECT + any(JSONExtractString(labels, '%s')) as k8s_cluster_name, + any(JSONExtractString(labels, '%s')) as k8s_node_name, + any(JSONExtractString(labels, '%s')) as k8s_namespace_name, + any(JSONExtractString(labels, '%s')) as k8s_deployment_name, + any(JSONExtractString(labels, '%s')) as k8s_statefulset_name, + any(JSONExtractString(labels, '%s')) as k8s_daemonset_name, + any(JSONExtractString(labels, '%s')) as k8s_cronjob_name, + any(JSONExtractString(labels, '%s')) as k8s_job_name, + JSONExtractString(labels, '%s') as k8s_pod_name +`, + GetDotMetrics("k8s_cluster_name"), + GetDotMetrics("k8s_node_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_deployment_name"), + GetDotMetrics("k8s_statefulset_name"), + GetDotMetrics("k8s_daemonset_name"), + GetDotMetrics("k8s_cronjob_name"), + GetDotMetrics("k8s_job_name"), + GetDotMetrics("k8s_pod_name"), + ) + + filterGroupQuery = fmt.Sprintf(` +AND JSONExtractString(labels, '%s') + NOT IN ('kube-system','kube-public','kube-node-lease','metallb-system') +GROUP BY k8s_pod_name +LIMIT 1 BY k8s_cluster_name, k8s_node_name, k8s_namespace_name +`, + GetDotMetrics("k8s_namespace_name"), + ) + + isSendingRequiredMetadataQuery = selectQuery + fromWhereQuery + filterGroupQuery ) // getParamsForTopItems returns the step, time series table name and samples table name @@ -181,3 +397,12 @@ func getParamsForTopVolumes(req model.VolumeListRequest) (int64, string, string) func localQueryToDistributedQuery(query string) string { return strings.Replace(query, ".time_series_v4", ".distributed_time_series_v4", 1) } + +func GetDotMetrics(key string) string { + if constants.IsDotMetricsEnabled { + if _, ok := dotMetricMap[key]; ok { + return dotMetricMap[key] + } + } + return key +} diff --git a/pkg/query-service/app/inframetrics/daemonsets.go b/pkg/query-service/app/inframetrics/daemonsets.go index c5a9aaee49..85b31248b2 100644 --- a/pkg/query-service/app/inframetrics/daemonsets.go +++ b/pkg/query-service/app/inframetrics/daemonsets.go @@ -16,18 +16,18 @@ import ( ) var ( - metricToUseForDaemonSets = "k8s_pod_cpu_utilization" - k8sDaemonSetNameAttrKey = "k8s_daemonset_name" + metricToUseForDaemonSets = GetDotMetrics("k8s_pod_cpu_utilization") + k8sDaemonSetNameAttrKey = GetDotMetrics("k8s_daemonset_name") metricNamesForDaemonSets = map[string]string{ - "desired_nodes": "k8s_daemonset_desired_scheduled_nodes", - "available_nodes": "k8s_daemonset_current_scheduled_nodes", + "desired_nodes": GetDotMetrics("k8s_daemonset_desired_scheduled_nodes"), + "available_nodes": GetDotMetrics("k8s_daemonset_current_scheduled_nodes"), } daemonSetAttrsToEnrich = []string{ - "k8s_daemonset_name", - "k8s_namespace_name", - "k8s_cluster_name", + GetDotMetrics("k8s_daemonset_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_cluster_name"), } queryNamesForDaemonSets = map[string][]string{ diff --git a/pkg/query-service/app/inframetrics/deployments.go b/pkg/query-service/app/inframetrics/deployments.go index 9865c2ccde..3645d1a33a 100644 --- a/pkg/query-service/app/inframetrics/deployments.go +++ b/pkg/query-service/app/inframetrics/deployments.go @@ -16,18 +16,18 @@ import ( ) var ( - metricToUseForDeployments = "k8s_pod_cpu_utilization" - k8sDeploymentNameAttrKey = "k8s_deployment_name" + metricToUseForDeployments = GetDotMetrics("k8s_pod_cpu_utilization") + k8sDeploymentNameAttrKey = GetDotMetrics("k8s_deployment_name") metricNamesForDeployments = map[string]string{ - "desired_pods": "k8s_deployment_desired", - "available_pods": "k8s_deployment_available", + "desired_pods": GetDotMetrics("k8s_deployment_desired"), + "available_pods": GetDotMetrics("k8s_deployment_available"), } deploymentAttrsToEnrich = []string{ - "k8s_deployment_name", - "k8s_namespace_name", - "k8s_cluster_name", + GetDotMetrics("k8s_deployment_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_cluster_name"), } queryNamesForDeployments = map[string][]string{ diff --git a/pkg/query-service/app/inframetrics/hosts.go b/pkg/query-service/app/inframetrics/hosts.go index db0f380238..82cf75f15d 100644 --- a/pkg/query-service/app/inframetrics/hosts.go +++ b/pkg/query-service/app/inframetrics/hosts.go @@ -41,15 +41,15 @@ var ( "mode", "mountpoint", "type", - "os_type", - "process_cgroup", - "process_command", - "process_command_line", - "process_executable_name", - "process_executable_path", - "process_owner", - "process_parent_pid", - "process_pid", + GetDotMetrics("os_type"), + GetDotMetrics("process_cgroup"), + GetDotMetrics("process_command"), + GetDotMetrics("process_command_line"), + GetDotMetrics("process_executable_name"), + GetDotMetrics("process_executable_path"), + GetDotMetrics("process_owner"), + GetDotMetrics("process_parent_pid"), + GetDotMetrics("process_pid"), } queryNamesForTopHosts = map[string][]string{ @@ -60,17 +60,17 @@ var ( } // TODO(srikanthccv): remove hardcoded metric name and support keys from any system metric - metricToUseForHostAttributes = "system_cpu_load_average_15m" - hostNameAttrKey = "host_name" + metricToUseForHostAttributes = GetDotMetrics("system_cpu_load_average_15m") + hostNameAttrKey = GetDotMetrics("host_name") agentNameToIgnore = "k8s-infra-otel-agent" hostAttrsToEnrich = []string{ - "os_type", + GetDotMetrics("os_type"), } metricNamesForHosts = map[string]string{ - "cpu": "system_cpu_time", - "memory": "system_memory_usage", - "load15": "system_cpu_load_average_15m", - "wait": "system_cpu_time", + "cpu": GetDotMetrics("system_cpu_time"), + "memory": GetDotMetrics("system_memory_usage"), + "load15": GetDotMetrics("system_cpu_load_average_15m"), + "wait": GetDotMetrics("system_cpu_time"), } ) @@ -351,13 +351,14 @@ func (h *HostsRepo) IsSendingK8SAgentMetrics(ctx context.Context, req model.Host constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_SAMPLES_V4_TABLENAME, namesStr) query := fmt.Sprintf(` - SELECT DISTINCT JSONExtractString(labels, 'k8s_cluster_name') as k8s_cluster_name, JSONExtractString(labels, 'k8s_node_name') as k8s_node_name + SELECT DISTINCT JSONExtractString(labels, '%s') as k8s_cluster_name, JSONExtractString(labels, '%s') as k8s_node_name FROM %s.%s WHERE metric_name IN (%s) AND unix_milli >= toUnixTimestamp(now() - INTERVAL 60 MINUTE) * 1000 - AND JSONExtractString(labels, 'host_name') LIKE '%%-otel-agent%%' + AND JSONExtractString(labels, '%s') LIKE '%%-otel-agent%%' AND fingerprint GLOBAL IN (%s)`, - constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_V4_TABLENAME, namesStr, queryForRecentFingerprints) + GetDotMetrics("k8s_cluster_name"), GetDotMetrics("k8s_node_name"), + constants.SIGNOZ_METRIC_DBNAME, constants.SIGNOZ_TIMESERIES_V4_TABLENAME, namesStr, GetDotMetrics("host_name"), queryForRecentFingerprints) result, err := h.reader.GetListResultV3(ctx, query) if err != nil { @@ -368,13 +369,13 @@ func (h *HostsRepo) IsSendingK8SAgentMetrics(ctx context.Context, req model.Host nodeNames := make(map[string]struct{}) for _, row := range result { - switch v := row.Data["k8s_cluster_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_cluster_name")].(type) { case string: clusterNames[v] = struct{}{} case *string: clusterNames[*v] = struct{}{} } - switch v := row.Data["k8s_node_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_node_name")].(type) { case string: nodeNames[v] = struct{}{} case *string: diff --git a/pkg/query-service/app/inframetrics/jobs.go b/pkg/query-service/app/inframetrics/jobs.go index 7f8aa61b70..654d633def 100644 --- a/pkg/query-service/app/inframetrics/jobs.go +++ b/pkg/query-service/app/inframetrics/jobs.go @@ -16,20 +16,20 @@ import ( ) var ( - metricToUseForJobs = "k8s_job_desired_successful_pods" - k8sJobNameAttrKey = "k8s_job_name" + metricToUseForJobs = GetDotMetrics("k8s_job_desired_successful_pods") + k8sJobNameAttrKey = GetDotMetrics("k8s_job_name") metricNamesForJobs = map[string]string{ - "desired_successful_pods": "k8s_job_desired_successful_pods", - "active_pods": "k8s_job_active_pods", - "failed_pods": "k8s_job_failed_pods", - "successful_pods": "k8s_job_successful_pods", + "desired_successful_pods": GetDotMetrics("k8s_job_desired_successful_pods"), + "active_pods": GetDotMetrics("k8s_job_active_pods"), + "failed_pods": GetDotMetrics("k8s_job_failed_pods"), + "successful_pods": GetDotMetrics("k8s_job_successful_pods"), } jobAttrsToEnrich = []string{ - "k8s_job_name", - "k8s_namespace_name", - "k8s_cluster_name", + GetDotMetrics("k8s_job_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_cluster_name"), } queryNamesForJobs = map[string][]string{ @@ -52,7 +52,7 @@ var ( QueryName: "H", DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: metricNamesForJobs["desired_successful_pods"], + Key: GetDotMetrics(metricNamesForJobs["desired_successful_pods"]), DataType: v3.AttributeKeyDataTypeFloat64, }, Temporality: v3.Unspecified, @@ -72,7 +72,7 @@ var ( QueryName: "I", DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: metricNamesForJobs["active_pods"], + Key: GetDotMetrics(metricNamesForJobs["active_pods"]), DataType: v3.AttributeKeyDataTypeFloat64, }, Temporality: v3.Unspecified, @@ -92,7 +92,7 @@ var ( QueryName: "J", DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: metricNamesForJobs["failed_pods"], + Key: GetDotMetrics(metricNamesForJobs["failed_pods"]), DataType: v3.AttributeKeyDataTypeFloat64, }, Temporality: v3.Unspecified, @@ -112,7 +112,7 @@ var ( QueryName: "K", DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: metricNamesForJobs["successful_pods"], + Key: GetDotMetrics(metricNamesForJobs["successful_pods"]), DataType: v3.AttributeKeyDataTypeFloat64, }, Temporality: v3.Unspecified, @@ -321,7 +321,7 @@ func (d *JobsRepo) GetJobList(ctx context.Context, orgID valuer.UUID, req model. } if req.OrderBy == nil { - req.OrderBy = &v3.OrderBy{ColumnName: "desired_pods", Order: v3.DirectionDesc} + req.OrderBy = &v3.OrderBy{ColumnName: GetDotMetrics("desired_pods"), Order: v3.DirectionDesc} } if req.GroupBy == nil { diff --git a/pkg/query-service/app/inframetrics/namespaces.go b/pkg/query-service/app/inframetrics/namespaces.go index b3c6249190..32606d7282 100644 --- a/pkg/query-service/app/inframetrics/namespaces.go +++ b/pkg/query-service/app/inframetrics/namespaces.go @@ -16,11 +16,11 @@ import ( ) var ( - metricToUseForNamespaces = "k8s_pod_cpu_utilization" + metricToUseForNamespaces = GetDotMetrics("k8s_pod_cpu_utilization") namespaceAttrsToEnrich = []string{ - "k8s_namespace_name", - "k8s_cluster_name", + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_cluster_name"), } queryNamesForNamespaces = map[string][]string{ @@ -31,11 +31,11 @@ var ( namespaceQueryNames = []string{"A", "D", "H", "I", "J", "K"} attributesKeysForNamespaces = []v3.AttributeKey{ - {Key: "k8s_namespace_name"}, - {Key: "k8s_cluster_name"}, + {Key: GetDotMetrics("k8s_namespace_name")}, + {Key: GetDotMetrics("k8s_cluster_name")}, } - k8sNamespaceNameAttrKey = "k8s_namespace_name" + k8sNamespaceNameAttrKey = GetDotMetrics("k8s_namespace_name") ) type NamespacesRepo struct { diff --git a/pkg/query-service/app/inframetrics/nodes.go b/pkg/query-service/app/inframetrics/nodes.go index 7e1cfeffce..df0095a791 100644 --- a/pkg/query-service/app/inframetrics/nodes.go +++ b/pkg/query-service/app/inframetrics/nodes.go @@ -3,10 +3,6 @@ package inframetrics import ( "context" "fmt" - "math" - "sort" - "strings" - "github.com/SigNoz/signoz/pkg/query-service/app/metrics/v4/helpers" "github.com/SigNoz/signoz/pkg/query-service/common" "github.com/SigNoz/signoz/pkg/query-service/constants" @@ -16,14 +12,17 @@ import ( "github.com/SigNoz/signoz/pkg/query-service/postprocess" "github.com/SigNoz/signoz/pkg/valuer" "golang.org/x/exp/slices" + "math" + "sort" + "strings" ) var ( - metricToUseForNodes = "k8s_node_cpu_utilization" + metricToUseForNodes = GetDotMetrics("k8s_node_cpu_utilization") - nodeAttrsToEnrich = []string{"k8s_node_name", "k8s_node_uid", "k8s_cluster_name"} + nodeAttrsToEnrich = []string{GetDotMetrics("k8s_node_name"), GetDotMetrics("k8s_node_uid"), GetDotMetrics("k8s_cluster_name")} - k8sNodeGroupAttrKey = "k8s_node_name" + k8sNodeGroupAttrKey = GetDotMetrics("k8s_node_name") queryNamesForNodes = map[string][]string{ "cpu": {"A"}, @@ -34,11 +33,11 @@ var ( nodeQueryNames = []string{"A", "B", "C", "D", "E", "F"} metricNamesForNodes = map[string]string{ - "cpu": "k8s_node_cpu_utilization", - "cpu_allocatable": "k8s_node_allocatable_cpu", - "memory": "k8s_node_memory_usage", - "memory_allocatable": "k8s_node_allocatable_memory", - "node_condition": "k8s_node_condition_ready", + "cpu": GetDotMetrics("k8s_node_cpu_utilization"), + "cpu_allocatable": GetDotMetrics("k8s_node_allocatable_cpu"), + "memory": GetDotMetrics("k8s_node_memory_usage"), + "memory_allocatable": GetDotMetrics("k8s_node_allocatable_memory"), + "node_condition": GetDotMetrics("k8s_node_condition_ready"), } ) diff --git a/pkg/query-service/app/inframetrics/pods.go b/pkg/query-service/app/inframetrics/pods.go index a895b75623..d3a5a32325 100644 --- a/pkg/query-service/app/inframetrics/pods.go +++ b/pkg/query-service/app/inframetrics/pods.go @@ -19,22 +19,22 @@ import ( ) var ( - metricToUseForPods = "k8s_pod_cpu_utilization" + metricToUseForPods = GetDotMetrics("k8s_pod_cpu_utilization") podAttrsToEnrich = []string{ - "k8s_pod_uid", - "k8s_pod_name", - "k8s_namespace_name", - "k8s_node_name", - "k8s_deployment_name", - "k8s_statefulset_name", - "k8s_daemonset_name", - "k8s_job_name", - "k8s_cronjob_name", - "k8s_cluster_name", + GetDotMetrics("k8s_pod_uid"), + GetDotMetrics("k8s_pod_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_node_name"), + GetDotMetrics("k8s_deployment_name"), + GetDotMetrics("k8s_statefulset_name"), + GetDotMetrics("k8s_daemonset_name"), + GetDotMetrics("k8s_job_name"), + GetDotMetrics("k8s_cronjob_name"), + GetDotMetrics("k8s_cluster_name"), } - k8sPodUIDAttrKey = "k8s_pod_uid" + k8sPodUIDAttrKey = GetDotMetrics("k8s_pod_uid") queryNamesForPods = map[string][]string{ "cpu": {"A"}, @@ -49,14 +49,14 @@ var ( podQueryNames = []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"} metricNamesForPods = map[string]string{ - "cpu": "k8s_pod_cpu_utilization", - "cpu_request": "k8s_pod_cpu_request_utilization", - "cpu_limit": "k8s_pod_cpu_limit_utilization", - "memory": "k8s_pod_memory_usage", - "memory_request": "k8s_pod_memory_request_utilization", - "memory_limit": "k8s_pod_memory_limit_utilization", - "restarts": "k8s_container_restarts", - "pod_phase": "k8s_pod_phase", + "cpu": GetDotMetrics("k8s_pod_cpu_utilization"), + "cpu_request": GetDotMetrics("k8s_pod_cpu_request_utilization"), + "cpu_limit": GetDotMetrics("k8s_pod_cpu_limit_utilization"), + "memory": GetDotMetrics("k8s_pod_memory_usage"), + "memory_request": GetDotMetrics("k8s_pod_memory_request_utilization"), + "memory_limit": GetDotMetrics("k8s_pod_memory_limit_utilization"), + "restarts": GetDotMetrics("k8s_container_restarts"), + "pod_phase": GetDotMetrics("k8s_pod_phase"), } ) @@ -167,7 +167,7 @@ func (p *PodsRepo) SendingRequiredMetadata(ctx context.Context) ([]model.PodOnbo // for each pod, check if we have all the required metadata for _, row := range result { status := model.PodOnboardingStatus{} - switch v := row.Data["k8s_cluster_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_cluster_name")].(type) { case string: status.HasClusterName = true status.ClusterName = v @@ -175,7 +175,7 @@ func (p *PodsRepo) SendingRequiredMetadata(ctx context.Context) ([]model.PodOnbo status.HasClusterName = *v != "" status.ClusterName = *v } - switch v := row.Data["k8s_node_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_node_name")].(type) { case string: status.HasNodeName = true status.NodeName = v @@ -183,7 +183,7 @@ func (p *PodsRepo) SendingRequiredMetadata(ctx context.Context) ([]model.PodOnbo status.HasNodeName = *v != "" status.NodeName = *v } - switch v := row.Data["k8s_namespace_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_namespace_name")].(type) { case string: status.HasNamespaceName = true status.NamespaceName = v @@ -191,38 +191,38 @@ func (p *PodsRepo) SendingRequiredMetadata(ctx context.Context) ([]model.PodOnbo status.HasNamespaceName = *v != "" status.NamespaceName = *v } - switch v := row.Data["k8s_deployment_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_deployment_name")].(type) { case string: status.HasDeploymentName = true case *string: status.HasDeploymentName = *v != "" } - switch v := row.Data["k8s_statefulset_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_statefulset_name")].(type) { case string: status.HasStatefulsetName = true case *string: status.HasStatefulsetName = *v != "" } - switch v := row.Data["k8s_daemonset_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_daemonset_name")].(type) { case string: status.HasDaemonsetName = true case *string: status.HasDaemonsetName = *v != "" } - switch v := row.Data["k8s_cronjob_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_cronjob_name")].(type) { case string: status.HasCronjobName = true case *string: status.HasCronjobName = *v != "" } - switch v := row.Data["k8s_job_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_job_name")].(type) { case string: status.HasJobName = true case *string: status.HasJobName = *v != "" } - switch v := row.Data["k8s_pod_name"].(type) { + switch v := row.Data[GetDotMetrics("k8s_pod_name")].(type) { case string: status.PodName = v case *string: diff --git a/pkg/query-service/app/inframetrics/processes.go b/pkg/query-service/app/inframetrics/processes.go index 192b290cae..a088e6ad57 100644 --- a/pkg/query-service/app/inframetrics/processes.go +++ b/pkg/query-service/app/inframetrics/processes.go @@ -21,15 +21,15 @@ var ( "memory": {"C"}, } - processPIDAttrKey = "process_pid" + processPIDAttrKey = GetDotMetrics("process_pid") metricNamesForProcesses = map[string]string{ - "cpu": "process_cpu_time", - "memory": "process_memory_usage", + "cpu": GetDotMetrics("process_cpu_time"), + "memory": GetDotMetrics("process_memory_usage"), } - metricToUseForProcessAttributes = "process_memory_usage" - processNameAttrKey = "process_executable_name" - processCMDAttrKey = "process_command" - processCMDLineAttrKey = "process_command_line" + metricToUseForProcessAttributes = GetDotMetrics("process_memory_usage") + processNameAttrKey = GetDotMetrics("process_executable_name") + processCMDAttrKey = GetDotMetrics("process_command") + processCMDLineAttrKey = GetDotMetrics("process_command_line") ) type ProcessesRepo struct { @@ -44,7 +44,7 @@ func NewProcessesRepo(reader interfaces.Reader, querierV2 interfaces.Querier) *P func (p *ProcessesRepo) GetProcessAttributeKeys(ctx context.Context, req v3.FilterAttributeKeyRequest) (*v3.FilterAttributeKeyResponse, error) { // TODO(srikanthccv): remove hardcoded metric name and support keys from any system metric req.DataSource = v3.DataSourceMetrics - req.AggregateAttribute = "process_memory_usage" + req.AggregateAttribute = GetDotMetrics("process_memory_usage") if req.Limit == 0 { req.Limit = 50 } @@ -69,7 +69,7 @@ func (p *ProcessesRepo) GetProcessAttributeKeys(ctx context.Context, req v3.Filt func (p *ProcessesRepo) GetProcessAttributeValues(ctx context.Context, req v3.FilterAttributeValueRequest) (*v3.FilterAttributeValueResponse, error) { req.DataSource = v3.DataSourceMetrics - req.AggregateAttribute = "process_memory_usage" + req.AggregateAttribute = GetDotMetrics("process_memory_usage") if req.Limit == 0 { req.Limit = 50 } @@ -85,7 +85,7 @@ func (p *ProcessesRepo) getMetadataAttributes(ctx context.Context, req model.ProcessListRequest) (map[string]map[string]string, error) { processAttrs := map[string]map[string]string{} - keysToAdd := []string{"process_pid", "process_executable_name", "process_command", "process_command_line"} + keysToAdd := []string{GetDotMetrics("process_pid"), GetDotMetrics("process_executable_name"), GetDotMetrics("process_command"), GetDotMetrics("process_command_line")} for _, key := range keysToAdd { hasKey := false for _, groupByKey := range req.GroupBy { diff --git a/pkg/query-service/app/inframetrics/pvcs.go b/pkg/query-service/app/inframetrics/pvcs.go index 4ee51c6d8d..19f047e809 100644 --- a/pkg/query-service/app/inframetrics/pvcs.go +++ b/pkg/query-service/app/inframetrics/pvcs.go @@ -16,19 +16,19 @@ import ( ) var ( - metricToUseForVolumes = "k8s_volume_available" + metricToUseForVolumes = GetDotMetrics("k8s_volume_available") volumeAttrsToEnrich = []string{ - "k8s_pod_uid", - "k8s_pod_name", - "k8s_namespace_name", - "k8s_node_name", - "k8s_statefulset_name", - "k8s_cluster_name", - "k8s_persistentvolumeclaim_name", + GetDotMetrics("k8s_pod_uid"), + GetDotMetrics("k8s_pod_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_node_name"), + GetDotMetrics("k8s_statefulset_name"), + GetDotMetrics("k8s_cluster_name"), + GetDotMetrics("k8s_persistentvolumeclaim_name"), } - k8sPersistentVolumeClaimNameAttrKey = "k8s_persistentvolumeclaim_name" + k8sPersistentVolumeClaimNameAttrKey = GetDotMetrics("k8s_persistentvolumeclaim_name") queryNamesForVolumes = map[string][]string{ "available": {"A"}, @@ -42,11 +42,11 @@ var ( volumeQueryNames = []string{"A", "B", "C", "D", "E", "F1"} metricNamesForVolumes = map[string]string{ - "available": "k8s_volume_available", - "capacity": "k8s_volume_capacity", - "inodes": "k8s_volume_inodes", - "inodes_free": "k8s_volume_inodes_free", - "inodes_used": "k8s_volume_inodes_used", + "available": GetDotMetrics("k8s_volume_available"), + "capacity": GetDotMetrics("k8s_volume_capacity"), + "inodes": GetDotMetrics("k8s_volume_inodes"), + "inodes_free": GetDotMetrics("k8s_volume_inodes_free"), + "inodes_used": GetDotMetrics("k8s_volume_inodes_used"), } ) diff --git a/pkg/query-service/app/inframetrics/statefulsets.go b/pkg/query-service/app/inframetrics/statefulsets.go index 4881cd0195..db9a68ff7d 100644 --- a/pkg/query-service/app/inframetrics/statefulsets.go +++ b/pkg/query-service/app/inframetrics/statefulsets.go @@ -16,18 +16,18 @@ import ( ) var ( - metricToUseForStatefulSets = "k8s_pod_cpu_utilization" - k8sStatefulSetNameAttrKey = "k8s_statefulset_name" + metricToUseForStatefulSets = GetDotMetrics("k8s_pod_cpu_utilization") + k8sStatefulSetNameAttrKey = GetDotMetrics("k8s_statefulset_name") metricNamesForStatefulSets = map[string]string{ - "desired_pods": "k8s_statefulset_desired_pods", - "available_pods": "k8s_statefulset_current_pods", + "desired_pods": GetDotMetrics("k8s_statefulset_desired_pods"), + "available_pods": GetDotMetrics("k8s_statefulset_current_pods"), } statefulSetAttrsToEnrich = []string{ - "k8s_statefulset_name", - "k8s_namespace_name", - "k8s_cluster_name", + GetDotMetrics("k8s_statefulset_name"), + GetDotMetrics("k8s_namespace_name"), + GetDotMetrics("k8s_cluster_name"), } queryNamesForStatefulSets = map[string][]string{ diff --git a/pkg/query-service/app/inframetrics/workload_query.go b/pkg/query-service/app/inframetrics/workload_query.go index 435b23725b..0bc2a1f883 100644 --- a/pkg/query-service/app/inframetrics/workload_query.go +++ b/pkg/query-service/app/inframetrics/workload_query.go @@ -4,13 +4,13 @@ import v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3" var ( metricNamesForWorkloads = map[string]string{ - "cpu": "k8s_pod_cpu_utilization", - "cpu_request": "k8s_pod_cpu_request_utilization", - "cpu_limit": "k8s_pod_cpu_limit_utilization", - "memory": "k8s_pod_memory_usage", - "memory_request": "k8s_pod_memory_request_utilization", - "memory_limit": "k8s_pod_memory_limit_utilization", - "restarts": "k8s_container_restarts", + "cpu": GetDotMetrics("k8s_pod_cpu_utilization"), + "cpu_request": GetDotMetrics("k8s_pod_cpu_request_utilization"), + "cpu_limit": GetDotMetrics("k8s_pod_cpu_limit_utilization"), + "memory": GetDotMetrics("k8s_pod_memory_usage"), + "memory_request": GetDotMetrics("k8s_pod_memory_request_utilization"), + "memory_limit": GetDotMetrics("k8s_pod_memory_limit_utilization"), + "restarts": GetDotMetrics("k8s_container_restarts"), } ) diff --git a/pkg/query-service/app/integrations/messagingQueues/kafka/translator.go b/pkg/query-service/app/integrations/messagingQueues/kafka/translator.go index bf5c37099c..97f529616f 100644 --- a/pkg/query-service/app/integrations/messagingQueues/kafka/translator.go +++ b/pkg/query-service/app/integrations/messagingQueues/kafka/translator.go @@ -66,6 +66,11 @@ func buildBuilderQueriesProducerBytes( attributeCache *Clients, ) (map[string]*v3.BuilderQuery, error) { + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + bq := make(map[string]*v3.BuilderQuery) queryName := "byte_rate" @@ -74,7 +79,7 @@ func buildBuilderQueriesProducerBytes( StepInterval: common.MinAllowedStepInterval(unixMilliStart, unixMilliEnd), DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: "kafka_producer_byte_rate", + Key: getDotMetrics("kafka_producer_byte_rate", normalized), DataType: v3.AttributeKeyDataTypeFloat64, Type: v3.AttributeKeyType("Gauge"), IsColumn: true, @@ -88,7 +93,7 @@ func buildBuilderQueriesProducerBytes( Items: []v3.FilterItem{ { Key: v3.AttributeKey{ - Key: "service_name", + Key: getDotMetrics("service_name", normalized), Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, }, @@ -110,7 +115,7 @@ func buildBuilderQueriesProducerBytes( ReduceTo: v3.ReduceToOperatorAvg, GroupBy: []v3.AttributeKey{ { - Key: "service_name", + Key: getDotMetrics("service_name", normalized), DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, }, @@ -133,12 +138,17 @@ func buildBuilderQueriesNetwork( bq := make(map[string]*v3.BuilderQuery) queryName := "latency" + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + chq := &v3.BuilderQuery{ QueryName: queryName, StepInterval: common.MinAllowedStepInterval(unixMilliStart, unixMilliEnd), DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: "kafka_consumer_fetch_latency_avg", + Key: getDotMetrics("kafka_consumer_fetch_latency_avg", normalized), }, AggregateOperator: v3.AggregateOperatorAvg, Temporality: v3.Unspecified, @@ -149,7 +159,7 @@ func buildBuilderQueriesNetwork( Items: []v3.FilterItem{ { Key: v3.AttributeKey{ - Key: "service_name", + Key: getDotMetrics("service_name", normalized), Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, }, @@ -158,7 +168,7 @@ func buildBuilderQueriesNetwork( }, { Key: v3.AttributeKey{ - Key: "client_id", + Key: getDotMetrics("client_id", normalized), Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, }, @@ -167,7 +177,7 @@ func buildBuilderQueriesNetwork( }, { Key: v3.AttributeKey{ - Key: "service_instance_id", + Key: getDotMetrics("service_instance_id", normalized), Type: v3.AttributeKeyTypeTag, DataType: v3.AttributeKeyDataTypeString, }, @@ -180,17 +190,17 @@ func buildBuilderQueriesNetwork( ReduceTo: v3.ReduceToOperatorAvg, GroupBy: []v3.AttributeKey{ { - Key: "service_name", + Key: getDotMetrics("service_name", normalized), DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, }, { - Key: "client_id", + Key: getDotMetrics("client_id", normalized), DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, }, { - Key: "service_instance_id", + Key: getDotMetrics("service_instance_id", normalized), DataType: v3.AttributeKeyDataTypeString, Type: v3.AttributeKeyTypeTag, }, @@ -207,12 +217,17 @@ func BuildBuilderQueriesKafkaOnboarding(messagingQueue *MessagingQueue) (*v3.Que unixMilliStart := messagingQueue.Start / 1000000 unixMilliEnd := messagingQueue.End / 1000000 + normalized := true + if constants.IsDotMetricsEnabled { + normalized = false + } + buiderQuery := &v3.BuilderQuery{ QueryName: "fetch_latency", StepInterval: common.MinAllowedStepInterval(unixMilliStart, unixMilliEnd), DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: "kafka_consumer_fetch_latency_avg", + Key: getDotMetrics("kafka_consumer_fetch_latency_avg", normalized), }, AggregateOperator: v3.AggregateOperatorCount, Temporality: v3.Unspecified, @@ -227,7 +242,7 @@ func BuildBuilderQueriesKafkaOnboarding(messagingQueue *MessagingQueue) (*v3.Que StepInterval: common.MinAllowedStepInterval(unixMilliStart, unixMilliEnd), DataSource: v3.DataSourceMetrics, AggregateAttribute: v3.AttributeKey{ - Key: "kafka_consumer_group_lag", + Key: getDotMetrics("kafka_consumer_group_lag", normalized), }, AggregateOperator: v3.AggregateOperatorCount, Temporality: v3.Unspecified, @@ -411,3 +426,19 @@ func buildCompositeQuery(chq *v3.ClickHouseQuery, queryContext string) (*v3.Comp PanelType: v3.PanelTypeTable, }, nil } + +func getDotMetrics(metricName string, normalized bool) string { + dotMetricsMap := map[string]string{ + "kafka_producer_byte_rate": "kafka.producer.byte-rate", + "service_name": "service.name", + "kafka_consumer_fetch_latency_avg": "kafka.consumer.fetch_latency_avg", + "service_instance_id": "service.instance.id", + "client_id": "client-id", + "kafka_consumer_group_lag": "kafka.consumer_group.lag", + } + if _, ok := dotMetricsMap[metricName]; ok && !normalized { + return dotMetricsMap[metricName] + } else { + return metricName + } +} diff --git a/pkg/query-service/app/metrics/v4/helpers/sub_query.go b/pkg/query-service/app/metrics/v4/helpers/sub_query.go index a5a7eaa17b..adab9bf644 100644 --- a/pkg/query-service/app/metrics/v4/helpers/sub_query.go +++ b/pkg/query-service/app/metrics/v4/helpers/sub_query.go @@ -263,7 +263,11 @@ func PrepareTimeseriesFilterQuery(start, end int64, mq *v3.BuilderQuery) (string conditions = append(conditions, fmt.Sprintf("metric_name IN %s", utils.ClickHouseFormattedMetricNames(mq.AggregateAttribute.Key))) conditions = append(conditions, fmt.Sprintf("temporality = '%s'", mq.Temporality)) - conditions = append(conditions, "__normalized = true") + if constants.IsDotMetricsEnabled { + conditions = append(conditions, "__normalized = false") + } else { + conditions = append(conditions, "__normalized = true") + } start, end, tableName := whichTSTableToUse(start, end, mq) @@ -351,7 +355,11 @@ func PrepareTimeseriesFilterQueryV3(start, end int64, mq *v3.BuilderQuery) (stri conditions = append(conditions, fmt.Sprintf("metric_name IN %s", utils.ClickHouseFormattedMetricNames(mq.AggregateAttribute.Key))) conditions = append(conditions, fmt.Sprintf("temporality = '%s'", mq.Temporality)) - conditions = append(conditions, "__normalized = true") + if constants.IsDotMetricsEnabled { + conditions = append(conditions, "__normalized = false") + } else { + conditions = append(conditions, "__normalized = true") + } start, end, tableName := whichTSTableToUse(start, end, mq) diff --git a/pkg/query-service/app/metricsexplorer/summary.go b/pkg/query-service/app/metricsexplorer/summary.go index 4027dd0500..d31548f9cd 100644 --- a/pkg/query-service/app/metricsexplorer/summary.go +++ b/pkg/query-service/app/metricsexplorer/summary.go @@ -33,11 +33,7 @@ func NewSummaryService(reader interfaces.Reader, alertManager *rules.Manager, da func (receiver *SummaryService) FilterKeys(ctx context.Context, params *metrics_explorer.FilterKeyRequest) (*metrics_explorer.FilterKeyResponse, *model.ApiError) { var response metrics_explorer.FilterKeyResponse - keys, apiError := receiver.reader.GetAllMetricFilterAttributeKeys( - ctx, - params, - true, - ) + keys, apiError := receiver.reader.GetAllMetricFilterAttributeKeys(ctx, params) if apiError != nil { return nil, apiError } @@ -56,7 +52,7 @@ func (receiver *SummaryService) FilterValues(ctx context.Context, orgID valuer.U case "metric_name": var filterValues []string request := v3.AggregateAttributeRequest{DataSource: v3.DataSourceMetrics, SearchText: params.SearchText, Limit: params.Limit} - attributes, err := receiver.reader.GetMetricAggregateAttributes(ctx, orgID, &request, true, true) + attributes, err := receiver.reader.GetMetricAggregateAttributes(ctx, orgID, &request, true) if err != nil { return nil, model.InternalError(err) } diff --git a/pkg/query-service/app/parser.go b/pkg/query-service/app/parser.go index b6ebd05f55..e0e957927a 100644 --- a/pkg/query-service/app/parser.go +++ b/pkg/query-service/app/parser.go @@ -8,6 +8,7 @@ import ( "fmt" "math" "net/http" + "sort" "strconv" "strings" "text/template" @@ -882,10 +883,23 @@ func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiE } chTransformQuery(chQuery.Query, queryRangeParams.Variables) - for name, value := range queryRangeParams.Variables { - chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("{{%s}}", name), fmt.Sprint(value), -1) - chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("[[%s]]", name), fmt.Sprint(value), -1) - chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("$%s", name), fmt.Sprint(value), -1) + + keys := make([]string, 0, len(queryRangeParams.Variables)) + + querytemplate.AssignReservedVarsV3(queryRangeParams) + + for k := range queryRangeParams.Variables { + keys = append(keys, k) + } + + sort.Slice(keys, func(i, j int) bool { + return len(keys[i]) > len(keys[j]) + }) + + for _, k := range keys { + chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("{{%s}}", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) + chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("[[%s]]", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) + chQuery.Query = strings.Replace(chQuery.Query, fmt.Sprintf("$%s", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) } tmpl := template.New("clickhouse-query") @@ -896,7 +910,6 @@ func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiE var query bytes.Buffer // replace go template variables - querytemplate.AssignReservedVarsV3(queryRangeParams) err = tmpl.Execute(&query, queryRangeParams.Variables) if err != nil { @@ -913,10 +926,22 @@ func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiE continue } - for name, value := range queryRangeParams.Variables { - promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("{{%s}}", name), fmt.Sprint(value), -1) - promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("[[%s]]", name), fmt.Sprint(value), -1) - promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("$%s", name), fmt.Sprint(value), -1) + querytemplate.AssignReservedVarsV3(queryRangeParams) + + keys := make([]string, 0, len(queryRangeParams.Variables)) + + for k := range queryRangeParams.Variables { + keys = append(keys, k) + } + + sort.Slice(keys, func(i, j int) bool { + return len(keys[i]) > len(keys[j]) + }) + + for _, k := range keys { + promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("{{%s}}", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) + promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("[[%s]]", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) + promQuery.Query = strings.Replace(promQuery.Query, fmt.Sprintf("$%s", k), fmt.Sprint(queryRangeParams.Variables[k]), -1) } tmpl := template.New("prometheus-query") @@ -926,9 +951,6 @@ func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiE } var query bytes.Buffer - // replace go template variables - querytemplate.AssignReservedVarsV3(queryRangeParams) - err = tmpl.Execute(&query, queryRangeParams.Variables) if err != nil { return nil, &model.ApiError{Typ: model.ErrorBadData, Err: err} diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.go index b01fb6423e..75d6073326 100644 --- a/pkg/query-service/constants/constants.go +++ b/pkg/query-service/constants/constants.go @@ -637,9 +637,14 @@ var DeprecatedStaticFieldsTraces = map[string]v3.AttributeKey{ var StaticFieldsTraces = map[string]v3.AttributeKey{} +var IsDotMetricsEnabled = false + func init() { StaticFieldsTraces = maps.Clone(NewStaticFieldsTraces) maps.Copy(StaticFieldsTraces, DeprecatedStaticFieldsTraces) + if GetOrDefaultEnv(DotMetricsEnabled, "false") == "true" { + IsDotMetricsEnabled = true + } } const TRACE_V4_MAX_PAGINATION_LIMIT = 10000 @@ -665,3 +670,5 @@ const InspectMetricsMaxTimeDiff = 1800000 func GetDefaultSiteURL() string { return GetOrDefaultEnv("SIGNOZ_SITE_URL", HTTPHostPort) } + +const DotMetricsEnabled = "DOT_METRICS_ENABLED" diff --git a/pkg/query-service/interfaces/interface.go b/pkg/query-service/interfaces/interface.go index ac07a0a006..f57ccc3b70 100644 --- a/pkg/query-service/interfaces/interface.go +++ b/pkg/query-service/interfaces/interface.go @@ -49,7 +49,7 @@ type Reader interface { SetTTL(ctx context.Context, orgID string, ttlParams *model.TTLParams) (*model.SetTTLResponseItem, *model.ApiError) FetchTemporality(ctx context.Context, orgID valuer.UUID, metricNames []string) (map[string]map[v3.Temporality]bool, error) - GetMetricAggregateAttributes(ctx context.Context, orgID valuer.UUID, req *v3.AggregateAttributeRequest, skipDotNames bool, skipSignozMetrics bool) (*v3.AggregateAttributeResponse, error) + GetMetricAggregateAttributes(ctx context.Context, orgID valuer.UUID, req *v3.AggregateAttributeRequest, skipSignozMetrics bool) (*v3.AggregateAttributeResponse, error) GetMetricAttributeKeys(ctx context.Context, req *v3.FilterAttributeKeyRequest) (*v3.FilterAttributeKeyResponse, error) GetMetricAttributeValues(ctx context.Context, req *v3.FilterAttributeValueRequest) (*v3.FilterAttributeValueResponse, error) @@ -117,7 +117,7 @@ type Reader interface { GetAllMetricFilterAttributeValues(ctx context.Context, req *metrics_explorer.FilterValueRequest) ([]string, *model.ApiError) GetAllMetricFilterUnits(ctx context.Context, req *metrics_explorer.FilterValueRequest) ([]string, *model.ApiError) GetAllMetricFilterTypes(ctx context.Context, req *metrics_explorer.FilterValueRequest) ([]string, *model.ApiError) - GetAllMetricFilterAttributeKeys(ctx context.Context, req *metrics_explorer.FilterKeyRequest, skipDotNames bool) (*[]v3.AttributeKey, *model.ApiError) + GetAllMetricFilterAttributeKeys(ctx context.Context, req *metrics_explorer.FilterKeyRequest) (*[]v3.AttributeKey, *model.ApiError) GetMetricsDataPoints(ctx context.Context, metricName string) (uint64, *model.ApiError) GetMetricsLastReceived(ctx context.Context, metricName string) (int64, *model.ApiError) diff --git a/pkg/query-service/metrics/transition.go b/pkg/query-service/metrics/transition.go index 97a37317c7..4affc866e8 100644 --- a/pkg/query-service/metrics/transition.go +++ b/pkg/query-service/metrics/transition.go @@ -5,3 +5,23 @@ var MetricsUnderTransition = map[string]string{ "k8s_node_cpu_utilization": "k8s_node_cpu_usage", "container_cpu_utilization": "container_cpu_usage", } + +var DotMetricsUnderTransition = map[string]string{ + "k8s.pod.cpu.utilization": "k8s.pod.cpu.usage", + "k8s.node.cpu.utilization": "k8s.node.cpu.usage", + "container.cpu.utilization": "container.cpu.usage", +} + +func GetTransitionedMetric(metric string, normalized bool) string { + if normalized { + if _, ok := MetricsUnderTransition[metric]; ok { + return MetricsUnderTransition[metric] + } + return metric + } else { + if _, ok := DotMetricsUnderTransition[metric]; ok { + return DotMetricsUnderTransition[metric] + } + return metric + } +} diff --git a/pkg/query-service/utils/format.go b/pkg/query-service/utils/format.go index 1acf9d6ff8..a6d7cdcec7 100644 --- a/pkg/query-service/utils/format.go +++ b/pkg/query-service/utils/format.go @@ -233,8 +233,9 @@ func ClickHouseFormattedValue(v interface{}) string { func ClickHouseFormattedMetricNames(v interface{}) string { if name, ok := v.(string); ok { - if newName, ok := metrics.MetricsUnderTransition[name]; ok { - return ClickHouseFormattedValue([]interface{}{name, newName}) + transitionedMetrics := metrics.GetTransitionedMetric(name, !constants.IsDotMetricsEnabled) + if transitionedMetrics != name { + return ClickHouseFormattedValue([]interface{}{name, transitionedMetrics}) } else { return ClickHouseFormattedValue([]interface{}{name}) } diff --git a/pkg/types/featuretypes/feature.go b/pkg/types/featuretypes/feature.go index 964cd4a15c..68d2e7f538 100644 --- a/pkg/types/featuretypes/feature.go +++ b/pkg/types/featuretypes/feature.go @@ -26,3 +26,4 @@ func NewStorableFeature() {} const UseSpanMetrics = "USE_SPAN_METRICS" const AnomalyDetection = "ANOMALY_DETECTION" const TraceFunnels = "TRACE_FUNNELS" +const DotMetricsEnabled = "DOT_METRICS_ENABLED"