chore: support for non-normalized metrics behind a feature flag (#7919)

feat(7294-services): added dot metrics boolean for services tab
This commit is contained in:
aniketio-ctrl 2025-05-30 15:57:29 +05:30 committed by GitHub
parent c08d1bccaf
commit 68effaf232
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
121 changed files with 17187 additions and 14622 deletions

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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<string, unknown>,
): K8sClustersData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sClustersListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>,
): K8sDaemonSetsData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sDaemonSetsListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>,
): K8sDeploymentsData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sDeploymentsListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>): K8sJobsData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sJobsListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>,
): K8sNamespacesData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sNamespacesListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>,
): K8sNodesData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sNodesListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>): K8sPodsData['meta'] {
// clone everything
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sPodsListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>;
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<string, unknown>,
): K8sVolumesData['meta'] {
// start with everything that was already there
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sVolumesListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -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<string, unknown>,
): K8sStatefulSetsData['meta'] {
const out: Record<string, unknown> = { ...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<string, string>,
dotMetricsEnabled = false,
): Promise<SuccessResponse<K8sStatefulSetsListResponse> | 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<typeof props.filters.items>(
(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<string, unknown>),
}));
return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
payload,
params: requestProps,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);

View File

@ -17,3 +17,19 @@ export const Logout = (): void => {
history.push(ROUTES.LOGIN);
};
export const UnderscoreToDotMap: Record<string, string> = {
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',
};

View File

@ -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(

View File

@ -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',
}

View File

@ -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<Exception>['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', {

View File

@ -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 (
<MemoryRouter initialEntries={initUrl ?? ['/exceptions']}>

View File

@ -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, {
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);

View File

@ -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,
],
);

View File

@ -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<AppState, GlobalReducer>(
@ -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 {
</div>
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={HostsQuickFiltersConfig}
config={GetHostsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleQuickFiltersChange}
/>

View File

@ -198,3 +198,48 @@ export const HostsQuickFiltersConfig: IQuickFiltersConfig[] = [
defaultOpen: true,
},
];
export function GetHostsQuickFiltersConfig(
dotMetricsEnabled: boolean,
): IQuickFiltersConfig[] {
// These keys dont 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,
},
];
}

View File

@ -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]);

View File

@ -136,6 +136,11 @@ export const getK8sClustersListColumns = (
return columnsConfig as ColumnType<K8sClustersRowData>[];
};
const dotToUnder: Record<string, keyof K8sClustersData['meta']> = {
'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 (

View File

@ -30,7 +30,51 @@ export const getDaemonSetMetricsQueryPayload = (
daemonSet: K8sDaemonSetsData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -43,7 +87,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -59,7 +103,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_daemonset_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonSetNameKey,
type: 'tag',
},
op: '=',
@ -72,7 +116,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -99,7 +143,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_container_cpu_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -115,7 +159,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -128,7 +172,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -155,7 +199,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_container_cpu_limit--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_limit',
key: k8sContainerCpuLimitKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -171,7 +215,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -184,7 +228,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -244,7 +288,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -260,7 +304,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_daemonset_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonSetNameKey,
type: 'tag',
},
op: '=',
@ -273,7 +317,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -300,7 +344,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_container_memory_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemoryRequestKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -316,7 +360,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -329,7 +373,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -356,7 +400,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_container_memory_limit--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_limit',
key: k8sContainerMemoryLimitKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -372,7 +416,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -385,7 +429,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -445,7 +489,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_network_io--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_io',
key: k8sPodNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -461,7 +505,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_daemonset_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonSetNameKey,
type: 'tag',
},
op: '=',
@ -474,7 +518,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -551,7 +595,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_pod_network_errors--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_errors',
key: k8sPodNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -567,7 +611,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_daemonset_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonSetNameKey,
type: 'tag',
},
op: '=',
@ -580,7 +624,7 @@ export const getDaemonSetMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -646,3 +690,4 @@ export const getDaemonSetMetricsQueryPayload = (
end,
},
];
};

View File

@ -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 || [], [

View File

@ -236,6 +236,12 @@ export const getK8sDaemonSetsListColumns = (
return columnsConfig as ColumnType<K8sDaemonSetsRowData>[];
};
const dotToUnder: Record<string, keyof K8sDaemonSetsData['meta']> = {
'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 (

View File

@ -30,7 +30,47 @@ export const getDeploymentMetricsQueryPayload = (
deployment: K8sDeploymentsData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -43,7 +83,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -59,7 +99,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_deployment_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
op: '=',
@ -86,7 +126,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_container_cpu_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -102,7 +142,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -129,7 +169,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_container_cpu_limit--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_limit',
key: k8sContainerCpuLimitKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -145,7 +185,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -205,7 +245,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -221,7 +261,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_deployment_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
op: '=',
@ -248,7 +288,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_container_memory_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemoryRequestKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -264,7 +304,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -291,7 +331,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_container_memory_limit--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_limit',
key: k8sContainerMemoryLimitKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -307,7 +347,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
@ -367,7 +407,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_network_io--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_io',
key: k8sPodNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -383,7 +423,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_deployment_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
op: '=',
@ -460,7 +500,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_pod_network_errors--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_errors',
key: k8sPodNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -476,7 +516,7 @@ export const getDeploymentMetricsQueryPayload = (
id: 'k8s_deployment_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
op: '=',
@ -542,3 +582,4 @@ export const getDeploymentMetricsQueryPayload = (
end,
},
];
};

View File

@ -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 || [], [

View File

@ -226,6 +226,12 @@ export const getK8sDeploymentsListColumns = (
return columnsConfig as ColumnType<K8sDeploymentsRowData>[];
};
const dotToUnder: Record<string, keyof K8sDeploymentsData['meta']> = {
'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 (

View File

@ -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<T> {
timeRange: {
startTime: number;
@ -49,6 +52,7 @@ interface EntityMetricsProps<T> {
node: T,
start: number,
end: number,
dotMetricsEnabled: boolean,
) => GetQueryResultsProps[];
queryKey: string;
category: K8sCategory;
@ -65,9 +69,25 @@ function EntityMetrics<T>({
queryKey,
category,
}: EntityMetricsProps<T>): 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(

View File

@ -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: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={PodsQuickFiltersConfig}
config={GetPodsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -129,7 +136,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={NodesQuickFiltersConfig}
config={GetNodesQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -152,7 +159,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={NamespaceQuickFiltersConfig}
config={GetNamespaceQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -172,7 +179,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={ClustersQuickFiltersConfig}
config={GetClustersQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -192,7 +199,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={DeploymentsQuickFiltersConfig}
config={GetDeploymentsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -212,7 +219,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={JobsQuickFiltersConfig}
config={GetJobsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -232,7 +239,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={DaemonSetsQuickFiltersConfig}
config={GetDaemonsetsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -255,7 +262,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={StatefulsetsQuickFiltersConfig}
config={GetStatefulsetsQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>
@ -275,7 +282,7 @@ export default function InfraMonitoringK8s(): JSX.Element {
children: (
<QuickFilters
source={QuickFiltersSource.INFRA_MONITORING}
config={VolumesQuickFiltersConfig}
config={GetVolumesQuickFiltersConfig(dotMetricsEnabled)}
handleFilterVisibilityChange={handleFilterVisibilityChange}
onFilterChange={handleFilterChange}
/>

View File

@ -30,7 +30,26 @@ export const getJobMetricsQueryPayload = (
job: K8sJobsData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -43,7 +62,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -59,7 +78,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_job_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_job_name',
key: k8sJobNameKey,
type: 'tag',
},
op: '=',
@ -72,7 +91,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -132,7 +151,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_pod_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -148,7 +167,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_job_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_job_name',
key: k8sJobNameKey,
type: 'tag',
},
op: '=',
@ -161,7 +180,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -221,7 +240,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_pod_network_io--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_io',
key: k8sPodNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -237,7 +256,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_job_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_job_name',
key: k8sJobNameKey,
type: 'tag',
},
op: '=',
@ -250,7 +269,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -327,7 +346,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_pod_network_errors--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_errors',
key: k8sPodNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -343,7 +362,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_job_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_job_name',
key: k8sJobNameKey,
type: 'tag',
},
op: '=',
@ -356,7 +375,7 @@ export const getJobMetricsQueryPayload = (
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -422,3 +441,4 @@ export const getJobMetricsQueryPayload = (
end,
},
];
};

View File

@ -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, {
} = 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]);

View File

@ -263,6 +263,12 @@ export const getK8sJobsListColumns = (
return columnsConfig as ColumnType<K8sJobsRowData>[];
};
const dotToUnder: Record<string, keyof K8sJobsData['meta']> = {
'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 (

View File

@ -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 || [], [

View File

@ -54,7 +54,97 @@ export const getNamespaceMetricsQueryPayload = (
namespace: K8sNamespacesData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -64,10 +154,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
id: k8sPodCpuUtilizationKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -80,10 +170,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '47b3adae',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -107,10 +197,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_cpu_request--float64--Gauge--true',
id: k8sContainerCpuRequestKey,
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -123,10 +213,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '93d2be5e',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -150,10 +240,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
id: k8sPodCpuUtilizationKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'min',
@ -166,10 +256,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '795eb679',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -193,10 +283,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
id: k8sPodCpuUtilizationKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'max',
@ -209,10 +299,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '6792adbe',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -269,10 +359,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_usage--float64--Gauge--true',
id: k8sPodMemoryUsageKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -285,10 +375,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '10011298',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -312,10 +402,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_memory_request--float64--Gauge--true',
id: k8sContainerMemoryRequestKey,
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemoryRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -328,10 +418,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'ea53b656',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -355,10 +445,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_working_set--float64--Gauge--true',
id: k8sPodMemoryWorkingSetKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_working_set',
key: k8sPodMemoryWorkingSetKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -371,10 +461,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '674ace83',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -398,10 +488,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_rss--float64--Gauge--true',
id: k8sPodMemoryRssKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_rss',
key: k8sPodMemoryRssKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -414,10 +504,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '187dbdb3',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -441,10 +531,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_usage--float64--Gauge--true',
id: k8sPodMemoryUsageKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'min',
@ -457,10 +547,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'a3dbf468',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -484,10 +574,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_usage--float64--Gauge--true',
id: k8sPodMemoryUsageKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'max',
@ -500,10 +590,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '4b2406c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -560,10 +650,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
id: k8sPodCpuUtilizationKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -576,10 +666,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'c3a73f0a',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -592,15 +682,15 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: k8sPodNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
],
having: [],
legend: '{{k8s_pod_name}}',
legend: `{{${k8sPodNameKey}}}`,
limit: 20,
orderBy: [],
queryName: 'A',
@ -645,10 +735,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_usage--float64--Gauge--true',
id: k8sPodMemoryUsageKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -661,10 +751,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '5cad3379',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -677,15 +767,15 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: k8sPodNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
],
having: [],
legend: '{{k8s_pod_name}}',
legend: `{{${k8sPodNameKey}}}`,
limit: 10,
orderBy: [],
queryName: 'A',
@ -730,10 +820,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_network_io--float64--Sum--true',
id: k8sPodNetworkIoKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_io',
key: k8sPodNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -746,10 +836,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '00f5c5e1',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -762,7 +852,7 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'interface--string--tag--false',
id: 'interface',
isColumn: false,
isJSON: false,
key: 'interface',
@ -770,7 +860,7 @@ export const getNamespaceMetricsQueryPayload = (
},
{
dataType: DataTypes.String,
id: 'direction--string--tag--false',
id: 'direction',
isColumn: false,
isJSON: false,
key: 'direction',
@ -823,10 +913,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.String,
id: 'k8s_pod_network_errors--float64--Sum--true',
id: k8sPodNetworkErrorsKey,
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_errors',
key: k8sPodNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -839,10 +929,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '3aa8e064',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -855,7 +945,7 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'interface--string--tag--false',
id: 'interface',
isColumn: false,
isJSON: false,
key: 'interface',
@ -863,7 +953,7 @@ export const getNamespaceMetricsQueryPayload = (
},
{
dataType: DataTypes.String,
id: 'direction--string--tag--false',
id: 'direction',
isColumn: false,
isJSON: false,
key: 'direction',
@ -916,10 +1006,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_statefulset_current_pods--float64--Gauge--true',
id: k8sStatefulsetCurrentPodsKey,
isColumn: true,
isJSON: false,
key: 'k8s_statefulset_current_pods',
key: k8sStatefulsetCurrentPodsKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -932,10 +1022,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '5f2a55c5',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sStatefulsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sStatefulsetNameKey,
type: 'tag',
},
op: '=',
@ -948,10 +1038,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: k8sStatefulsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulsetNameKey,
type: 'tag',
},
],
@ -968,10 +1058,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_statefulset_desired_pods--float64--Gauge--true',
id: k8sStatefulsetDesiredPodsKey,
isColumn: true,
isJSON: false,
key: 'k8s_statefulset_desired_pods',
key: k8sStatefulsetDesiredPodsKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -984,10 +1074,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '13bd7a1d',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1000,10 +1090,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: k8sStatefulsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulsetNameKey,
type: 'tag',
},
],
@ -1020,10 +1110,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_statefulset_updated_pods--float64--Gauge--true',
id: k8sStatefulsetUpdatedPodsKey,
isColumn: true,
isJSON: false,
key: 'k8s_statefulset_updated_pods',
key: k8sStatefulsetUpdatedPodsKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1036,10 +1126,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '9d287c73',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1052,10 +1142,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: k8sStatefulsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulsetNameKey,
type: 'tag',
},
],
@ -1105,10 +1195,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_replicaset_desired--float64--Gauge--true',
id: k8sReplicasetDesiredKey,
isColumn: true,
isJSON: false,
key: 'k8s_replicaset_desired',
key: k8sReplicasetDesiredKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1121,10 +1211,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '0c1e655c',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1137,16 +1227,16 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_replicaset_name--string--tag--false',
id: k8sReplicasetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_replicaset_name',
key: k8sReplicasetNameKey,
type: 'tag',
},
],
having: [
{
columnName: 'MAX(k8s_replicaset_desired)',
columnName: `MAX(${k8sReplicasetDesiredKey})`,
op: '>',
value: 0,
},
@ -1163,10 +1253,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_replicaset_available--float64--Gauge--true',
id: k8sReplicasetAvailableKey,
isColumn: true,
isJSON: false,
key: 'k8s_replicaset_available',
key: k8sReplicasetAvailableKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1179,10 +1269,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'b2296bdb',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1195,16 +1285,16 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_replicaset_name--string--tag--false',
id: k8sReplicasetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_replicaset_name',
key: k8sReplicasetNameKey,
type: 'tag',
},
],
having: [
{
columnName: 'MAX(k8s_replicaset_available)',
columnName: `MAX(${k8sReplicasetDesiredKey})`,
op: '>',
value: 0,
},
@ -1254,10 +1344,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_daemonset_desired_scheduled_namespaces--float64--Gauge--true',
id: k8sDaemonsetDesiredScheduledNamespacesKey,
isColumn: true,
isJSON: false,
key: 'k8s_daemonset_desired_scheduled_namespaces',
key: k8sDaemonsetDesiredScheduledNamespacesKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1270,10 +1360,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '2964eb92',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1286,10 +1376,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_daemonset_name--string--tag--false',
id: k8sDaemonsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonsetNameKey,
type: 'tag',
},
],
@ -1306,10 +1396,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_daemonset_current_scheduled_namespaces--float64--Gauge--true',
id: k8sDaemonsetCurrentScheduledNamespacesKey,
isColumn: true,
isJSON: false,
key: 'k8s_daemonset_current_scheduled_namespaces',
key: k8sDaemonsetCurrentScheduledNamespacesKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1322,10 +1412,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'cd324eff',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1338,10 +1428,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_daemonset_name--string--tag--false',
id: k8sDaemonsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonsetNameKey,
type: 'tag',
},
],
@ -1358,10 +1448,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_daemonset_ready_namespaces--float64--Gauge--true',
id: k8sDaemonsetReadyNamespacesKey,
isColumn: true,
isJSON: false,
key: 'k8s_daemonset_ready_namespaces',
key: k8sDaemonsetReadyNamespacesKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1374,10 +1464,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '0416fa6f',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1390,10 +1480,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_daemonset_name--string--tag--false',
id: k8sDaemonsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonsetNameKey,
type: 'tag',
},
],
@ -1410,10 +1500,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_daemonset_misscheduled_namespaces--float64--Gauge--true',
id: k8sDaemonsetMisscheduledNamespacesKey,
isColumn: true,
isJSON: false,
key: 'k8s_daemonset_misscheduled_namespaces',
key: k8sDaemonsetMisscheduledNamespacesKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1426,10 +1516,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'c0a126d3',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1442,10 +1532,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_daemonset_name--string--tag--false',
id: k8sDaemonsetNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_daemonset_name',
key: k8sDaemonsetNameKey,
type: 'tag',
},
],
@ -1495,10 +1585,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_deployment_desired--float64--Gauge--true',
id: k8sDeploymentDesiredKey,
isColumn: true,
isJSON: false,
key: 'k8s_deployment_desired',
key: k8sDeploymentDesiredKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -1511,10 +1601,10 @@ export const getNamespaceMetricsQueryPayload = (
id: '9bc659c1',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1527,10 +1617,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_deployment_name--string--tag--false',
id: k8sDeploymentNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
],
@ -1547,10 +1637,10 @@ export const getNamespaceMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_deployment_available--float64--Gauge--true',
id: k8sDeploymentAvailableKey,
isColumn: true,
isJSON: false,
key: 'k8s_deployment_available',
key: k8sDeploymentAvailableKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1563,10 +1653,10 @@ export const getNamespaceMetricsQueryPayload = (
id: 'e1696631',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: k8sNamespaceNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -1579,10 +1669,10 @@ export const getNamespaceMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'k8s_deployment_name--string--tag--false',
id: k8sDeploymentNameKey,
isColumn: false,
isJSON: false,
key: 'k8s_deployment_name',
key: k8sDeploymentNameKey,
type: 'tag',
},
],
@ -1631,3 +1721,4 @@ export const getNamespaceMetricsQueryPayload = (
end,
},
];
};

View File

@ -122,6 +122,11 @@ export const getK8sNamespacesListColumns = (
return columnsConfig as ColumnType<K8sNamespacesRowData>[];
};
const dotToUnder: Record<string, keyof K8sNamespacesData['meta']> = {
'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 (

View File

@ -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, {
} = 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]);

View File

@ -54,7 +54,90 @@ export const getNodeMetricsQueryPayload = (
node: K8sNodesData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -67,7 +150,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_cpu_utilization',
key: k8sNodeCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -83,7 +166,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -110,7 +193,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_allocatable_cpu--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_allocatable_cpu',
key: k8sNodeAllocatableCpuKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -126,7 +209,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -153,7 +236,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_container_cpu_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -169,7 +252,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -196,7 +279,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_cpu_utilization',
key: k8sNodeCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'max',
@ -212,7 +295,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -239,7 +322,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_cpu_utilization',
key: k8sNodeCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'min',
@ -255,7 +338,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -315,7 +398,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_usage',
key: k8sNodeMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -331,7 +414,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -358,7 +441,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_allocatable_memory--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_allocatable_memory',
key: k8sNodeAllocatableMemoryKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -374,7 +457,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -401,7 +484,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_container_memory_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemoryRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -417,7 +500,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -444,7 +527,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_usage',
key: k8sNodeMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'max',
@ -460,7 +543,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -487,7 +570,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_usage',
key: k8sNodeMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'min',
@ -503,7 +586,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -530,7 +613,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_working_set--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_working_set',
key: k8sNodeMemoryWorkingSetKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -546,7 +629,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -573,7 +656,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_rss--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_rss',
key: k8sNodeMemoryRssKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -589,7 +672,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -649,7 +732,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_cpu_utilization',
key: k8sNodeCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -665,7 +748,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -692,7 +775,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_allocatable_cpu--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_allocatable_cpu',
key: k8sNodeAllocatableCpuKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -708,7 +791,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -735,7 +818,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_container_cpu_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -751,7 +834,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -824,7 +907,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_memory_usage',
key: k8sNodeMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -840,7 +923,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -867,7 +950,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_allocatable_memory--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_allocatable_memory',
key: k8sNodeAllocatableMemoryKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -883,7 +966,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -910,7 +993,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_container_memory_request--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemoryRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -926,7 +1009,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -999,7 +1082,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilizationKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1015,7 +1098,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1031,12 +1114,12 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
],
having: [],
legend: '{{k8s_pod_name}}',
legend: `{{${k8sPodNameKey}}}`,
limit: 10,
orderBy: [],
queryName: 'A',
@ -1084,7 +1167,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_pod_memory_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemoryUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1100,7 +1183,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1116,12 +1199,12 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_pod_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
],
having: [],
legend: '{{k8s_pod_name}}',
legend: `{{${k8sPodNameKey}}}`,
limit: 10,
orderBy: [],
queryName: 'A',
@ -1169,7 +1252,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_network_errors--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_network_errors',
key: k8sNodeNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -1185,7 +1268,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1262,7 +1345,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_network_io--float64--Sum--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_network_io',
key: k8sNodeNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -1278,7 +1361,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1355,7 +1438,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_filesystem_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_filesystem_usage',
key: k8sNodeFilesystemUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1371,7 +1454,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1398,7 +1481,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_filesystem_capacity--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_filesystem_capacity',
key: k8sNodeFilesystemCapacityKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1414,7 +1497,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1441,7 +1524,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_filesystem_available--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_filesystem_available',
key: k8sNodeFilesystemAvailableKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1457,7 +1540,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1517,7 +1600,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_filesystem_usage--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_filesystem_usage',
key: k8sNodeFilesystemUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1533,7 +1616,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1560,7 +1643,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_filesystem_capacity--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_node_filesystem_capacity',
key: k8sNodeFilesystemCapacityKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -1576,7 +1659,7 @@ export const getNodeMetricsQueryPayload = (
id: 'k8s_node_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'k8s_node_name',
key: k8sNodeNameKey,
type: 'tag',
},
op: '=',
@ -1632,3 +1715,4 @@ export const getNodeMetricsQueryPayload = (
end,
},
];
};

View File

@ -152,6 +152,12 @@ export const getK8sNodesListColumns = (
return columnsConfig as ColumnType<K8sNodesRowData>[];
};
const dotToUnder: Record<string, keyof K8sNodesData['meta']> = {
'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 (

View File

@ -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, {
} = 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;

File diff suppressed because it is too large Load Diff

View File

@ -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 || [], [

View File

@ -38,7 +38,56 @@ export const getStatefulSetMetricsQueryPayload = (
statefulSet: K8sStatefulSetsData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -48,10 +97,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
id: 'cpu_usage',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_utilization',
key: k8sPodCpuUtilKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -61,26 +110,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '8627bd22',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -104,10 +153,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_cpu_request--float64--Gauge--true',
id: 'cpu_request',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_request',
key: k8sContainerCpuRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -117,26 +166,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '82f07131',
id: 'f3',
key: {
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: 'pod_name',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -160,10 +209,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_cpu_limit--float64--Gauge--true',
id: 'cpu_limit',
isColumn: true,
isJSON: false,
key: 'k8s_container_cpu_limit',
key: k8sContainerCpuLimitKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -173,26 +222,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '9c669f4f',
id: 'f4',
key: {
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: 'pod_name',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -216,23 +265,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -249,10 +284,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true',
id: 'cpu_req_util',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_request_utilization',
key: k8sPodCpuReqUtilKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -262,26 +297,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '3c835082',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -305,10 +340,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true',
id: 'cpu_limit_util',
isColumn: true,
isJSON: false,
key: 'k8s_pod_cpu_limit_utilization',
key: k8sPodCpuLimitUtilKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -318,26 +353,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: 'c0a5e5b1',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -361,23 +396,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -394,10 +415,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_usage--float64--Gauge--true',
id: 'mem_usage',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_usage',
key: k8sPodMemUsageKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -407,26 +428,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: 'f8ae7d0f',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -450,10 +471,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_memory_request--float64--Gauge--true',
id: 'mem_request',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_request',
key: k8sContainerMemRequestKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -463,26 +484,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '66fbdd5e',
id: 'f3',
key: {
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: 'pod_name',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -506,10 +527,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_container_memory_limit--float64--Gauge--true',
id: 'mem_limit',
isColumn: true,
isJSON: false,
key: 'k8s_container_memory_limit',
key: k8sContainerMemLimitKey,
type: 'Gauge',
},
aggregateOperator: 'latest',
@ -519,26 +540,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '1a408383',
id: 'f4',
key: {
dataType: DataTypes.String,
id: 'k8s_pod_name--string--tag--false',
id: 'pod_name',
isColumn: false,
isJSON: false,
key: 'k8s_pod_name',
key: k8sPodNameKey,
type: 'tag',
},
op: 'contains',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -562,23 +583,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -595,10 +602,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_request_utilization--float64--Gauge--true',
id: 'mem_req_util',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_request_utilization',
key: k8sPodMemReqUtilKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -608,26 +615,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: 'acdccfa2',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -651,10 +658,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true',
id: 'mem_limit_util',
isColumn: true,
isJSON: false,
key: 'k8s_pod_memory_limit_utilization',
key: k8sPodMemLimitUtilKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -664,26 +671,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: 'cc9a85d3',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -707,23 +714,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -740,10 +733,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_network_io--float64--Sum--true',
id: 'net_io',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_io',
key: k8sPodNetworkIoKey,
type: 'Sum',
},
aggregateOperator: 'rate',
@ -753,26 +746,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '2ea33f83',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -785,7 +778,7 @@ export const getStatefulSetMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'direction--string--tag--false',
id: 'direction',
isColumn: false,
isJSON: false,
key: 'direction',
@ -793,7 +786,7 @@ export const getStatefulSetMetricsQueryPayload = (
},
{
dataType: DataTypes.String,
id: 'interface--string--tag--false',
id: 'interface',
isColumn: false,
isJSON: false,
key: 'interface',
@ -813,23 +806,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -846,10 +825,10 @@ export const getStatefulSetMetricsQueryPayload = (
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'k8s_pod_network_errors--float64--Sum--true',
id: 'net_err',
isColumn: true,
isJSON: false,
key: 'k8s_pod_network_errors',
key: k8sPodNetworkErrorsKey,
type: 'Sum',
},
aggregateOperator: 'increase',
@ -859,26 +838,26 @@ export const getStatefulSetMetricsQueryPayload = (
filters: {
items: [
{
id: '7e25d4fb',
id: 'f1',
key: {
dataType: DataTypes.String,
id: 'k8s_statefulset_name--string--tag--false',
id: 'ss_name',
isColumn: false,
isJSON: false,
key: 'k8s_statefulset_name',
key: k8sStatefulSetNameKey,
type: 'tag',
},
op: '=',
value: statefulSet.meta.k8s_statefulset_name,
},
{
id: '47b3adae',
id: 'f2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
id: 'ns_name',
isColumn: false,
isJSON: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: '=',
@ -891,7 +870,7 @@ export const getStatefulSetMetricsQueryPayload = (
groupBy: [
{
dataType: DataTypes.String,
id: 'direction--string--tag--false',
id: 'direction',
isColumn: false,
isJSON: false,
key: 'direction',
@ -899,7 +878,7 @@ export const getStatefulSetMetricsQueryPayload = (
},
{
dataType: DataTypes.String,
id: 'interface--string--tag--false',
id: 'interface',
isColumn: false,
isJSON: false,
key: 'interface',
@ -919,23 +898,9 @@ export const getStatefulSetMetricsQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -944,3 +909,4 @@ export const getStatefulSetMetricsQueryPayload = (
end,
},
];
};

View File

@ -236,6 +236,11 @@ export const getK8sStatefulSetsListColumns = (
return columnsConfig as ColumnType<K8sStatefulSetsRowData>[];
};
const dotToUnder: Record<string, keyof K8sStatefulSetsData['meta']> = {
'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 (

View File

@ -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, {
} = 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]);

View File

@ -34,7 +34,40 @@ export const getVolumeQueryPayload = (
volume: K8sVolumesData,
start: number,
end: number,
): GetQueryResultsProps[] => [
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,
@ -47,7 +80,7 @@ export const getVolumeQueryPayload = (
id: 'k8s_volume_available--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_volume_available',
key: k8sVolumeAvailableKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -57,50 +90,49 @@ export const getVolumeQueryPayload = (
filters: {
items: [
{
id: '6077fbc2',
id: 'c1',
key: {
dataType: DataTypes.String,
id: 'k8s_cluster_name--string--tag--false',
isColumn: false,
key: 'k8s_cluster_name',
key: k8sClusterNameKey,
type: 'tag',
},
op: '=',
value: volume.meta.k8s_cluster_name,
},
{
id: '6077fbc2',
id: 'c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: 'in',
value: [volume.meta.k8s_namespace_name],
},
{
id: '217757e9',
id: 'c3',
key: {
dataType: DataTypes.String,
id: 'k8s_volume_type--string--tag--false',
isColumn: false,
key: 'k8s_volume_type',
key: k8sVolumeTypeKey,
type: 'tag',
},
op: 'in',
value: ['persistentVolumeClaim'],
},
{
id: '34754bda',
id: 'c4',
key: {
key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_persistentvolumeclaim_name--string--tag--false',
isColumn: false,
key: k8sPVCNameKey,
type: 'tag',
},
op: '=',
value: volume.persistentVolumeClaimName,
@ -111,7 +143,7 @@ export const getVolumeQueryPayload = (
functions: [],
groupBy: [],
having: [],
legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
legend: legendTemplate,
limit: null,
orderBy: [],
queryName: 'A',
@ -123,23 +155,9 @@ export const getVolumeQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -159,7 +177,7 @@ export const getVolumeQueryPayload = (
id: 'k8s_volume_capacity--float64--Gauge--true',
isColumn: true,
isJSON: false,
key: 'k8s_volume_capacity',
key: k8sVolumeCapacityKey,
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -169,50 +187,49 @@ export const getVolumeQueryPayload = (
filters: {
items: [
{
id: '6077fbc2',
id: 'c1',
key: {
dataType: DataTypes.String,
id: 'k8s_cluster_name--string--tag--false',
isColumn: false,
key: 'k8s_cluster_name',
key: k8sClusterNameKey,
type: 'tag',
},
op: '=',
value: volume.meta.k8s_cluster_name,
},
{
id: '0cdebb88',
id: 'c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: 'in',
value: [volume.meta.k8s_namespace_name],
},
{
id: 'e0e880ce',
id: 'c3',
key: {
dataType: DataTypes.String,
id: 'k8s_volume_type--string--tag--false',
isColumn: false,
key: 'k8s_volume_type',
key: k8sVolumeTypeKey,
type: 'tag',
},
op: 'in',
value: ['persistentVolumeClaim'],
},
{
id: '34754bda',
id: 'c4',
key: {
key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_persistentvolumeclaim_name--string--tag--false',
isColumn: false,
key: k8sPVCNameKey,
type: 'tag',
},
op: '=',
value: volume.persistentVolumeClaimName,
@ -223,7 +240,7 @@ export const getVolumeQueryPayload = (
functions: [],
groupBy: [],
having: [],
legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
legend: legendTemplate,
limit: null,
orderBy: [],
queryName: 'A',
@ -235,23 +252,9 @@ export const getVolumeQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -270,7 +273,7 @@ export const getVolumeQueryPayload = (
dataType: DataTypes.Float64,
id: 'k8s_volume_inodes_used--float64----true',
isColumn: true,
key: 'k8s_volume_inodes_used',
key: k8sVolumeInodesUsedKey,
type: '',
},
aggregateOperator: 'avg',
@ -280,50 +283,49 @@ export const getVolumeQueryPayload = (
filters: {
items: [
{
id: '6077fbc2',
id: 'c1',
key: {
dataType: DataTypes.String,
id: 'k8s_cluster_name--string--tag--false',
isColumn: false,
key: 'k8s_cluster_name',
key: k8sClusterNameKey,
type: 'tag',
},
op: '=',
value: volume.meta.k8s_cluster_name,
},
{
id: '46393c61',
id: 'c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: 'in',
value: [volume.meta.k8s_namespace_name],
},
{
id: '450ee3cb',
id: 'c3',
key: {
dataType: DataTypes.String,
id: 'k8s_volume_type--string--tag--false',
isColumn: false,
key: 'k8s_volume_type',
key: k8sVolumeTypeKey,
type: 'tag',
},
op: 'in',
value: ['persistentVolumeClaim'],
},
{
id: '34754bda',
id: 'c4',
key: {
key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_persistentvolumeclaim_name--string--tag--false',
isColumn: false,
key: k8sPVCNameKey,
type: 'tag',
},
op: '=',
value: volume.persistentVolumeClaimName,
@ -333,7 +335,7 @@ export const getVolumeQueryPayload = (
},
groupBy: [],
having: [],
legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
legend: legendTemplate,
limit: null,
orderBy: [],
queryName: 'A',
@ -346,23 +348,9 @@ export const getVolumeQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -381,7 +369,7 @@ export const getVolumeQueryPayload = (
dataType: DataTypes.Float64,
id: 'k8s_volume_inodes--float64----true',
isColumn: true,
key: 'k8s_volume_inodes',
key: k8sVolumeInodesKey,
type: '',
},
aggregateOperator: 'avg',
@ -391,50 +379,49 @@ export const getVolumeQueryPayload = (
filters: {
items: [
{
id: '6077fbc2',
id: 'c1',
key: {
dataType: DataTypes.String,
id: 'k8s_cluster_name--string--tag--false',
isColumn: false,
key: 'k8s_cluster_name',
key: k8sClusterNameKey,
type: 'tag',
},
op: '=',
value: volume.meta.k8s_cluster_name,
},
{
id: '5a604bad',
id: 'c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: 'in',
value: [volume.meta.k8s_namespace_name],
},
{
id: '24b074f3',
id: 'c3',
key: {
dataType: DataTypes.String,
id: 'k8s_volume_type--string--tag--false',
isColumn: false,
key: 'k8s_volume_type',
key: k8sVolumeTypeKey,
type: 'tag',
},
op: 'in',
value: ['persistentVolumeClaim'],
},
{
id: '34754bda',
id: 'c4',
key: {
key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_persistentvolumeclaim_name--string--tag--false',
isColumn: false,
key: k8sPVCNameKey,
type: 'tag',
},
op: '=',
value: volume.persistentVolumeClaimName,
@ -444,7 +431,7 @@ export const getVolumeQueryPayload = (
},
groupBy: [],
having: [],
legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
legend: legendTemplate,
limit: null,
orderBy: [],
queryName: 'A',
@ -457,23 +444,9 @@ export const getVolumeQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -492,7 +465,7 @@ export const getVolumeQueryPayload = (
dataType: DataTypes.Float64,
id: 'k8s_volume_inodes_free--float64----true',
isColumn: true,
key: 'k8s_volume_inodes_free',
key: k8sVolumeInodesFreeKey,
type: '',
},
aggregateOperator: 'avg',
@ -502,50 +475,49 @@ export const getVolumeQueryPayload = (
filters: {
items: [
{
id: '6077fbc2',
id: 'c1',
key: {
dataType: DataTypes.String,
id: 'k8s_cluster_name--string--tag--false',
isColumn: false,
key: 'k8s_cluster_name',
key: k8sClusterNameKey,
type: 'tag',
},
op: '=',
value: volume.meta.k8s_cluster_name,
},
{
id: '8f01b14d',
id: 'c2',
key: {
dataType: DataTypes.String,
id: 'k8s_namespace_name--string--tag--false',
isColumn: false,
key: 'k8s_namespace_name',
key: k8sNamespaceNameKey,
type: 'tag',
},
op: 'in',
value: [volume.meta.k8s_namespace_name],
},
{
id: 'a72c99da',
id: 'c3',
key: {
dataType: DataTypes.String,
id: 'k8s_volume_type--string--tag--false',
isColumn: false,
key: 'k8s_volume_type',
key: k8sVolumeTypeKey,
type: 'tag',
},
op: 'in',
value: ['persistentVolumeClaim'],
},
{
id: '34754bda',
id: 'c4',
key: {
key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_persistentvolumeclaim_name--string--tag--false',
isColumn: false,
key: k8sPVCNameKey,
type: 'tag',
},
op: '=',
value: volume.persistentVolumeClaimName,
@ -555,7 +527,7 @@ export const getVolumeQueryPayload = (
},
groupBy: [],
having: [],
legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
legend: legendTemplate,
limit: null,
orderBy: [],
queryName: 'A',
@ -568,23 +540,9 @@ export const getVolumeQueryPayload = (
],
queryFormulas: [],
},
clickhouse_sql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
clickhouse_sql: [{ disabled: false, legend: '', name: 'A', query: '' }],
id: v4(),
promql: [
{
disabled: false,
legend: '',
name: 'A',
query: '',
},
],
promql: [{ disabled: false, legend: '', name: 'A', query: '' }],
queryType: EQueryType.QUERY_BUILDER,
},
variables: {},
@ -593,3 +551,4 @@ export const getVolumeQueryPayload = (
end,
},
];
};

View File

@ -142,6 +142,16 @@ export const getK8sVolumesListColumns = (
return columnsConfig as ColumnType<K8sVolumesRowData>[];
};
const dotToUnder: Record<string, keyof K8sVolumesData['meta']> = {
'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 (

View File

@ -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,20 +50,66 @@ export const K8sEntityToAggregateAttributeMapping = {
[K8sCategory.VOLUMES]: 'k8s_volume_capacity',
};
export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
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 function GetK8sEntityToAggregateAttribute(
category: K8sCategory,
dotMetricsEnabled: boolean,
): string {
return dotMetricsEnabled ? dotMap[category] : underscoreMap[category];
}
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';
// Define aggregate attribute (metric) name
const cpuUtilizationMetric = dotMetricsEnabled
? 'k8s.pod.cpu.utilization'
: 'k8s_pod_cpu_utilization';
return [
{
type: FiltersType.CHECKBOX,
title: 'Pod',
attributeKey: {
key: 'k8s_pod_name',
key: podKey,
dataType: DataTypes.String,
type: 'tag',
isColumn: false,
isJSON: false,
id: 'k8s_pod_name--string--tag--true',
id: `${podKey}--string--tag--true`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -71,14 +117,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${namespaceKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -86,15 +133,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Node',
attributeKey: {
key: 'k8s_node_name',
key: nodeKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: 'k8s.node.name--string--resource--true',
id: `${nodeKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -102,14 +149,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -117,14 +165,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Deployment',
attributeKey: {
key: 'k8s_deployment_name',
key: deploymentKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${deploymentKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -132,14 +181,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Statefulset',
attributeKey: {
key: 'k8s_statefulset_name',
key: statefulsetKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${statefulsetKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -147,14 +197,15 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'DaemonSet',
attributeKey: {
key: 'k8s_daemonset_name',
key: daemonsetKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${daemonsetKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
@ -162,32 +213,47 @@ export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Job',
attributeKey: {
key: 'k8s_job_name',
key: jobKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${jobKey}--string--resource--false`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilizationMetric,
dataSource: DataSource.METRICS,
defaultOpen: false,
},
];
}
export const NodesQuickFiltersConfig: IQuickFiltersConfig[] = [
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';
// Define aggregate metric name for node CPU utilization
const cpuUtilMetric = dotMetricsEnabled
? 'k8s.node.cpu.utilization'
: 'k8s_node_cpu_utilization';
return [
{
type: FiltersType.CHECKBOX,
title: 'Node Name',
attributeKey: {
key: 'k8s_node_name',
key: nodeKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${nodeKey}--string--resource--true`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -195,32 +261,46 @@ export const NodesQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource--true`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const NamespaceQuickFiltersConfig: IQuickFiltersConfig[] = [
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';
return [
{
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${namespaceKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -228,65 +308,101 @@ export const NamespaceQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const ClustersQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: cpuUtilMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const ContainersQuickFiltersConfig: IQuickFiltersConfig[] = [
export function GetContainersQuickFiltersConfig(
dotMetricsEnabled: boolean,
): IQuickFiltersConfig[] {
const containerKey = dotMetricsEnabled
? 'k8s.container.name'
: 'k8s_container_name';
return [
{
type: FiltersType.CHECKBOX,
title: 'Container',
attributeKey: {
key: 'k8s_container_name',
key: containerKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${containerKey}--string--resource`,
},
defaultOpen: true,
},
];
}
export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_persistentvolumeclaim_name',
key: pvcKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${pvcKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_volume_capacity',
aggregateAttribute: volumeMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -294,14 +410,15 @@ export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${namespaceKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_volume_capacity',
aggregateAttribute: volumeMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -309,32 +426,49 @@ export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_volume_capacity',
aggregateAttribute: volumeMetric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_deployment_name',
key: deployKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${deployKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -342,14 +476,15 @@ export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${namespaceKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -357,32 +492,49 @@ export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_statefulset_name',
key: ssKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${ssKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -390,14 +542,15 @@ export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${namespaceKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -405,32 +558,49 @@ export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${clusterKey}--string--resource`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metric,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_daemonset_name',
key: nameKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${nameKey}--string--resource--true`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -438,14 +608,14 @@ export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -453,32 +623,46 @@ export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
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: 'k8s_job_name',
key: nameKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
id: `${nameKey}--string--resource--true`,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -486,14 +670,14 @@ export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Namespace Name',
attributeKey: {
key: 'k8s_namespace_name',
key: namespaceKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
@ -501,18 +685,19 @@ export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
type: FiltersType.CHECKBOX,
title: 'Cluster Name',
attributeKey: {
key: 'k8s_cluster_name',
key: clusterKey,
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
},
aggregateOperator: 'noop',
aggregateAttribute: 'k8s_pod_cpu_utilization',
aggregateAttribute: metricName,
dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
}
export const getInvalidValueTooltipText = (
entity: K8sCategory,

View File

@ -299,6 +299,19 @@ export const getK8sPodsListColumns = (
return updatedColumnsConfig as ColumnType<K8sPodsRowData>[];
};
const dotToUnder: Record<string, keyof K8sPodsData['meta']> = {
'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 (

View File

@ -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(

View File

@ -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) => ({

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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', {

View File

@ -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({

View File

@ -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(

View File

@ -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<IServiceName>();
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,
],
);

View File

@ -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 =

View File

@ -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);

View File

@ -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;
}

View File

@ -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 = {

View File

@ -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;
}

View File

@ -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: {

View File

@ -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', () => {

View File

@ -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,

View File

@ -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<string, string>[]
>([]);
const { featureFlags } = useAppContext();
const dotMetricsEnabled =
featureFlags?.find((flag) => flag.name === FeatureKeys.DOT_METRICS_ENABLED)
?.active || false;
const resourceDeploymentKey = getResourceDeploymentKeys(dotMetricsEnabled);
const [selectedEnvironments, setSelectedEnvironments] = useState<string[]>([]);
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 (
<div className="resourceAttributesFilter-container">

View File

@ -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 (
<QueryChipContainer>
<QueryChipItem>{convertMetricKeyToTrace(queryData.tagKey)}</QueryChipItem>
<QueryChipItem>{queryData.operator}</QueryChipItem>
<QueryChipItem
closable={queryData.tagKey !== 'resource_deployment_environment'}
closable={queryData.tagKey !== getResourceDeploymentKeys(dotMetricsEnabled)}
onClose={onCloseHandler}
>
{queryData.tagValue.join(', ')}

View File

@ -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 (
<ServiceMetricTable

View File

@ -19,11 +19,14 @@ import {
export const serviceMetricsQuery = (
topLevelOperation: [keyof ServiceDataProps, string[]],
dotMetricsEnabled: boolean,
): QueryBuilderData => {
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,
},
];

View File

@ -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);

View File

@ -29,6 +29,7 @@ export interface GetQueryRangeRequestDataProps {
maxTime: number;
minTime: number;
globalSelectedInterval: Time | TimeV2 | CustomTimeType;
dotMetricsEnabled: boolean;
}
export interface GetServiceListFromQueryProps {

View File

@ -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(),
},

View File

@ -17,6 +17,7 @@ type UseGetK8sClustersList = (
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sClustersListResponse> | 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<K8sClustersListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sClustersList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sClustersList(requestData, signal, headers, dotMetricsEnabled),
...options,

View File

@ -17,6 +17,7 @@ type UseGetK8sDaemonSetsList = (
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sDaemonSetsListResponse> | 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<K8sDaemonSetsListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sDaemonSetsList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sDaemonSetsList(requestData, signal, headers, dotMetricsEnabled),
...options,

View File

@ -15,6 +15,7 @@ type UseGetK8sDeploymentsList = (
Error
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sDeploymentsListResponse> | 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<K8sDeploymentsListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sDeploymentsList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sDeploymentsList(requestData, signal, headers, dotMetricsEnabled),
...options,
queryKey,
});

View File

@ -17,6 +17,7 @@ type UseGetK8sJobsList = (
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sJobsListResponse> | 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<SuccessResponse<K8sJobsListResponse> | ErrorResponse, Error>({
queryFn: ({ signal }) => getK8sJobsList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sJobsList(requestData, signal, headers, dotMetricsEnabled),
...options,

View File

@ -15,6 +15,7 @@ type UseGetK8sNamespacesList = (
Error
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sNamespacesListResponse> | 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<K8sNamespacesListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sNamespacesList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sNamespacesList(requestData, signal, headers, dotMetricsEnabled),
...options,
queryKey,
});

View File

@ -15,6 +15,7 @@ type UseGetK8sNodesList = (
Error
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sNodesListResponse> | 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<SuccessResponse<K8sNodesListResponse> | ErrorResponse, Error>({
queryFn: ({ signal }) => getK8sNodesList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sNodesList(requestData, signal, headers, dotMetricsEnabled),
...options,
queryKey,
});

View File

@ -15,6 +15,7 @@ type UseGetK8sPodsList = (
Error
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sPodsListResponse> | 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<SuccessResponse<K8sPodsListResponse> | ErrorResponse, Error>({
queryFn: ({ signal }) => getK8sPodsList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sPodsList(requestData, signal, headers, dotMetricsEnabled),
...options,
queryKey,
});

View File

@ -17,6 +17,7 @@ type UseGetK8sStatefulSetsList = (
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sStatefulSetsListResponse> | 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<K8sStatefulSetsListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sStatefulSetsList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sStatefulSetsList(requestData, signal, headers, dotMetricsEnabled),
...options,

View File

@ -15,6 +15,7 @@ type UseGetK8sVolumesList = (
Error
>,
headers?: Record<string, string>,
dotMetricsEnabled?: boolean,
) => UseQueryResult<
SuccessResponse<K8sVolumesListResponse> | 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<K8sVolumesListResponse> | ErrorResponse,
Error
>({
queryFn: ({ signal }) => getK8sVolumesList(requestData, signal, headers),
queryFn: ({ signal }) =>
getK8sVolumesList(requestData, signal, headers, dotMetricsEnabled),
...options,
queryKey,
});

View File

@ -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,

View File

@ -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:

View File

@ -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(

View File

@ -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 => (
<QueryClientProvider client={queryClient}>
<AppProvider>
<Router history={history}>
<ResourceProvider>{children}</ResourceProvider>
</Router>
</AppProvider>
</QueryClientProvider>
);
const { result } = renderHook(() => useResourceAttribute(), { wrapper });

View File

@ -146,7 +146,17 @@ export const OperatorSchema: IOption[] = OperatorConversions.map(
}),
);
export const GetTagKeys = async (): Promise<IOption[]> => {
export const getResourceDeploymentKeys = (
dotMetricsEnabled: boolean,
): string => {
if (dotMetricsEnabled) return 'resource_deployment.environment';
return 'resource_deployment_environment';
};
export const GetTagKeys = async (
dotMetricsEnabled: boolean,
): Promise<IOption[]> => {
const resourceDeploymentKey = getResourceDeploymentKeys(dotMetricsEnabled);
const { payload } = await getResourceAttributesTagKeys({
metricName: 'signoz_calls_total',
match: 'resource_',
@ -159,17 +169,19 @@ export const GetTagKeys = async (): Promise<IOption[]> => {
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<IOption[]> => {
export const getEnvironmentTagKeys = async (
dotMetricsEnabled: boolean,
): Promise<IOption[]> => {
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<IOption[]> => {
}));
};
export const getEnvironmentTagValues = async (): Promise<IOption[]> => {
export const getEnvironmentTagValues = async (
dotMetricsEnabled: boolean,
): Promise<IOption[]> => {
const { payload } = await getResourceAttributesTagValues({
tagKey: 'resource_deployment_environment',
tagKey: getResourceDeploymentKeys(dotMetricsEnabled),
metricName: 'signoz_calls_total',
});

View File

@ -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',
},

View File

@ -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),
],
},
];

View File

@ -79,16 +79,23 @@ export function getWidgetQuery(
};
}
export const requestTimesWidgetData = getWidgetQueryBuilder(
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: 'kafka_request_time_avg',
type: 'Gauge',
},
aggregateOperator: 'avg',
@ -118,26 +125,24 @@ export const requestTimesWidgetData = getWidgetQueryBuilder(
}),
);
export const brokerCountWidgetData = getWidgetQueryBuilder(
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,
key: 'kafka_brokers',
type: 'Gauge',
},
aggregateOperator: 'sum',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -152,30 +157,33 @@ export const brokerCountWidgetData = getWidgetQueryBuilder(
},
],
title: 'Broker Count',
description: 'Total number of active brokers in the Kafka cluster.\n',
description: 'Total number of active brokers in the Kafka cluster.',
}),
);
export const producerFetchRequestPurgatoryWidgetData = getWidgetQueryBuilder(
export const getProducerFetchRequestPurgatoryWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_purgatory_size--float64--Gauge--true',
// 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,
key: 'kafka_purgatory_size',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -195,27 +203,33 @@ export const producerFetchRequestPurgatoryWidgetData = getWidgetQueryBuilder(
}),
);
export const brokerNetworkThroughputWidgetData = getWidgetQueryBuilder(
export const getBrokerNetworkThroughputWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id:
'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate--float64--Gauge--true',
// 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: 'kafka_server_brokertopicmetrics_bytesoutpersec_oneminuterate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -235,26 +249,31 @@ export const brokerNetworkThroughputWidgetData = getWidgetQueryBuilder(
}),
);
export const ioWaitTimeWidgetData = getWidgetQueryBuilder(
export const getIoWaitTimeWidgetData = (dotMetricsEnabled: boolean): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_producer_io_waittime_total--float64--Sum--true',
// 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,
key: 'kafka_producer_io_waittime_total',
type: 'Sum',
},
aggregateOperator: 'rate',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -274,26 +293,32 @@ export const ioWaitTimeWidgetData = getWidgetQueryBuilder(
}),
);
export const requestResponseWidgetData = getWidgetQueryBuilder(
export const getRequestResponseWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_producer_request_rate--float64--Gauge--true',
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: 'kafka_producer_request_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -309,20 +334,23 @@ export const requestResponseWidgetData = getWidgetQueryBuilder(
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_producer_response_rate--float64--Gauge--true',
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: 'kafka_producer_response_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'B',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -342,26 +370,32 @@ export const requestResponseWidgetData = getWidgetQueryBuilder(
}),
);
export const averageRequestLatencyWidgetData = getWidgetQueryBuilder(
export const getAverageRequestLatencyWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_producer_request_latency_avg--float64--Gauge--true',
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: 'kafka_producer_request_latency_avg',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -381,26 +415,32 @@ export const averageRequestLatencyWidgetData = getWidgetQueryBuilder(
}),
);
export const kafkaProducerByteRateWidgetData = getWidgetQueryBuilder(
export const getKafkaProducerByteRateWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_producer_byte_rate--float64--Gauge--true',
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: 'kafka_producer_byte_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -423,32 +463,40 @@ export const kafkaProducerByteRateWidgetData = getWidgetQueryBuilder(
timeAggregation: 'avg',
},
],
title: 'kafka_producer_byte_rate',
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 bytesConsumedWidgetData = getWidgetQueryBuilder(
export const getBytesConsumedWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_bytes_consumed_rate--float64--Gauge--true',
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: 'kafka_consumer_bytes_consumed_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -462,32 +510,39 @@ export const bytesConsumedWidgetData = getWidgetQueryBuilder(
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 consumerOffsetWidgetData = getWidgetQueryBuilder(
export const getConsumerOffsetWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_group_offset--float64--Gauge--true',
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: 'kafka_consumer_group_offset',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -527,30 +582,37 @@ export const consumerOffsetWidgetData = getWidgetQueryBuilder(
},
],
title: 'Consumer Offset',
description: 'Current offset of each consumer group for each topic partition',
description:
'Current offset of each consumer group for each topic partition',
}),
);
export const consumerGroupMemberWidgetData = getWidgetQueryBuilder(
export const getConsumerGroupMemberWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_group_members--float64--Gauge--true',
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,
key: 'kafka_consumer_group_members',
type: 'Gauge',
},
aggregateOperator: 'sum',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -578,26 +640,32 @@ export const consumerGroupMemberWidgetData = getWidgetQueryBuilder(
}),
);
export const consumerLagByGroupWidgetData = getWidgetQueryBuilder(
export const getConsumerLagByGroupWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_group_lag--float64--Gauge--true',
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,
key: 'kafka_consumer_group_lag',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -642,26 +710,32 @@ export const consumerLagByGroupWidgetData = getWidgetQueryBuilder(
}),
);
export const consumerFetchRateWidgetData = getWidgetQueryBuilder(
export const getConsumerFetchRateWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_fetch_rate--float64--Gauge--true',
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,
key: 'kafka_consumer_fetch_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -669,7 +743,7 @@ export const consumerFetchRateWidgetData = getWidgetQueryBuilder(
id: 'service_name--string--tag--false',
isColumn: false,
isJSON: false,
key: 'service_name',
key: dotMetricsEnabled ? 'service.name' : 'service_name',
type: 'tag',
},
],
@ -690,26 +764,32 @@ export const consumerFetchRateWidgetData = getWidgetQueryBuilder(
}),
);
export const messagesConsumedWidgetData = getWidgetQueryBuilder(
export const getMessagesConsumedWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_consumer_records_consumed_rate--float64--Gauge--true',
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,
key: 'kafka_consumer_records_consumed_rate',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -729,26 +809,30 @@ export const messagesConsumedWidgetData = getWidgetQueryBuilder(
}),
);
export const jvmGCCountWidgetData = getWidgetQueryBuilder(
export const getJvmGCCountWidgetData = (dotMetricsEnabled: boolean): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'jvm_gc_collections_count--float64--Sum--true',
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,
key: 'jvm_gc_collections_count',
type: 'Sum',
},
aggregateOperator: 'rate',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -768,26 +852,32 @@ export const jvmGCCountWidgetData = getWidgetQueryBuilder(
}),
);
export const jvmGcCollectionsElapsedWidgetData = getWidgetQueryBuilder(
export const getJvmGcCollectionsElapsedWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'jvm_gc_collections_elapsed--float64--Sum--true',
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,
key: 'jvm_gc_collections_elapsed',
type: 'Sum',
},
aggregateOperator: 'rate',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -801,32 +891,40 @@ export const jvmGcCollectionsElapsedWidgetData = getWidgetQueryBuilder(
timeAggregation: 'rate',
},
],
title: 'jvm_gc_collections_elapsed',
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 cpuRecentUtilizationWidgetData = getWidgetQueryBuilder(
export const getCpuRecentUtilizationWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'jvm_cpu_recent_utilization--float64--Gauge--true',
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,
key: 'jvm_cpu_recent_utilization',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -846,26 +944,28 @@ export const cpuRecentUtilizationWidgetData = getWidgetQueryBuilder(
}),
);
export const jvmMemoryHeapWidgetData = getWidgetQueryBuilder(
export const getJvmMemoryHeapWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'jvm_memory_heap_max--float64--Gauge--true',
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,
key: 'jvm_memory_heap_max',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [],
having: [],
@ -885,26 +985,30 @@ export const jvmMemoryHeapWidgetData = getWidgetQueryBuilder(
}),
);
export const partitionCountPerTopicWidgetData = getWidgetQueryBuilder(
export const getPartitionCountPerTopicWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_topic_partitions--float64--Gauge--true',
key: dotMetricsEnabled
? 'kafka.topic.partitions'
: 'kafka_topic_partitions',
id: `${
dotMetricsEnabled ? 'kafka.topic.partitions' : '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',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -932,26 +1036,32 @@ export const partitionCountPerTopicWidgetData = getWidgetQueryBuilder(
}),
);
export const currentOffsetPartitionWidgetData = getWidgetQueryBuilder(
export const getCurrentOffsetPartitionWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_partition_current_offset--float64--Gauge--true',
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,
key: 'kafka_partition_current_offset',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -988,26 +1098,32 @@ export const currentOffsetPartitionWidgetData = getWidgetQueryBuilder(
}),
);
export const oldestOffsetWidgetData = getWidgetQueryBuilder(
export const getOldestOffsetWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_partition_oldest_offset--float64--Gauge--true',
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,
key: 'kafka_partition_oldest_offset',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{
@ -1044,26 +1160,32 @@ export const oldestOffsetWidgetData = getWidgetQueryBuilder(
}),
);
export const insyncReplicasWidgetData = getWidgetQueryBuilder(
export const getInsyncReplicasWidgetData = (
dotMetricsEnabled: boolean,
): Widgets =>
getWidgetQueryBuilder(
getWidgetQuery({
queryData: [
{
aggregateAttribute: {
dataType: DataTypes.Float64,
id: 'kafka_partition_replicas_in_sync--float64--Gauge--true',
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,
key: 'kafka_partition_replicas_in_sync',
type: 'Gauge',
},
aggregateOperator: 'avg',
dataSource: DataSource.METRICS,
disabled: false,
expression: 'A',
filters: {
items: [],
op: 'AND',
},
filters: { items: [], op: 'AND' },
functions: [],
groupBy: [
{

View File

@ -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<string>('');
const { isFetching, options } = useGetAllConfigOptions({
const { isFetching, options } = useGetAllConfigOptions(
{
attributeKey: type,
searchText,
});
},
dotMetricsEnabled,
);
const handleDebouncedSearch = useDebouncedFn((searchText): void => {
setSearchText(searchText as string);
}, 500);

View File

@ -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<DefaultOptionType[]> => {
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,

View File

@ -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 (
<QueryClientProvider client={queryClient}>
<ResourceProvider>
<ErrorModalProvider>
<Provider store={mockStored(role)}>
<AppContext.Provider value={getAppContextMock(role, appContextOverrides)}>
<ResourceProvider>
<ErrorModalProvider>
<BrowserRouter>
{/* Use the mock store with the provided role */}
<TimezoneProvider>
<QueryBuilderProvider>{children}</QueryBuilderProvider>
</TimezoneProvider>
</BrowserRouter>
</AppContext.Provider>
</Provider>
</ErrorModalProvider>
</ResourceProvider>
</AppContext.Provider>
</Provider>
</QueryClientProvider>
);
}

View File

@ -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 {

View File

@ -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}
}

View File

@ -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,9 +1198,33 @@ func prepareQuery(r *http.Request) (string, error) {
if tmplErr != nil {
return "", tmplErr
}
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) {
query, err := prepareQuery(r)
if err != nil {
@ -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:

View File

@ -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"},

Some files were not shown because too many files have changed in this diff Show More