Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: statefulsets, daemonsets, jobs and volumes implementation in k8s infra monitoring (#6629)

Amlan Kumar Nandy813ca8bc2302
diff --git a/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts b/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts
new file mode 100644
index 0000000000..c09de10580
--- /dev/null
+++ b/frontend/src/api/infraMonitoring/getK8sDaemonSetsList.ts
@@ -0,0 +1,70 @@
+import axios from 'api';
+import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
+import { AxiosError } from 'axios';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
+
+export interface K8sDaemonSetsListPayload {
+ filters: TagFilter;
+ groupBy?: BaseAutocompleteData[];
+ offset?: number;
+ limit?: number;
+ orderBy?: {
+ columnName: string;
+ order: 'asc' | 'desc';
+ };
+}
+
+export interface K8sDaemonSetsData {
+ daemonSetName: string;
+ cpuUsage: number;
+ memoryUsage: number;
+ cpuRequest: number;
+ memoryRequest: number;
+ cpuLimit: number;
+ memoryLimit: number;
+ restarts: number;
+ desiredNodes: number;
+ availableNodes: number;
+ meta: {
+ k8s_cluster_name: string;
+ k8s_daemonset_name: string;
+ k8s_namespace_name: string;
+ };
+}
+
+export interface K8sDaemonSetsListResponse {
+ status: string;
+ data: {
+ type: string;
+ records: K8sDaemonSetsData[];
+ groups: null;
+ total: number;
+ sentAnyHostMetricsData: boolean;
+ isSendingK8SAgentMetrics: boolean;
+ };
+}
+
+export const getK8sDaemonSetsList = async (
+ props: K8sDaemonSetsListPayload,
+ signal?: AbortSignal,
+ headers?: Record<string, string>,
+): Promise<SuccessResponse<K8sDaemonSetsListResponse> | ErrorResponse> => {
+ try {
+ const response = await axios.post('/daemonsets/list', props, {
+ signal,
+ headers,
+ });
+
+ return {
+ statusCode: 200,
+ error: null,
+ message: 'Success',
+ payload: response.data,
+ params: props,
+ };
+ } catch (error) {
+ return ErrorResponseHandler(error as AxiosError);
+ }
+};
diff --git a/frontend/src/api/infraMonitoring/getK8sJobsList.ts b/frontend/src/api/infraMonitoring/getK8sJobsList.ts
new file mode 100644
index 0000000000..36a6bb973d
--- /dev/null
+++ b/frontend/src/api/infraMonitoring/getK8sJobsList.ts
@@ -0,0 +1,72 @@
+import axios from 'api';
+import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
+import { AxiosError } from 'axios';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
+
+export interface K8sJobsListPayload {
+ filters: TagFilter;
+ groupBy?: BaseAutocompleteData[];
+ offset?: number;
+ limit?: number;
+ orderBy?: {
+ columnName: string;
+ order: 'asc' | 'desc';
+ };
+}
+
+export interface K8sJobsData {
+ jobName: string;
+ cpuUsage: number;
+ memoryUsage: number;
+ cpuRequest: number;
+ memoryRequest: number;
+ cpuLimit: number;
+ memoryLimit: number;
+ restarts: number;
+ desiredSuccessfulPods: number;
+ activePods: number;
+ failedPods: number;
+ successfulPods: number;
+ meta: {
+ k8s_cluster_name: string;
+ k8s_job_name: string;
+ k8s_namespace_name: string;
+ };
+}
+
+export interface K8sJobsListResponse {
+ status: string;
+ data: {
+ type: string;
+ records: K8sJobsData[];
+ groups: null;
+ total: number;
+ sentAnyHostMetricsData: boolean;
+ isSendingK8SAgentMetrics: boolean;
+ };
+}
+
+export const getK8sJobsList = async (
+ props: K8sJobsListPayload,
+ signal?: AbortSignal,
+ headers?: Record<string, string>,
+): Promise<SuccessResponse<K8sJobsListResponse> | ErrorResponse> => {
+ try {
+ const response = await axios.post('/jobs/list', props, {
+ signal,
+ headers,
+ });
+
+ return {
+ statusCode: 200,
+ error: null,
+ message: 'Success',
+ payload: response.data,
+ params: props,
+ };
+ } catch (error) {
+ return ErrorResponseHandler(error as AxiosError);
+ }
+};
diff --git a/frontend/src/api/infraMonitoring/getK8sVolumesList.ts b/frontend/src/api/infraMonitoring/getK8sVolumesList.ts
new file mode 100644
index 0000000000..ea825ba05d
--- /dev/null
+++ b/frontend/src/api/infraMonitoring/getK8sVolumesList.ts
@@ -0,0 +1,71 @@
+import axios from 'api';
+import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
+import { AxiosError } from 'axios';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
+
+export interface K8sVolumesListPayload {
+ filters: TagFilter;
+ groupBy?: BaseAutocompleteData[];
+ offset?: number;
+ limit?: number;
+ orderBy?: {
+ columnName: string;
+ order: 'asc' | 'desc';
+ };
+}
+
+export interface K8sVolumesData {
+ persistentVolumeClaimName: string;
+ volumeAvailable: number;
+ volumeCapacity: number;
+ volumeInodes: number;
+ volumeInodesFree: number;
+ volumeInodesUsed: number;
+ volumeUsage: number;
+ meta: {
+ k8s_cluster_name: string;
+ k8s_namespace_name: string;
+ k8s_node_name: string;
+ k8s_persistentvolumeclaim_name: string;
+ k8s_pod_name: string;
+ k8s_pod_uid: string;
+ k8s_statefulset_name: string;
+ };
+}
+
+export interface K8sVolumesListResponse {
+ status: string;
+ data: {
+ type: string;
+ records: K8sVolumesData[];
+ groups: null;
+ total: number;
+ sentAnyHostMetricsData: boolean;
+ isSendingK8SAgentMetrics: boolean;
+ };
+}
+
+export const getK8sVolumesList = async (
+ props: K8sVolumesListPayload,
+ signal?: AbortSignal,
+ headers?: Record<string, string>,
+): Promise<SuccessResponse<K8sVolumesListResponse> | ErrorResponse> => {
+ try {
+ const response = await axios.post('/pvcs/list', props, {
+ signal,
+ headers,
+ });
+
+ return {
+ statusCode: 200,
+ error: null,
+ message: 'Success',
+ payload: response.data,
+ params: props,
+ };
+ } catch (error) {
+ return ErrorResponseHandler(error as AxiosError);
+ }
+};
diff --git a/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts b/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts
new file mode 100644
index 0000000000..191ec069c3
--- /dev/null
+++ b/frontend/src/api/infraMonitoring/getsK8sStatefulSetsList.ts
@@ -0,0 +1,69 @@
+import axios from 'api';
+import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
+import { AxiosError } from 'axios';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
+
+export interface K8sStatefulSetsListPayload {
+ filters: TagFilter;
+ groupBy?: BaseAutocompleteData[];
+ offset?: number;
+ limit?: number;
+ orderBy?: {
+ columnName: string;
+ order: 'asc' | 'desc';
+ };
+}
+
+export interface K8sStatefulSetsData {
+ statefulSetName: string;
+ cpuUsage: number;
+ memoryUsage: number;
+ desiredPods: number;
+ availablePods: number;
+ cpuRequest: number;
+ memoryRequest: number;
+ cpuLimit: number;
+ memoryLimit: number;
+ restarts: number;
+ meta: {
+ k8s_statefulset_name: string;
+ k8s_namespace_name: string;
+ };
+}
+
+export interface K8sStatefulSetsListResponse {
+ status: string;
+ data: {
+ type: string;
+ records: K8sStatefulSetsData[];
+ groups: null;
+ total: number;
+ sentAnyHostMetricsData: boolean;
+ isSendingK8SAgentMetrics: boolean;
+ };
+}
+
+export const getK8sStatefulSetsList = async (
+ props: K8sStatefulSetsListPayload,
+ signal?: AbortSignal,
+ headers?: Record<string, string>,
+): Promise<SuccessResponse<K8sStatefulSetsListResponse> | ErrorResponse> => {
+ try {
+ const response = await axios.post('/statefulsets/list', props, {
+ signal,
+ headers,
+ });
+
+ return {
+ statusCode: 200,
+ error: null,
+ message: 'Success',
+ payload: response.data,
+ params: props,
+ };
+ } catch (error) {
+ return ErrorResponseHandler(error as AxiosError);
+ }
+};
diff --git a/frontend/src/constants/reactQueryKeys.ts b/frontend/src/constants/reactQueryKeys.ts
index 30da4e1362..19d894ab8e 100644
--- a/frontend/src/constants/reactQueryKeys.ts
+++ b/frontend/src/constants/reactQueryKeys.ts
@@ -26,4 +26,8 @@ export const REACT_QUERY_KEY = {
GET_DEPLOYMENT_LIST: 'GET_DEPLOYMENT_LIST',
GET_CLUSTER_LIST: 'GET_CLUSTER_LIST',
GET_NAMESPACE_LIST: 'GET_NAMESPACE_LIST',
+ GET_STATEFULSET_LIST: 'GET_STATEFULSET_LIST',
+ GET_JOB_LIST: 'GET_JOB_LIST',
+ GET_DAEMONSET_LIST: 'GET_DAEMONSET_LIST,',
+ GET_VOLUME_LIST: 'GET_VOLUME_LIST',
};
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.interfaces.ts b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.interfaces.ts
new file mode 100644
index 0000000000..6b21b2f77e
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.interfaces.ts
@@ -0,0 +1,7 @@
+import { K8sDaemonSetsData } from 'api/infraMonitoring/getK8sDaemonSetsList';
+
+export type DaemonSetDetailsProps = {
+ daemonSet: K8sDaemonSetsData | null;
+ isModalTimeSelection: boolean;
+ onClose: () => void;
+};
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.tsx b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.tsx
new file mode 100644
index 0000000000..36312c59cd
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/DaemonSetDetails.tsx
@@ -0,0 +1,593 @@
+/* eslint-disable sonarjs/no-identical-functions */
+import '../../EntityDetailsUtils/entityDetails.styles.scss';
+
+import { Color, Spacing } from '@signozhq/design-tokens';
+import { Button, Divider, Drawer, Radio, Tooltip, Typography } from 'antd';
+import { RadioChangeEvent } from 'antd/lib';
+import logEvent from 'api/common/logEvent';
+import { VIEW_TYPES, VIEWS } from 'components/HostMetricsDetail/constants';
+import { QueryParams } from 'constants/query';
+import {
+ initialQueryBuilderFormValuesMap,
+ initialQueryState,
+} from 'constants/queryBuilder';
+import ROUTES from 'constants/routes';
+import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
+import {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/config';
+import { useIsDarkMode } from 'hooks/useDarkMode';
+import useUrlQuery from 'hooks/useUrlQuery';
+import GetMinMax from 'lib/getMinMax';
+import {
+ BarChart2,
+ ChevronsLeftRight,
+ Compass,
+ DraftingCompass,
+ ScrollText,
+ X,
+} from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import {
+ IBuilderQuery,
+ TagFilterItem,
+} from 'types/api/queryBuilder/queryBuilderData';
+import {
+ LogsAggregatorOperator,
+ TracesAggregatorOperator,
+} from 'types/common/queryBuilder';
+import { GlobalReducer } from 'types/reducer/globalTime';
+import { v4 as uuidv4 } from 'uuid';
+
+import DaemonSetEvents from '../../EntityDetailsUtils/EntityEvents';
+import DaemonSetLogs from '../../EntityDetailsUtils/EntityLogs';
+import DaemonSetMetrics from '../../EntityDetailsUtils/EntityMetrics';
+import DaemonSetTraces from '../../EntityDetailsUtils/EntityTraces';
+import { QUERY_KEYS } from '../../EntityDetailsUtils/utils';
+import {
+ daemonSetWidgetInfo,
+ getDaemonSetMetricsQueryPayload,
+} from './constants';
+import { DaemonSetDetailsProps } from './DaemonSetDetails.interfaces';
+
+function DaemonSetDetails({
+ daemonSet,
+ onClose,
+ isModalTimeSelection,
+}: DaemonSetDetailsProps): JSX.Element {
+ const { maxTime, minTime, selectedTime } = useSelector<
+ AppState,
+ GlobalReducer
+ >((state) => state.globalTime);
+
+ const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
+ minTime,
+ ]);
+ const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
+ maxTime,
+ ]);
+
+ const urlQuery = useUrlQuery();
+
+ const [modalTimeRange, setModalTimeRange] = useState(() => ({
+ startTime: startMs,
+ endTime: endMs,
+ }));
+
+ const [selectedInterval, setSelectedInterval] = useState<Time>(
+ selectedTime as Time,
+ );
+
+ const [selectedView, setSelectedView] = useState<VIEWS>(VIEWS.METRICS);
+ const isDarkMode = useIsDarkMode();
+
+ const initialFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_DAEMON_SET_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_daemonSet_name--string--resource--false',
+ },
+ op: '=',
+ value: daemonSet?.meta.k8s_daemonset_name || '',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_NAMESPACE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_daemonSet_name--string--resource--false',
+ },
+ op: '=',
+ value: daemonSet?.meta.k8s_namespace_name || '',
+ },
+ ],
+ }),
+ [daemonSet?.meta.k8s_daemonset_name, daemonSet?.meta.k8s_namespace_name],
+ );
+
+ const initialEventsFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_KIND,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.kind--string--resource--false',
+ },
+ op: '=',
+ value: 'DaemonSet',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.name--string--resource--false',
+ },
+ op: '=',
+ value: daemonSet?.meta.k8s_daemonset_name || '',
+ },
+ ],
+ }),
+ [daemonSet?.meta.k8s_daemonset_name],
+ );
+
+ const [logFilters, setLogFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [tracesFilters, setTracesFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [eventsFilters, setEventsFilters] = useState<IBuilderQuery['filters']>(
+ initialEventsFilters,
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: DaemonSets list details page visited', {
+ daemonSet: daemonSet?.daemonSetName,
+ });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ setLogFilters(initialFilters);
+ setTracesFilters(initialFilters);
+ setEventsFilters(initialEventsFilters);
+ }, [initialFilters, initialEventsFilters]);
+
+ useEffect(() => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ }, [selectedTime, minTime, maxTime]);
+
+ const handleTabChange = (e: RadioChangeEvent): void => {
+ setSelectedView(e.target.value);
+ };
+
+ const handleTimeChange = useCallback(
+ (interval: Time | CustomTimeType, dateTimeRange?: [number, number]): void => {
+ setSelectedInterval(interval as Time);
+
+ if (interval === 'custom' && dateTimeRange) {
+ setModalTimeRange({
+ startTime: Math.floor(dateTimeRange[0] / 1000),
+ endTime: Math.floor(dateTimeRange[1] / 1000),
+ });
+ } else {
+ const { maxTime, minTime } = GetMinMax(interval);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+
+ logEvent('Infra Monitoring: DaemonSets list details time updated', {
+ daemonSet: daemonSet?.daemonSetName,
+ interval,
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeLogFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setLogFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_DAEMON_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+ const paginationFilter = value.items.find((item) => item.key?.key === 'id');
+ const newFilters = value.items.filter(
+ (item) =>
+ item.key?.key !== 'id' &&
+ item.key?.key !== QUERY_KEYS.K8S_DAEMON_SET_NAME,
+ );
+
+ logEvent('Infra Monitoring: DaemonSets list details logs filters applied', {
+ daemonSet: daemonSet?.daemonSetName,
+ });
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...newFilters,
+ ...(paginationFilter ? [paginationFilter] : []),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeTracesFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setTracesFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_DAEMON_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+
+ logEvent(
+ 'Infra Monitoring: DaemonSets list details traces filters applied',
+ {
+ daemonSet: daemonSet?.daemonSetName,
+ },
+ );
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...value.items.filter(
+ (item) => item.key?.key !== QUERY_KEYS.K8S_DAEMON_SET_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeEventsFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setEventsFilters((prevFilters) => {
+ const daemonSetKindFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_KIND,
+ );
+ const daemonSetNameFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_NAME,
+ );
+
+ logEvent(
+ 'Infra Monitoring: DaemonSets list details events filters applied',
+ {
+ daemonSet: daemonSet?.daemonSetName,
+ },
+ );
+
+ return {
+ op: 'AND',
+ items: [
+ daemonSetKindFilter,
+ daemonSetNameFilter,
+ ...value.items.filter(
+ (item) =>
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_KIND &&
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleExplorePagesRedirect = (): void => {
+ if (selectedInterval !== 'custom') {
+ urlQuery.set(QueryParams.relativeTime, selectedInterval);
+ } else {
+ urlQuery.delete(QueryParams.relativeTime);
+ urlQuery.set(QueryParams.startTime, modalTimeRange.startTime.toString());
+ urlQuery.set(QueryParams.endTime, modalTimeRange.endTime.toString());
+ }
+
+ logEvent('Infra Monitoring: DaemonSets list details explore clicked', {
+ daemonSet: daemonSet?.daemonSetName,
+ view: selectedView,
+ });
+
+ if (selectedView === VIEW_TYPES.LOGS) {
+ const filtersWithoutPagination = {
+ ...logFilters,
+ items: logFilters.items.filter((item) => item.key?.key !== 'id'),
+ };
+
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.logs,
+ aggregateOperator: LogsAggregatorOperator.NOOP,
+ filters: filtersWithoutPagination,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.LOGS_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ } else if (selectedView === VIEW_TYPES.TRACES) {
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.traces,
+ aggregateOperator: TracesAggregatorOperator.NOOP,
+ filters: tracesFilters,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.TRACES_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ }
+ };
+
+ const handleClose = (): void => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ setSelectedView(VIEW_TYPES.METRICS);
+ onClose();
+ };
+
+ return (
+ <Drawer
+ width="70%"
+ title={
+ <>
+ <Divider type="vertical" />
+ <Typography.Text className="title">
+ {daemonSet?.meta.k8s_daemonset_name}
+ </Typography.Text>
+ </>
+ }
+ placement="right"
+ onClose={handleClose}
+ open={!!daemonSet}
+ style={{
+ overscrollBehavior: 'contain',
+ background: isDarkMode ? Color.BG_INK_400 : Color.BG_VANILLA_100,
+ }}
+ className="entity-detail-drawer"
+ destroyOnClose
+ closeIcon={<X size={16} style={{ marginTop: Spacing.MARGIN_1 }} />}
+ >
+ {daemonSet && (
+ <>
+ <div className="entity-detail-drawer__entity">
+ <div className="entity-details-grid">
+ <div className="labels-row">
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Daemonset Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Cluster Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Namespace Name
+ </Typography.Text>
+ </div>
+ <div className="values-row">
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={daemonSet.meta.k8s_daemonset_name}>
+ {daemonSet.meta.k8s_daemonset_name}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={daemonSet.meta.k8s_cluster_name}>
+ {daemonSet.meta.k8s_cluster_name}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={daemonSet.meta.k8s_namespace_name}>
+ {daemonSet.meta.k8s_namespace_name}
+ </Tooltip>
+ </Typography.Text>
+ </div>
+ </div>
+ </div>
+
+ <div className="views-tabs-container">
+ <Radio.Group
+ className="views-tabs"
+ onChange={handleTabChange}
+ value={selectedView}
+ >
+ <Radio.Button
+ className={
+ // eslint-disable-next-line sonarjs/no-duplicate-string
+ selectedView === VIEW_TYPES.METRICS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.METRICS}
+ >
+ <div className="view-title">
+ <BarChart2 size={14} />
+ Metrics
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.LOGS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.LOGS}
+ >
+ <div className="view-title">
+ <ScrollText size={14} />
+ Logs
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.TRACES ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.TRACES}
+ >
+ <div className="view-title">
+ <DraftingCompass size={14} />
+ Traces
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.EVENTS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.EVENTS}
+ >
+ <div className="view-title">
+ <ChevronsLeftRight size={14} />
+ Events
+ </div>
+ </Radio.Button>
+ </Radio.Group>
+
+ {(selectedView === VIEW_TYPES.LOGS ||
+ selectedView === VIEW_TYPES.TRACES) && (
+ <Button
+ icon={<Compass size={18} />}
+ className="compass-button"
+ onClick={handleExplorePagesRedirect}
+ />
+ )}
+ </div>
+ {selectedView === VIEW_TYPES.METRICS && (
+ <DaemonSetMetrics
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ entity={daemonSet}
+ entityWidgetInfo={daemonSetWidgetInfo}
+ getEntityQueryPayload={getDaemonSetMetricsQueryPayload}
+ category={K8sCategory.DAEMONSETS}
+ queryKey="daemonsetMetrics"
+ />
+ )}
+ {selectedView === VIEW_TYPES.LOGS && (
+ <DaemonSetLogs
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeLogFilters={handleChangeLogFilters}
+ logFilters={logFilters}
+ selectedInterval={selectedInterval}
+ category={K8sCategory.DAEMONSETS}
+ queryKey="daemonsetLogs"
+ queryKeyFilters={[
+ QUERY_KEYS.K8S_DAEMON_SET_NAME,
+ QUERY_KEYS.K8S_NAMESPACE_NAME,
+ ]}
+ />
+ )}
+ {selectedView === VIEW_TYPES.TRACES && (
+ <DaemonSetTraces
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeTracesFilters={handleChangeTracesFilters}
+ tracesFilters={tracesFilters}
+ selectedInterval={selectedInterval}
+ queryKey="daemonsetTraces"
+ />
+ )}
+ {selectedView === VIEW_TYPES.EVENTS && (
+ <DaemonSetEvents
+ timeRange={modalTimeRange}
+ handleChangeEventFilters={handleChangeEventsFilters}
+ filters={eventsFilters}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ queryKey="daemonsetEvents"
+ category={K8sCategory.DAEMONSETS}
+ />
+ )}
+ </>
+ )}
+ </Drawer>
+ );
+}
+
+export default DaemonSetDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts
new file mode 100644
index 0000000000..1b9ea26033
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/constants.ts
@@ -0,0 +1,648 @@
+/* eslint-disable sonarjs/no-duplicate-string */
+import { K8sDaemonSetsData } from 'api/infraMonitoring/getK8sDaemonSetsList';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { EQueryType } from 'types/common/dashboard';
+import { DataSource } from 'types/common/queryBuilder';
+import { v4 } from 'uuid';
+
+export const daemonSetWidgetInfo = [
+ {
+ title: 'CPU usage, request, limits',
+ yAxisUnit: '',
+ },
+ {
+ title: 'Memory usage, request, limits',
+ yAxisUnit: 'bytes',
+ },
+ {
+ title: 'Network IO',
+ yAxisUnit: 'binBps',
+ },
+ {
+ title: 'Network errors count',
+ yAxisUnit: '',
+ },
+];
+
+export const getDaemonSetMetricsQueryPayload = (
+ daemonSet: K8sDaemonSetsData,
+ start: number,
+ end: number,
+): GetQueryResultsProps[] => [
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_cpu_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '745a486f',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_daemonset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_daemonset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_cpu_request--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_cpu_request',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: '148dffa7',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'requests',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_cpu_limit--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_cpu_limit',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'C',
+ filters: {
+ items: [
+ {
+ id: 'd420a02b',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'limits',
+ limit: null,
+ orderBy: [],
+ queryName: 'C',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_memory_usage--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_memory_usage',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6d3283ce',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_daemonset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_daemonset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_memory_request--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_memory_request',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: 'a334f5c2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'requests',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_memory_limit--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_memory_limit',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'C',
+ filters: {
+ items: [
+ {
+ id: 'fde3c631',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'limits',
+ limit: null,
+ orderBy: [],
+ queryName: 'C',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_io--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_io',
+ type: 'Sum',
+ },
+ aggregateOperator: 'rate',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: 'ccbdbd6a',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_daemonset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_daemonset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'rate',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_errors--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_errors',
+ type: 'Sum',
+ },
+ aggregateOperator: 'increase',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '581a85fb',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_daemonset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_daemonset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_daemonset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: daemonSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'increase',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/index.ts b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/index.ts
new file mode 100644
index 0000000000..462ee23be4
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/DaemonSetDetails/index.ts
@@ -0,0 +1,3 @@
+import DaemonSetDetails from './DaemonSetDetails';
+
+export default DaemonSetDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.styles.scss b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.styles.scss
new file mode 100644
index 0000000000..7c3d056dce
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.styles.scss
@@ -0,0 +1,62 @@
+.infra-monitoring-container {
+ .daemonSets-list-table {
+ .expanded-table-container {
+ padding-left: 20px;
+ }
+
+ .ant-table-cell.column-progress-bar {
+ min-width: 180px;
+ max-width: 180px;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+
+ .progress-container {
+ display: flex;
+ justify-content: start;
+ }
+ }
+}
+
+.ant-table-cell {
+ &:has(.daemonset-name-header) {
+ min-width: 250px !important;
+ max-width: 250px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.namespace-name-header) {
+ min-width: 220px !important;
+ max-width: 220px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.med-col) {
+ min-width: 200px !important;
+ max-width: 200px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.small-col) {
+ min-width: 120px !important;
+ max-width: 120px !important;
+ }
+}
+
+.expanded-daemonsets-list-table {
+ .ant-table-cell {
+ min-width: 220px !important;
+ max-width: 220px !important;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+}
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx
new file mode 100644
index 0000000000..5fc60527c4
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/K8sDaemonSetsList.tsx
@@ -0,0 +1,516 @@
+/* eslint-disable no-restricted-syntax */
+/* eslint-disable @typescript-eslint/explicit-function-return-type */
+import '../InfraMonitoringK8s.styles.scss';
+import './K8sDaemonSetsList.styles.scss';
+
+import { LoadingOutlined } from '@ant-design/icons';
+import {
+ Button,
+ Spin,
+ Table,
+ TablePaginationConfig,
+ TableProps,
+ Typography,
+} from 'antd';
+import { ColumnType, SorterResult } from 'antd/es/table/interface';
+import logEvent from 'api/common/logEvent';
+import { K8sDaemonSetsListPayload } from 'api/infraMonitoring/getK8sDaemonSetsList';
+import classNames from 'classnames';
+import { useGetK8sDaemonSetsList } from 'hooks/infraMonitoring/useGetK8sDaemonSetsList';
+import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+import {
+ K8sCategory,
+ K8sEntityToAggregateAttributeMapping,
+} from '../constants';
+import K8sHeader from '../K8sHeader';
+import LoadingContainer from '../LoadingContainer';
+import DaemonSetDetails from './DaemonSetDetails';
+import {
+ defaultAddedColumns,
+ formatDataForTable,
+ getK8sDaemonSetsListColumns,
+ getK8sDaemonSetsListQuery,
+ K8sDaemonSetsRowData,
+} from './utils';
+
+// eslint-disable-next-line sonarjs/cognitive-complexity
+function K8sDaemonSetsList({
+ isFiltersVisible,
+ handleFilterVisibilityChange,
+ quickFiltersLastUpdated,
+}: {
+ isFiltersVisible: boolean;
+ handleFilterVisibilityChange: () => void;
+ quickFiltersLastUpdated: number;
+}): JSX.Element {
+ const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
+ (state) => state.globalTime,
+ );
+
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]);
+
+ const [orderBy, setOrderBy] = useState<{
+ columnName: string;
+ order: 'asc' | 'desc';
+ } | null>(null);
+
+ const [selectedDaemonSetUID, setselectedDaemonSetUID] = useState<
+ string | null
+ >(null);
+
+ const pageSize = 10;
+
+ const [groupBy, setGroupBy] = useState<IBuilderQuery['groupBy']>([]);
+
+ const [
+ selectedRowData,
+ setSelectedRowData,
+ ] = useState<K8sDaemonSetsRowData | null>(null);
+
+ const [groupByOptions, setGroupByOptions] = useState<
+ { value: string; label: string }[]
+ >([]);
+
+ const { currentQuery } = useQueryBuilder();
+
+ const queryFilters = useMemo(
+ () =>
+ currentQuery?.builder?.queryData[0]?.filters || {
+ items: [],
+ op: 'and',
+ },
+ [currentQuery?.builder?.queryData],
+ );
+
+ // Reset pagination every time quick filters are changed
+ useEffect(() => {
+ setCurrentPage(1);
+ }, [quickFiltersLastUpdated]);
+
+ const createFiltersForSelectedRowData = (
+ selectedRowData: K8sDaemonSetsRowData,
+ groupBy: IBuilderQuery['groupBy'],
+ ): IBuilderQuery['filters'] => {
+ const baseFilters: IBuilderQuery['filters'] = {
+ items: [...queryFilters.items],
+ op: 'and',
+ };
+
+ if (!selectedRowData) return baseFilters;
+
+ const { groupedByMeta } = selectedRowData;
+
+ for (const key of groupBy) {
+ baseFilters.items.push({
+ key: {
+ key: key.key,
+ type: null,
+ },
+ op: '=',
+ value: groupedByMeta[key.key],
+ id: key.key,
+ });
+ }
+
+ return baseFilters;
+ };
+
+ const fetchGroupedByRowDataQuery = useMemo(() => {
+ if (!selectedRowData) return null;
+
+ const baseQuery = getK8sDaemonSetsListQuery();
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ return {
+ ...baseQuery,
+ limit: 10,
+ offset: 0,
+ filters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [minTime, maxTime, orderBy, selectedRowData, groupBy]);
+
+ const {
+ data: groupedByRowData,
+ isFetching: isFetchingGroupedByRowData,
+ isLoading: isLoadingGroupedByRowData,
+ isError: isErrorGroupedByRowData,
+ refetch: fetchGroupedByRowData,
+ } = useGetK8sDaemonSetsList(
+ fetchGroupedByRowDataQuery as K8sDaemonSetsListPayload,
+ {
+ queryKey: ['daemonSetList', fetchGroupedByRowDataQuery],
+ enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData,
+ },
+ );
+
+ const {
+ data: groupByFiltersData,
+ isLoading: isLoadingGroupByFilters,
+ } = useGetAggregateKeys(
+ {
+ dataSource: currentQuery.builder.queryData[0].dataSource,
+ aggregateAttribute:
+ K8sEntityToAggregateAttributeMapping[K8sCategory.DAEMONSETS],
+ aggregateOperator: 'noop',
+ searchText: '',
+ tagType: '',
+ },
+ {
+ queryKey: [currentQuery.builder.queryData[0].dataSource, 'noop'],
+ },
+ true,
+ K8sCategory.DAEMONSETS,
+ );
+
+ const query = useMemo(() => {
+ const baseQuery = getK8sDaemonSetsListQuery();
+ const queryPayload = {
+ ...baseQuery,
+ limit: pageSize,
+ offset: (currentPage - 1) * pageSize,
+ filters: queryFilters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ if (groupBy.length > 0) {
+ queryPayload.groupBy = groupBy;
+ }
+ return queryPayload;
+ }, [currentPage, minTime, maxTime, orderBy, groupBy, queryFilters]);
+
+ const formattedGroupedByDaemonSetsData = useMemo(
+ () =>
+ formatDataForTable(groupedByRowData?.payload?.data?.records || [], groupBy),
+ [groupedByRowData, groupBy],
+ );
+
+ const { data, isFetching, isLoading, isError } = useGetK8sDaemonSetsList(
+ query as K8sDaemonSetsListPayload,
+ {
+ queryKey: ['daemonSetList', query],
+ enabled: !!query,
+ },
+ );
+
+ const daemonSetsData = useMemo(() => data?.payload?.data?.records || [], [
+ data,
+ ]);
+ const totalCount = data?.payload?.data?.total || 0;
+
+ const formattedDaemonSetsData = useMemo(
+ () => formatDataForTable(daemonSetsData, groupBy),
+ [daemonSetsData, groupBy],
+ );
+
+ const columns = useMemo(() => getK8sDaemonSetsListColumns(groupBy), [groupBy]);
+
+ const handleGroupByRowClick = (record: K8sDaemonSetsRowData): void => {
+ setSelectedRowData(record);
+
+ if (expandedRowKeys.includes(record.key)) {
+ setExpandedRowKeys(expandedRowKeys.filter((key) => key !== record.key));
+ } else {
+ setExpandedRowKeys([record.key]);
+ }
+ };
+
+ useEffect(() => {
+ if (selectedRowData) {
+ fetchGroupedByRowData();
+ }
+ }, [selectedRowData, fetchGroupedByRowData]);
+
+ const handleTableChange: TableProps<K8sDaemonSetsRowData>['onChange'] = useCallback(
+ (
+ pagination: TablePaginationConfig,
+ _filters: Record<string, (string | number | boolean)[] | null>,
+ sorter:
+ | SorterResult<K8sDaemonSetsRowData>
+ | SorterResult<K8sDaemonSetsRowData>[],
+ ): void => {
+ if (pagination.current) {
+ setCurrentPage(pagination.current);
+ }
+
+ if ('field' in sorter && sorter.order) {
+ setOrderBy({
+ columnName: sorter.field as string,
+ order: sorter.order === 'ascend' ? 'asc' : 'desc',
+ });
+ } else {
+ setOrderBy(null);
+ }
+ },
+ [],
+ );
+
+ const { handleChangeQueryData } = useQueryOperations({
+ index: 0,
+ query: currentQuery.builder.queryData[0],
+ entityVersion: '',
+ });
+
+ const handleFiltersChange = useCallback(
+ (value: IBuilderQuery['filters']): void => {
+ handleChangeQueryData('filters', value);
+ setCurrentPage(1);
+
+ logEvent('Infra Monitoring: K8s list filters applied', {
+ filters: value,
+ });
+ },
+ [handleChangeQueryData],
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: K8s list page visited', {});
+ }, []);
+
+ const selectedDaemonSetData = useMemo(() => {
+ if (!selectedDaemonSetUID) return null;
+ return (
+ daemonSetsData.find(
+ (daemonSet) => daemonSet.daemonSetName === selectedDaemonSetUID,
+ ) || null
+ );
+ }, [selectedDaemonSetUID, daemonSetsData]);
+
+ const handleRowClick = (record: K8sDaemonSetsRowData): void => {
+ if (groupBy.length === 0) {
+ setSelectedRowData(null);
+ setselectedDaemonSetUID(record.daemonsetUID);
+ } else {
+ handleGroupByRowClick(record);
+ }
+
+ logEvent('Infra Monitoring: K8s daemonSet list item clicked', {
+ daemonSetName: record.daemonsetName,
+ });
+ };
+
+ const nestedColumns = useMemo(() => getK8sDaemonSetsListColumns([]), []);
+
+ const isGroupedByAttribute = groupBy.length > 0;
+
+ const handleExpandedRowViewAllClick = (): void => {
+ if (!selectedRowData) return;
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ handleFiltersChange(filters);
+
+ setCurrentPage(1);
+ setSelectedRowData(null);
+ setGroupBy([]);
+ setOrderBy(null);
+ };
+
+ const expandedRowRender = (): JSX.Element => (
+ <div className="expanded-table-container">
+ {isErrorGroupedByRowData && (
+ <Typography>{groupedByRowData?.error || 'Something went wrong'}</Typography>
+ )}
+ {isFetchingGroupedByRowData || isLoadingGroupedByRowData ? (
+ <LoadingContainer />
+ ) : (
+ <div className="expanded-table">
+ <Table
+ columns={nestedColumns as ColumnType<K8sDaemonSetsRowData>[]}
+ dataSource={formattedGroupedByDaemonSetsData}
+ pagination={false}
+ scroll={{ x: true }}
+ tableLayout="fixed"
+ size="small"
+ loading={{
+ spinning: isFetchingGroupedByRowData || isLoadingGroupedByRowData,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ showHeader={false}
+ />
+
+ {groupedByRowData?.payload?.data?.total &&
+ groupedByRowData?.payload?.data?.total > 10 ? (
+ <div className="expanded-table-footer">
+ <Button
+ type="default"
+ size="small"
+ className="periscope-btn secondary"
+ onClick={handleExpandedRowViewAllClick}
+ >
+ View All
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ )}
+ </div>
+ );
+
+ const expandRowIconRenderer = ({
+ expanded,
+ onExpand,
+ record,
+ }: {
+ expanded: boolean;
+ onExpand: (
+ record: K8sDaemonSetsRowData,
+ e: React.MouseEvent<HTMLButtonElement>,
+ ) => void;
+ record: K8sDaemonSetsRowData;
+ }): JSX.Element | null => {
+ if (!isGroupedByAttribute) {
+ return null;
+ }
+
+ return expanded ? (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronDown size={14} />
+ </Button>
+ ) : (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronRight size={14} />
+ </Button>
+ );
+ };
+
+ const handleCloseDaemonSetDetail = (): void => {
+ setselectedDaemonSetUID(null);
+ };
+
+ const handleGroupByChange = useCallback(
+ (value: IBuilderQuery['groupBy']) => {
+ const groupBy = [];
+
+ for (let index = 0; index < value.length; index++) {
+ const element = (value[index] as unknown) as string;
+
+ const key = groupByFiltersData?.payload?.attributeKeys?.find(
+ (key) => key.key === element,
+ );
+
+ if (key) {
+ groupBy.push(key);
+ }
+ }
+
+ setCurrentPage(1);
+ setGroupBy(groupBy);
+ setExpandedRowKeys([]);
+ },
+ [groupByFiltersData],
+ );
+
+ useEffect(() => {
+ if (groupByFiltersData?.payload) {
+ setGroupByOptions(
+ groupByFiltersData?.payload?.attributeKeys?.map((filter) => ({
+ value: filter.key,
+ label: filter.key,
+ })) || [],
+ );
+ }
+ }, [groupByFiltersData]);
+
+ return (
+ <div className="k8s-list">
+ <K8sHeader
+ isFiltersVisible={isFiltersVisible}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ defaultAddedColumns={defaultAddedColumns}
+ handleFiltersChange={handleFiltersChange}
+ groupByOptions={groupByOptions}
+ isLoadingGroupByFilters={isLoadingGroupByFilters}
+ handleGroupByChange={handleGroupByChange}
+ selectedGroupBy={groupBy}
+ entity={K8sCategory.DAEMONSETS}
+ />
+ {isError && <Typography>{data?.error || 'Something went wrong'}</Typography>}
+
+ <Table
+ className={classNames('k8s-list-table', 'daemonSets-list-table', {
+ 'expanded-daemonsets-list-table': isGroupedByAttribute,
+ })}
+ dataSource={isFetching || isLoading ? [] : formattedDaemonSetsData}
+ columns={columns}
+ pagination={{
+ current: currentPage,
+ pageSize,
+ total: totalCount,
+ showSizeChanger: false,
+ hideOnSinglePage: true,
+ }}
+ scroll={{ x: true }}
+ loading={{
+ spinning: isFetching || isLoading,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ locale={{
+ emptyText:
+ isFetching || isLoading ? null : (
+ <div className="no-filtered-hosts-message-container">
+ <div className="no-filtered-hosts-message-content">
+ <img
+ src="/Icons/emptyState.svg"
+ alt="thinking-emoji"
+ className="empty-state-svg"
+ />
+
+ <Typography.Text className="no-filtered-hosts-message">
+ This query had no results. Edit your query and try again!
+ </Typography.Text>
+ </div>
+ </div>
+ ),
+ }}
+ tableLayout="fixed"
+ onChange={handleTableChange}
+ onRow={(record): { onClick: () => void; className: string } => ({
+ onClick: (): void => handleRowClick(record),
+ className: 'clickable-row',
+ })}
+ expandable={{
+ expandedRowRender: isGroupedByAttribute ? expandedRowRender : undefined,
+ expandIcon: expandRowIconRenderer,
+ expandedRowKeys,
+ }}
+ />
+
+ <DaemonSetDetails
+ daemonSet={selectedDaemonSetData}
+ isModalTimeSelection
+ onClose={handleCloseDaemonSetDetail}
+ />
+ </div>
+ );
+}
+
+export default K8sDaemonSetsList;
diff --git a/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx b/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx
new file mode 100644
index 0000000000..e7d39d81de
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/DaemonSets/utils.tsx
@@ -0,0 +1,345 @@
+import { Color } from '@signozhq/design-tokens';
+import { Tag, Tooltip } from 'antd';
+import { ColumnType } from 'antd/es/table';
+import {
+ K8sDaemonSetsData,
+ K8sDaemonSetsListPayload,
+} from 'api/infraMonitoring/getK8sDaemonSetsList';
+import { Group } from 'lucide-react';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+
+import {
+ EntityProgressBar,
+ formatBytes,
+ ValidateColumnValueWrapper,
+} from '../commonUtils';
+import { K8sCategory } from '../constants';
+import { IEntityColumn } from '../utils';
+
+export const defaultAddedColumns: IEntityColumn[] = [
+ {
+ label: 'DaemonSet Name',
+ value: 'daemonsetName',
+ id: 'daemonsetName',
+ canRemove: false,
+ },
+ {
+ label: 'Namespace Name',
+ value: 'namespaceName',
+ id: 'namespaceName',
+ canRemove: false,
+ },
+ {
+ label: 'Available',
+ value: 'available_nodes',
+ id: 'available_nodes',
+ canRemove: false,
+ },
+ {
+ label: 'Desired',
+ value: 'desired_nodes',
+ id: 'desired_nodes',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Req Usage (%)',
+ value: 'cpu_request',
+ id: 'cpu_request',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Limit Usage (%)',
+ value: 'cpu_limit',
+ id: 'cpu_limit',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Usage (cores)',
+ value: 'cpu',
+ id: 'cpu',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Req Usage (%)',
+ value: 'memory_request',
+ id: 'memory_request',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Limit Usage (%)',
+ value: 'memory_limit',
+ id: 'memory_limit',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Usage',
+ value: 'memory',
+ id: 'memory',
+ canRemove: false,
+ },
+];
+
+export interface K8sDaemonSetsRowData {
+ key: string;
+ daemonsetUID: string;
+ daemonsetName: React.ReactNode;
+ cpu_request: React.ReactNode;
+ cpu_limit: React.ReactNode;
+ cpu: React.ReactNode;
+ memory_request: React.ReactNode;
+ memory_limit: React.ReactNode;
+ memory: React.ReactNode;
+ desired_nodes: React.ReactNode;
+ available_nodes: React.ReactNode;
+ namespaceName: React.ReactNode;
+ groupedByMeta?: any;
+}
+
+const daemonSetGroupColumnConfig = {
+ title: (
+ <div className="column-header entity-group-header">
+ <Group size={14} /> DAEMONSET GROUP
+ </div>
+ ),
+ dataIndex: 'daemonSetGroup',
+ key: 'daemonSetGroup',
+ ellipsis: true,
+ width: 150,
+ align: 'left',
+ sorter: false,
+ className: 'column entity-group-header',
+};
+
+export const getK8sDaemonSetsListQuery = (): K8sDaemonSetsListPayload => ({
+ filters: {
+ items: [],
+ op: 'and',
+ },
+ orderBy: { columnName: 'cpu', order: 'desc' },
+});
+
+const columnProgressBarClassName = 'column-progress-bar';
+
+const columnsConfig = [
+ {
+ title: (
+ <div className="column-header-left daemonset-name-header">
+ DaemonSet Name
+ </div>
+ ),
+ dataIndex: 'daemonsetName',
+ key: 'daemonsetName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: (
+ <div className="column-header-left namespace-name-header">
+ Namespace Name
+ </div>
+ ),
+ dataIndex: 'namespaceName',
+ key: 'namespaceName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header small-col">Available</div>,
+ dataIndex: 'available_nodes',
+ key: 'available_nodes',
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Desired</div>,
+ dataIndex: 'desired_nodes',
+ key: 'desired_nodes',
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Req Usage (%)</div>,
+ dataIndex: 'cpu_request',
+ key: 'cpu_request',
+ width: 180,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Limit Usage (%)</div>,
+ dataIndex: 'cpu_limit',
+ key: 'cpu_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">CPU Usage (cores)</div>,
+ dataIndex: 'cpu',
+ key: 'cpu',
+ width: 80,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Req Usage (%)</div>,
+ dataIndex: 'memory_request',
+ key: 'memory_request',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Limit Usage (%)</div>,
+ dataIndex: 'memory_limit',
+ key: 'memory_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Mem Usage</div>,
+ dataIndex: 'memory',
+ key: 'memory',
+ width: 80,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+];
+
+export const getK8sDaemonSetsListColumns = (
+ groupBy: IBuilderQuery['groupBy'],
+): ColumnType<K8sDaemonSetsRowData>[] => {
+ if (groupBy.length > 0) {
+ const filteredColumns = [...columnsConfig].filter(
+ (column) => column.key !== 'daemonsetName',
+ );
+ filteredColumns.unshift(daemonSetGroupColumnConfig);
+ return filteredColumns as ColumnType<K8sDaemonSetsRowData>[];
+ }
+
+ return columnsConfig as ColumnType<K8sDaemonSetsRowData>[];
+};
+
+const getGroupByEle = (
+ daemonSet: K8sDaemonSetsData,
+ groupBy: IBuilderQuery['groupBy'],
+): React.ReactNode => {
+ const groupByValues: string[] = [];
+
+ groupBy.forEach((group) => {
+ groupByValues.push(daemonSet.meta[group.key as keyof typeof daemonSet.meta]);
+ });
+
+ return (
+ <div className="pod-group">
+ {groupByValues.map((value) => (
+ <Tag key={value} color={Color.BG_SLATE_400} className="pod-group-tag-item">
+ {value === '' ? '<no-value>' : value}
+ </Tag>
+ ))}
+ </div>
+ );
+};
+
+export const formatDataForTable = (
+ data: K8sDaemonSetsData[],
+ groupBy: IBuilderQuery['groupBy'],
+): K8sDaemonSetsRowData[] =>
+ data.map((daemonSet, index) => ({
+ key: index.toString(),
+ daemonsetUID: daemonSet.daemonSetName,
+ daemonsetName: (
+ <Tooltip title={daemonSet.meta.k8s_daemonset_name}>
+ {daemonSet.meta.k8s_daemonset_name || ''}
+ </Tooltip>
+ ),
+ namespaceName: (
+ <Tooltip title={daemonSet.meta.k8s_namespace_name}>
+ {daemonSet.meta.k8s_namespace_name || ''}
+ </Tooltip>
+ ),
+ cpu_request: (
+ <ValidateColumnValueWrapper
+ value={daemonSet.cpuRequest}
+ entity={K8sCategory.DAEMONSETS}
+ attribute="CPU Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={daemonSet.cpuRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu_limit: (
+ <ValidateColumnValueWrapper
+ value={daemonSet.cpuLimit}
+ entity={K8sCategory.DAEMONSETS}
+ attribute="CPU Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={daemonSet.cpuLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu: (
+ <ValidateColumnValueWrapper value={daemonSet.cpuUsage}>
+ {daemonSet.cpuUsage}
+ </ValidateColumnValueWrapper>
+ ),
+ memory_request: (
+ <ValidateColumnValueWrapper
+ value={daemonSet.memoryRequest}
+ entity={K8sCategory.DAEMONSETS}
+ attribute="Memory Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={daemonSet.memoryRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory_limit: (
+ <ValidateColumnValueWrapper
+ value={daemonSet.memoryLimit}
+ entity={K8sCategory.DAEMONSETS}
+ attribute="Memory Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={daemonSet.memoryLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory: (
+ <ValidateColumnValueWrapper value={daemonSet.memoryUsage}>
+ {formatBytes(daemonSet.memoryUsage)}
+ </ValidateColumnValueWrapper>
+ ),
+ available_nodes: (
+ <ValidateColumnValueWrapper value={daemonSet.availableNodes}>
+ {daemonSet.availableNodes}
+ </ValidateColumnValueWrapper>
+ ),
+ desired_nodes: (
+ <ValidateColumnValueWrapper value={daemonSet.desiredNodes}>
+ {daemonSet.desiredNodes}
+ </ValidateColumnValueWrapper>
+ ),
+ daemonSetGroup: getGroupByEle(daemonSet, groupBy),
+ meta: daemonSet.meta,
+ ...daemonSet.meta,
+ groupedByMeta: daemonSet.meta,
+ }));
diff --git a/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx
index 28e8ab79cc..779b9b4bf5 100644
--- a/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx
+++ b/frontend/src/container/InfraMonitoringK8s/Deployments/utils.tsx
@@ -30,14 +30,14 @@ export const defaultAddedColumns: IEntityColumn[] = [
},
{
label: 'Available',
- value: 'available',
- id: 'available',
+ value: 'available_pods',
+ id: 'available_pods',
canRemove: false,
},
{
label: 'Desired',
- value: 'desired',
- id: 'desired',
+ value: 'desired_pods',
+ id: 'desired_pods',
canRemove: false,
},
{
@@ -82,8 +82,8 @@ export interface K8sDeploymentsRowData {
key: string;
deploymentUID: string;
deploymentName: React.ReactNode;
- availableReplicas: React.ReactNode;
- desiredReplicas: React.ReactNode;
+ available_pods: React.ReactNode;
+ desired_pods: React.ReactNode;
cpu_request: React.ReactNode;
cpu_limit: React.ReactNode;
cpu: React.ReactNode;
@@ -148,16 +148,16 @@ const columnsConfig = [
},
{
title: <div className="column-header-left small-col">Available</div>,
- dataIndex: 'availableReplicas',
- key: 'availableReplicas',
+ dataIndex: 'available_pods',
+ key: 'available_pods',
width: 100,
sorter: false,
align: 'left',
},
{
title: <div className="column-header-left small-col">Desired</div>,
- dataIndex: 'desiredReplicas',
- key: 'desiredReplicas',
+ dataIndex: 'desired_pods',
+ key: 'desired_pods',
width: 80,
sorter: false,
align: 'left',
@@ -261,12 +261,12 @@ export const formatDataForTable = (
{deployment.meta.k8s_deployment_name}
</Tooltip>
),
- availableReplicas: (
+ available_pods: (
<ValidateColumnValueWrapper value={deployment.availablePods}>
{deployment.availablePods}
</ValidateColumnValueWrapper>
),
- desiredReplicas: (
+ desired_pods: (
<ValidateColumnValueWrapper value={deployment.desiredPods}>
{deployment.desiredPods}
</ValidateColumnValueWrapper>
diff --git a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/entityDetails.styles.scss b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/entityDetails.styles.scss
index 1fd8c08dab..ff91dffd3d 100644
--- a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/entityDetails.styles.scss
+++ b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/entityDetails.styles.scss
@@ -49,7 +49,7 @@
.labels-row,
.values-row {
display: grid;
- grid-template-columns: 1fr 1.5fr 1.5fr 1.5fr;
+ grid-template-columns: 1.5fr 1.5fr 1.5fr 1.5fr;
gap: 30px;
align-items: center;
}
diff --git a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/utils.tsx b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/utils.tsx
index 68c696d586..9b920832f1 100644
--- a/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/utils.tsx
+++ b/frontend/src/container/InfraMonitoringK8s/EntityDetailsUtils/utils.tsx
@@ -23,6 +23,9 @@ export const QUERY_KEYS = {
K8S_CLUSTER_NAME: 'k8s.cluster.name',
K8S_NODE_NAME: 'k8s.node.name',
K8S_DEPLOYMENT_NAME: 'k8s.deployment.name',
+ K8S_STATEFUL_SET_NAME: 'k8s.statefulset.name',
+ K8S_JOB_NAME: 'k8s.job.name',
+ K8S_DAEMON_SET_NAME: 'k8s.daemonset.name',
};
/**
diff --git a/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx b/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx
index 5ba6995673..2e99fdb4dd 100644
--- a/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx
+++ b/frontend/src/container/InfraMonitoringK8s/InfraMonitoringK8s.tsx
@@ -8,10 +8,14 @@ import QuickFilters from 'components/QuickFilters/QuickFilters';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
import {
+ ArrowUpDown,
+ Bolt,
Boxes,
Computer,
Container,
FilePenLine,
+ Group,
+ HardDrive,
Workflow,
} from 'lucide-react';
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
@@ -21,16 +25,24 @@ import { Query } from 'types/api/queryBuilder/queryBuilderData';
import K8sClustersList from './Clusters/K8sClustersList';
import {
ClustersQuickFiltersConfig,
+ DaemonSetsQuickFiltersConfig,
DeploymentsQuickFiltersConfig,
+ JobsQuickFiltersConfig,
K8sCategories,
NamespaceQuickFiltersConfig,
NodesQuickFiltersConfig,
PodsQuickFiltersConfig,
+ StatefulsetsQuickFiltersConfig,
+ VolumesQuickFiltersConfig,
} from './constants';
+import K8sDaemonSetsList from './DaemonSets/K8sDaemonSetsList';
import K8sDeploymentsList from './Deployments/K8sDeploymentsList';
+import K8sJobsList from './Jobs/K8sJobsList';
import K8sNamespacesList from './Namespaces/K8sNamespacesList';
import K8sNodesList from './Nodes/K8sNodesList';
import K8sPodLists from './Pods/K8sPodLists';
+import K8sStatefulSetsList from './StatefulSets/K8sStatefulSetsList';
+import K8sVolumesList from './Volumes/K8sVolumesList';
export default function InfraMonitoringK8s(): JSX.Element {
const [showFilters, setShowFilters] = useState(true);
@@ -98,7 +110,6 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
),
},
- // NOTE - Enabled these as we release new entities
{
label: (
<div className="k8s-quick-filters-category-label">
@@ -142,49 +153,6 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
),
},
- // {
- // label: (
- // <div className="k8s-quick-filters-category-label">
- // <div className="k8s-quick-filters-category-label-container">
- // <PackageOpen
- // size={14}
- // className="k8s-quick-filters-category-label-icon"
- // />
- // <Typography.Text>Containers</Typography.Text>
- // </div>
- // </div>
- // ),
- // key: K8sCategories.CONTAINERS,
- // showArrow: false,
- // children: (
- // <QuickFilters
- // source="infra-monitoring"
- // config={ContainersQuickFiltersConfig}
- // handleFilterVisibilityChange={handleFilterVisibilityChange}
- // onFilterChange={handleFilterChange}
- // />
- // ),
- // },
- // {
- // label: (
- // <div className="k8s-quick-filters-category-label">
- // <div className="k8s-quick-filters-category-label-container">
- // <HardDrive size={14} className="k8s-quick-filters-category-label-icon" />
- // <Typography.Text>Volumes</Typography.Text>
- // </div>
- // </div>
- // ),
- // key: K8sCategories.VOLUMES,
- // showArrow: false,
- // children: (
- // <QuickFilters
- // source="infra-monitoring"
- // config={VolumesQuickFiltersConfig}
- // handleFilterVisibilityChange={handleFilterVisibilityChange}
- // onFilterChange={handleFilterChange}
- // />
- // ),
- // },
{
label: (
<div className="k8s-quick-filters-category-label">
@@ -205,64 +173,108 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
),
},
+ {
+ label: (
+ <div className="k8s-quick-filters-category-label">
+ <div className="k8s-quick-filters-category-label-container">
+ <Bolt size={14} className="k8s-quick-filters-category-label-icon" />
+ <Typography.Text>Jobs</Typography.Text>
+ </div>
+ </div>
+ ),
+ key: K8sCategories.JOBS,
+ showArrow: false,
+ children: (
+ <QuickFilters
+ source="infra-monitoring"
+ config={JobsQuickFiltersConfig}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ onFilterChange={handleFilterChange}
+ />
+ ),
+ },
+ {
+ label: (
+ <div className="k8s-quick-filters-category-label">
+ <div className="k8s-quick-filters-category-label-container">
+ <Group size={14} className="k8s-quick-filters-category-label-icon" />
+ <Typography.Text>DaemonSets</Typography.Text>
+ </div>
+ </div>
+ ),
+ key: K8sCategories.DAEMONSETS,
+ showArrow: false,
+ children: (
+ <QuickFilters
+ source="infra-monitoring"
+ config={DaemonSetsQuickFiltersConfig}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ onFilterChange={handleFilterChange}
+ />
+ ),
+ },
+ {
+ label: (
+ <div className="k8s-quick-filters-category-label">
+ <div className="k8s-quick-filters-category-label-container">
+ <ArrowUpDown
+ size={14}
+ className="k8s-quick-filters-category-label-icon"
+ />
+ <Typography.Text>StatefulSets</Typography.Text>
+ </div>
+ </div>
+ ),
+ key: K8sCategories.STATEFULSETS,
+ showArrow: false,
+ children: (
+ <QuickFilters
+ source="infra-monitoring"
+ config={StatefulsetsQuickFiltersConfig}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ onFilterChange={handleFilterChange}
+ />
+ ),
+ },
+ {
+ label: (
+ <div className="k8s-quick-filters-category-label">
+ <div className="k8s-quick-filters-category-label-container">
+ <HardDrive size={14} className="k8s-quick-filters-category-label-icon" />
+ <Typography.Text>Volumes</Typography.Text>
+ </div>
+ </div>
+ ),
+ key: K8sCategories.VOLUMES,
+ showArrow: false,
+ children: (
+ <QuickFilters
+ source="infra-monitoring"
+ config={VolumesQuickFiltersConfig}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ onFilterChange={handleFilterChange}
+ />
+ ),
+ },
+ // TODO: Enable once we have implemented containers.
// {
// label: (
// <div className="k8s-quick-filters-category-label">
// <div className="k8s-quick-filters-category-label-container">
- // <Bolt size={14} className="k8s-quick-filters-category-label-icon" />
- // <Typography.Text>Jobs</Typography.Text>
- // </div>
- // </div>
- // ),
- // key: K8sCategories.JOBS,
- // showArrow: false,
- // children: (
- // <QuickFilters
- // source="infra-monitoring"
- // config={JobsQuickFiltersConfig}
- // handleFilterVisibilityChange={handleFilterVisibilityChange}
- // onFilterChange={handleFilterChange}
- // />
- // ),
- // },
- // {
- // label: (
- // <div className="k8s-quick-filters-category-label">
- // <div className="k8s-quick-filters-category-label-container">
- // <Group size={14} className="k8s-quick-filters-category-label-icon" />
- // <Typography.Text>DaemonSets</Typography.Text>
- // </div>
- // </div>
- // ),
- // key: K8sCategories.DAEMONSETS,
- // showArrow: false,
- // children: (
- // <QuickFilters
- // source="infra-monitoring"
- // config={DaemonSetsQuickFiltersConfig}
- // handleFilterVisibilityChange={handleFilterVisibilityChange}
- // onFilterChange={handleFilterChange}
- // />
- // ),
- // },
- // {
- // label: (
- // <div className="k8s-quick-filters-category-label">
- // <div className="k8s-quick-filters-category-label-container">
- // <ArrowUpDown
+ // <PackageOpen
// size={14}
// className="k8s-quick-filters-category-label-icon"
// />
- // <Typography.Text>StatefulSets</Typography.Text>
+ // <Typography.Text>Containers</Typography.Text>
// </div>
// </div>
// ),
- // key: K8sCategories.STATEFULSETS,
+ // key: K8sCategories.CONTAINERS,
// showArrow: false,
// children: (
// <QuickFilters
// source="infra-monitoring"
- // config={StatefulsetsQuickFiltersConfig}
+ // config={ContainersQuickFiltersConfig}
// handleFilterVisibilityChange={handleFilterVisibilityChange}
// onFilterChange={handleFilterChange}
// />
@@ -327,6 +339,14 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
)}
+ {selectedCategory === K8sCategories.CLUSTERS && (
+ <K8sClustersList
+ isFiltersVisible={showFilters}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ quickFiltersLastUpdated={quickFiltersLastUpdated}
+ />
+ )}
+
{selectedCategory === K8sCategories.DEPLOYMENTS && (
<K8sDeploymentsList
isFiltersVisible={showFilters}
@@ -343,8 +363,32 @@ export default function InfraMonitoringK8s(): JSX.Element {
/>
)}
- {selectedCategory === K8sCategories.CLUSTERS && (
- <K8sClustersList
+ {selectedCategory === K8sCategories.STATEFULSETS && (
+ <K8sStatefulSetsList
+ isFiltersVisible={showFilters}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ quickFiltersLastUpdated={quickFiltersLastUpdated}
+ />
+ )}
+
+ {selectedCategory === K8sCategories.JOBS && (
+ <K8sJobsList
+ isFiltersVisible={showFilters}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ quickFiltersLastUpdated={quickFiltersLastUpdated}
+ />
+ )}
+
+ {selectedCategory === K8sCategories.DAEMONSETS && (
+ <K8sDaemonSetsList
+ isFiltersVisible={showFilters}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ quickFiltersLastUpdated={quickFiltersLastUpdated}
+ />
+ )}
+
+ {selectedCategory === K8sCategories.VOLUMES && (
+ <K8sVolumesList
isFiltersVisible={showFilters}
handleFilterVisibilityChange={handleFilterVisibilityChange}
quickFiltersLastUpdated={quickFiltersLastUpdated}
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.interfaces.ts b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.interfaces.ts
new file mode 100644
index 0000000000..c86821258f
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.interfaces.ts
@@ -0,0 +1,7 @@
+import { K8sJobsData } from 'api/infraMonitoring/getK8sJobsList';
+
+export type JobDetailsProps = {
+ job: K8sJobsData | null;
+ isModalTimeSelection: boolean;
+ onClose: () => void;
+};
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.tsx b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.tsx
new file mode 100644
index 0000000000..22e71d7354
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/JobDetails.tsx
@@ -0,0 +1,573 @@
+/* eslint-disable sonarjs/no-identical-functions */
+import '../../EntityDetailsUtils/entityDetails.styles.scss';
+
+import { Color, Spacing } from '@signozhq/design-tokens';
+import { Button, Divider, Drawer, Radio, Tooltip, Typography } from 'antd';
+import { RadioChangeEvent } from 'antd/lib';
+import logEvent from 'api/common/logEvent';
+import { VIEW_TYPES, VIEWS } from 'components/HostMetricsDetail/constants';
+import { QueryParams } from 'constants/query';
+import {
+ initialQueryBuilderFormValuesMap,
+ initialQueryState,
+} from 'constants/queryBuilder';
+import ROUTES from 'constants/routes';
+import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
+import {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/config';
+import { useIsDarkMode } from 'hooks/useDarkMode';
+import useUrlQuery from 'hooks/useUrlQuery';
+import GetMinMax from 'lib/getMinMax';
+import {
+ BarChart2,
+ ChevronsLeftRight,
+ Compass,
+ DraftingCompass,
+ ScrollText,
+ X,
+} from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import {
+ IBuilderQuery,
+ TagFilterItem,
+} from 'types/api/queryBuilder/queryBuilderData';
+import {
+ LogsAggregatorOperator,
+ TracesAggregatorOperator,
+} from 'types/common/queryBuilder';
+import { GlobalReducer } from 'types/reducer/globalTime';
+import { v4 as uuidv4 } from 'uuid';
+
+import JobEvents from '../../EntityDetailsUtils/EntityEvents';
+import JobLogs from '../../EntityDetailsUtils/EntityLogs';
+import JobMetrics from '../../EntityDetailsUtils/EntityMetrics';
+import JobTraces from '../../EntityDetailsUtils/EntityTraces';
+import { QUERY_KEYS } from '../../EntityDetailsUtils/utils';
+import { getJobMetricsQueryPayload, jobWidgetInfo } from './constants';
+import { JobDetailsProps } from './JobDetails.interfaces';
+
+function JobDetails({
+ job,
+ onClose,
+ isModalTimeSelection,
+}: JobDetailsProps): JSX.Element {
+ const { maxTime, minTime, selectedTime } = useSelector<
+ AppState,
+ GlobalReducer
+ >((state) => state.globalTime);
+
+ const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
+ minTime,
+ ]);
+ const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
+ maxTime,
+ ]);
+
+ const urlQuery = useUrlQuery();
+
+ const [modalTimeRange, setModalTimeRange] = useState(() => ({
+ startTime: startMs,
+ endTime: endMs,
+ }));
+
+ const [selectedInterval, setSelectedInterval] = useState<Time>(
+ selectedTime as Time,
+ );
+
+ const [selectedView, setSelectedView] = useState<VIEWS>(VIEWS.METRICS);
+ const isDarkMode = useIsDarkMode();
+
+ const initialFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_JOB_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_job_name--string--resource--false',
+ },
+ op: '=',
+ value: job?.meta.k8s_job_name || '',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_NAMESPACE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_job_name--string--resource--false',
+ },
+ op: '=',
+ value: job?.meta.k8s_namespace_name || '',
+ },
+ ],
+ }),
+ [job?.meta.k8s_job_name, job?.meta.k8s_namespace_name],
+ );
+
+ const initialEventsFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_KIND,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.kind--string--resource--false',
+ },
+ op: '=',
+ value: 'Job',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.name--string--resource--false',
+ },
+ op: '=',
+ value: job?.meta.k8s_job_name || '',
+ },
+ ],
+ }),
+ [job?.meta.k8s_job_name],
+ );
+
+ const [logFilters, setLogFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [tracesFilters, setTracesFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [eventsFilters, setEventsFilters] = useState<IBuilderQuery['filters']>(
+ initialEventsFilters,
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: Jobs list details page visited', {
+ job: job?.jobName,
+ });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ setLogFilters(initialFilters);
+ setTracesFilters(initialFilters);
+ setEventsFilters(initialEventsFilters);
+ }, [initialFilters, initialEventsFilters]);
+
+ useEffect(() => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ }, [selectedTime, minTime, maxTime]);
+
+ const handleTabChange = (e: RadioChangeEvent): void => {
+ setSelectedView(e.target.value);
+ };
+
+ const handleTimeChange = useCallback(
+ (interval: Time | CustomTimeType, dateTimeRange?: [number, number]): void => {
+ setSelectedInterval(interval as Time);
+
+ if (interval === 'custom' && dateTimeRange) {
+ setModalTimeRange({
+ startTime: Math.floor(dateTimeRange[0] / 1000),
+ endTime: Math.floor(dateTimeRange[1] / 1000),
+ });
+ } else {
+ const { maxTime, minTime } = GetMinMax(interval);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+
+ logEvent('Infra Monitoring: Jobs list details time updated', {
+ job: job?.jobName,
+ interval,
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeLogFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setLogFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_STATEFUL_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+ const paginationFilter = value.items.find((item) => item.key?.key === 'id');
+ const newFilters = value.items.filter(
+ (item) =>
+ item.key?.key !== 'id' &&
+ item.key?.key !== QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ );
+
+ logEvent('Infra Monitoring: Jobs list details logs filters applied', {
+ job: job?.jobName,
+ });
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...newFilters,
+ ...(paginationFilter ? [paginationFilter] : []),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeTracesFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setTracesFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_STATEFUL_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+
+ logEvent('Infra Monitoring: Jobs list details traces filters applied', {
+ job: job?.jobName,
+ });
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...value.items.filter(
+ (item) => item.key?.key !== QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeEventsFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setEventsFilters((prevFilters) => {
+ const jobKindFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_KIND,
+ );
+ const jobNameFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_NAME,
+ );
+
+ logEvent('Infra Monitoring: Jobs list details events filters applied', {
+ job: job?.jobName,
+ });
+
+ return {
+ op: 'AND',
+ items: [
+ jobKindFilter,
+ jobNameFilter,
+ ...value.items.filter(
+ (item) =>
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_KIND &&
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleExplorePagesRedirect = (): void => {
+ if (selectedInterval !== 'custom') {
+ urlQuery.set(QueryParams.relativeTime, selectedInterval);
+ } else {
+ urlQuery.delete(QueryParams.relativeTime);
+ urlQuery.set(QueryParams.startTime, modalTimeRange.startTime.toString());
+ urlQuery.set(QueryParams.endTime, modalTimeRange.endTime.toString());
+ }
+
+ logEvent('Infra Monitoring: Jobs list details explore clicked', {
+ job: job?.jobName,
+ view: selectedView,
+ });
+
+ if (selectedView === VIEW_TYPES.LOGS) {
+ const filtersWithoutPagination = {
+ ...logFilters,
+ items: logFilters.items.filter((item) => item.key?.key !== 'id'),
+ };
+
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.logs,
+ aggregateOperator: LogsAggregatorOperator.NOOP,
+ filters: filtersWithoutPagination,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.LOGS_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ } else if (selectedView === VIEW_TYPES.TRACES) {
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.traces,
+ aggregateOperator: TracesAggregatorOperator.NOOP,
+ filters: tracesFilters,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.TRACES_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ }
+ };
+
+ const handleClose = (): void => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ setSelectedView(VIEW_TYPES.METRICS);
+ onClose();
+ };
+
+ return (
+ <Drawer
+ width="70%"
+ title={
+ <>
+ <Divider type="vertical" />
+ <Typography.Text className="title">
+ {job?.meta.k8s_job_name}
+ </Typography.Text>
+ </>
+ }
+ placement="right"
+ onClose={handleClose}
+ open={!!job}
+ style={{
+ overscrollBehavior: 'contain',
+ background: isDarkMode ? Color.BG_INK_400 : Color.BG_VANILLA_100,
+ }}
+ className="entity-detail-drawer"
+ destroyOnClose
+ closeIcon={<X size={16} style={{ marginTop: Spacing.MARGIN_1 }} />}
+ >
+ {job && (
+ <>
+ <div className="entity-detail-drawer__entity">
+ <div className="entity-details-grid">
+ <div className="labels-row">
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Job Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Namespace Name
+ </Typography.Text>
+ </div>
+ <div className="values-row">
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={job.meta.k8s_job_name}>
+ {job.meta.k8s_job_name}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={job.meta.k8s_namespace_name}>
+ {job.meta.k8s_namespace_name}
+ </Tooltip>
+ </Typography.Text>
+ </div>
+ </div>
+ </div>
+
+ <div className="views-tabs-container">
+ <Radio.Group
+ className="views-tabs"
+ onChange={handleTabChange}
+ value={selectedView}
+ >
+ <Radio.Button
+ className={
+ // eslint-disable-next-line sonarjs/no-duplicate-string
+ selectedView === VIEW_TYPES.METRICS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.METRICS}
+ >
+ <div className="view-title">
+ <BarChart2 size={14} />
+ Metrics
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.LOGS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.LOGS}
+ >
+ <div className="view-title">
+ <ScrollText size={14} />
+ Logs
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.TRACES ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.TRACES}
+ >
+ <div className="view-title">
+ <DraftingCompass size={14} />
+ Traces
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.EVENTS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.EVENTS}
+ >
+ <div className="view-title">
+ <ChevronsLeftRight size={14} />
+ Events
+ </div>
+ </Radio.Button>
+ </Radio.Group>
+
+ {(selectedView === VIEW_TYPES.LOGS ||
+ selectedView === VIEW_TYPES.TRACES) && (
+ <Button
+ icon={<Compass size={18} />}
+ className="compass-button"
+ onClick={handleExplorePagesRedirect}
+ />
+ )}
+ </div>
+ {selectedView === VIEW_TYPES.METRICS && (
+ <JobMetrics
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ entity={job}
+ category={K8sCategory.JOBS}
+ queryKey="jobMetrics"
+ entityWidgetInfo={jobWidgetInfo}
+ getEntityQueryPayload={getJobMetricsQueryPayload}
+ />
+ )}
+ {selectedView === VIEW_TYPES.LOGS && (
+ <JobLogs
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeLogFilters={handleChangeLogFilters}
+ logFilters={logFilters}
+ selectedInterval={selectedInterval}
+ category={K8sCategory.JOBS}
+ queryKey="jobLogs"
+ queryKeyFilters={[
+ QUERY_KEYS.K8S_JOB_NAME,
+ QUERY_KEYS.K8S_NAMESPACE_NAME,
+ ]}
+ />
+ )}
+ {selectedView === VIEW_TYPES.TRACES && (
+ <JobTraces
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeTracesFilters={handleChangeTracesFilters}
+ tracesFilters={tracesFilters}
+ selectedInterval={selectedInterval}
+ queryKey="jobTraces"
+ />
+ )}
+ {selectedView === VIEW_TYPES.EVENTS && (
+ <JobEvents
+ timeRange={modalTimeRange}
+ handleChangeEventFilters={handleChangeEventsFilters}
+ filters={eventsFilters}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ category={K8sCategory.JOBS}
+ queryKey="jobEvents"
+ />
+ )}
+ </>
+ )}
+ </Drawer>
+ );
+}
+
+export default JobDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts
new file mode 100644
index 0000000000..e7ea02246d
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/constants.ts
@@ -0,0 +1,424 @@
+/* eslint-disable sonarjs/no-duplicate-string */
+import { K8sJobsData } from 'api/infraMonitoring/getK8sJobsList';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { EQueryType } from 'types/common/dashboard';
+import { DataSource } from 'types/common/queryBuilder';
+import { v4 } from 'uuid';
+
+export const jobWidgetInfo = [
+ {
+ title: 'CPU usage',
+ yAxisUnit: '',
+ },
+ {
+ title: 'Memory usage, request, limits',
+ yAxisUnit: 'bytes',
+ },
+ {
+ title: 'Network IO',
+ yAxisUnit: 'binBps',
+ },
+ {
+ title: 'Network errors count',
+ yAxisUnit: '',
+ },
+];
+
+export const getJobMetricsQueryPayload = (
+ job: K8sJobsData,
+ start: number,
+ end: number,
+): GetQueryResultsProps[] => [
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_cpu_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6b59b690',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_job_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_job_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.jobName,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_memory_usage--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_memory_usage',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '8c217f4d',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_job_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_job_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.jobName,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_io--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_io',
+ type: 'Sum',
+ },
+ aggregateOperator: 'rate',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '2bbf9d0c',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_job_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_job_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.jobName,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'rate',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_errors--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_errors',
+ type: 'Sum',
+ },
+ aggregateOperator: 'increase',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '448e6cf7',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_job_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_job_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.jobName,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: job.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'increase',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/index.ts b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/index.ts
new file mode 100644
index 0000000000..0ddd657f88
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/JobDetails/index.ts
@@ -0,0 +1,3 @@
+import JobDetails from './JobDetails';
+
+export default JobDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.styles.scss b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.styles.scss
new file mode 100644
index 0000000000..f419db915c
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.styles.scss
@@ -0,0 +1,62 @@
+.infra-monitoring-container {
+ .jobs-list-table {
+ .expanded-table-container {
+ padding-left: 40px;
+ }
+
+ .ant-table-cell.column-progress-bar {
+ min-width: 180px;
+ max-width: 180px;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+
+ .progress-container {
+ display: flex;
+ justify-content: start;
+ }
+ }
+}
+
+.ant-table-cell {
+ &:has(.job-name-header) {
+ min-width: 250px !important;
+ max-width: 250px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.namespace-name-header) {
+ min-width: 220px !important;
+ max-width: 220px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.med-col) {
+ min-width: 200px !important;
+ max-width: 200px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.small-col) {
+ min-width: 120px !important;
+ max-width: 120px !important;
+ }
+}
+
+.expanded-jobs-list-table {
+ .ant-table-cell {
+ min-width: 200px !important;
+ max-width: 200px !important;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+}
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx
new file mode 100644
index 0000000000..98a3a23caa
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/K8sJobsList.tsx
@@ -0,0 +1,501 @@
+/* eslint-disable no-restricted-syntax */
+/* eslint-disable @typescript-eslint/explicit-function-return-type */
+import '../InfraMonitoringK8s.styles.scss';
+import './K8sJobsList.styles.scss';
+
+import { LoadingOutlined } from '@ant-design/icons';
+import {
+ Button,
+ Spin,
+ Table,
+ TablePaginationConfig,
+ TableProps,
+ Typography,
+} from 'antd';
+import { ColumnType, SorterResult } from 'antd/es/table/interface';
+import logEvent from 'api/common/logEvent';
+import { K8sJobsListPayload } from 'api/infraMonitoring/getK8sJobsList';
+import classNames from 'classnames';
+import { useGetK8sJobsList } from 'hooks/infraMonitoring/useGetK8sJobsList';
+import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+import {
+ K8sCategory,
+ K8sEntityToAggregateAttributeMapping,
+} from '../constants';
+import K8sHeader from '../K8sHeader';
+import LoadingContainer from '../LoadingContainer';
+import JobDetails from './JobDetails';
+import {
+ defaultAddedColumns,
+ formatDataForTable,
+ getK8sJobsListColumns,
+ getK8sJobsListQuery,
+ K8sJobsRowData,
+} from './utils';
+
+// eslint-disable-next-line sonarjs/cognitive-complexity
+function K8sJobsList({
+ isFiltersVisible,
+ handleFilterVisibilityChange,
+ quickFiltersLastUpdated,
+}: {
+ isFiltersVisible: boolean;
+ handleFilterVisibilityChange: () => void;
+ quickFiltersLastUpdated: number;
+}): JSX.Element {
+ const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
+ (state) => state.globalTime,
+ );
+
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]);
+
+ const [orderBy, setOrderBy] = useState<{
+ columnName: string;
+ order: 'asc' | 'desc';
+ } | null>(null);
+
+ const [selectedJobUID, setselectedJobUID] = useState<string | null>(null);
+
+ const pageSize = 10;
+
+ const [groupBy, setGroupBy] = useState<IBuilderQuery['groupBy']>([]);
+
+ const [selectedRowData, setSelectedRowData] = useState<K8sJobsRowData | null>(
+ null,
+ );
+
+ const [groupByOptions, setGroupByOptions] = useState<
+ { value: string; label: string }[]
+ >([]);
+
+ const { currentQuery } = useQueryBuilder();
+
+ const queryFilters = useMemo(
+ () =>
+ currentQuery?.builder?.queryData[0]?.filters || {
+ items: [],
+ op: 'and',
+ },
+ [currentQuery?.builder?.queryData],
+ );
+
+ // Reset pagination every time quick filters are changed
+ useEffect(() => {
+ setCurrentPage(1);
+ }, [quickFiltersLastUpdated]);
+
+ const createFiltersForSelectedRowData = (
+ selectedRowData: K8sJobsRowData,
+ groupBy: IBuilderQuery['groupBy'],
+ ): IBuilderQuery['filters'] => {
+ const baseFilters: IBuilderQuery['filters'] = {
+ items: [...queryFilters.items],
+ op: 'and',
+ };
+
+ if (!selectedRowData) return baseFilters;
+
+ const { groupedByMeta } = selectedRowData;
+
+ for (const key of groupBy) {
+ baseFilters.items.push({
+ key: {
+ key: key.key,
+ type: null,
+ },
+ op: '=',
+ value: groupedByMeta[key.key],
+ id: key.key,
+ });
+ }
+
+ return baseFilters;
+ };
+
+ const fetchGroupedByRowDataQuery = useMemo(() => {
+ if (!selectedRowData) return null;
+
+ const baseQuery = getK8sJobsListQuery();
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ return {
+ ...baseQuery,
+ limit: 10,
+ offset: 0,
+ filters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [minTime, maxTime, orderBy, selectedRowData, groupBy]);
+
+ const {
+ data: groupedByRowData,
+ isFetching: isFetchingGroupedByRowData,
+ isLoading: isLoadingGroupedByRowData,
+ isError: isErrorGroupedByRowData,
+ refetch: fetchGroupedByRowData,
+ } = useGetK8sJobsList(fetchGroupedByRowDataQuery as K8sJobsListPayload, {
+ queryKey: ['jobList', fetchGroupedByRowDataQuery],
+ enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData,
+ });
+
+ const {
+ data: groupByFiltersData,
+ isLoading: isLoadingGroupByFilters,
+ } = useGetAggregateKeys(
+ {
+ dataSource: currentQuery.builder.queryData[0].dataSource,
+ aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.JOBS],
+ aggregateOperator: 'noop',
+ searchText: '',
+ tagType: '',
+ },
+ {
+ queryKey: [currentQuery.builder.queryData[0].dataSource, 'noop'],
+ },
+ true,
+ K8sCategory.JOBS,
+ );
+
+ const query = useMemo(() => {
+ const baseQuery = getK8sJobsListQuery();
+ const queryPayload = {
+ ...baseQuery,
+ limit: pageSize,
+ offset: (currentPage - 1) * pageSize,
+ filters: queryFilters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ if (groupBy.length > 0) {
+ queryPayload.groupBy = groupBy;
+ }
+ return queryPayload;
+ }, [currentPage, minTime, maxTime, orderBy, groupBy, queryFilters]);
+
+ const formattedGroupedByJobsData = useMemo(
+ () =>
+ formatDataForTable(groupedByRowData?.payload?.data?.records || [], groupBy),
+ [groupedByRowData, groupBy],
+ );
+
+ const { data, isFetching, isLoading, isError } = useGetK8sJobsList(
+ query as K8sJobsListPayload,
+ {
+ queryKey: ['jobList', query],
+ enabled: !!query,
+ },
+ );
+
+ const jobsData = useMemo(() => data?.payload?.data?.records || [], [data]);
+ const totalCount = data?.payload?.data?.total || 0;
+
+ const formattedJobsData = useMemo(
+ () => formatDataForTable(jobsData, groupBy),
+ [jobsData, groupBy],
+ );
+
+ const columns = useMemo(() => getK8sJobsListColumns(groupBy), [groupBy]);
+
+ const handleGroupByRowClick = (record: K8sJobsRowData): void => {
+ setSelectedRowData(record);
+
+ if (expandedRowKeys.includes(record.key)) {
+ setExpandedRowKeys(expandedRowKeys.filter((key) => key !== record.key));
+ } else {
+ setExpandedRowKeys([record.key]);
+ }
+ };
+
+ useEffect(() => {
+ if (selectedRowData) {
+ fetchGroupedByRowData();
+ }
+ }, [selectedRowData, fetchGroupedByRowData]);
+
+ const handleTableChange: TableProps<K8sJobsRowData>['onChange'] = useCallback(
+ (
+ pagination: TablePaginationConfig,
+ _filters: Record<string, (string | number | boolean)[] | null>,
+ sorter: SorterResult<K8sJobsRowData> | SorterResult<K8sJobsRowData>[],
+ ): void => {
+ if (pagination.current) {
+ setCurrentPage(pagination.current);
+ }
+
+ if ('field' in sorter && sorter.order) {
+ setOrderBy({
+ columnName: sorter.field as string,
+ order: sorter.order === 'ascend' ? 'asc' : 'desc',
+ });
+ } else {
+ setOrderBy(null);
+ }
+ },
+ [],
+ );
+
+ const { handleChangeQueryData } = useQueryOperations({
+ index: 0,
+ query: currentQuery.builder.queryData[0],
+ entityVersion: '',
+ });
+
+ const handleFiltersChange = useCallback(
+ (value: IBuilderQuery['filters']): void => {
+ handleChangeQueryData('filters', value);
+ setCurrentPage(1);
+
+ logEvent('Infra Monitoring: K8s list filters applied', {
+ filters: value,
+ });
+ },
+ [handleChangeQueryData],
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: K8s list page visited', {});
+ }, []);
+
+ const selectedJobData = useMemo(() => {
+ if (!selectedJobUID) return null;
+ return jobsData.find((job) => job.jobName === selectedJobUID) || null;
+ }, [selectedJobUID, jobsData]);
+
+ const handleRowClick = (record: K8sJobsRowData): void => {
+ if (groupBy.length === 0) {
+ setSelectedRowData(null);
+ setselectedJobUID(record.jobUID);
+ } else {
+ handleGroupByRowClick(record);
+ }
+
+ logEvent('Infra Monitoring: K8s job list item clicked', {
+ jobName: record.jobName,
+ });
+ };
+
+ const nestedColumns = useMemo(() => getK8sJobsListColumns([]), []);
+
+ const isGroupedByAttribute = groupBy.length > 0;
+
+ const handleExpandedRowViewAllClick = (): void => {
+ if (!selectedRowData) return;
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ handleFiltersChange(filters);
+
+ setCurrentPage(1);
+ setSelectedRowData(null);
+ setGroupBy([]);
+ setOrderBy(null);
+ };
+
+ const expandedRowRender = (): JSX.Element => (
+ <div className="expanded-table-container">
+ {isErrorGroupedByRowData && (
+ <Typography>{groupedByRowData?.error || 'Something went wrong'}</Typography>
+ )}
+ {isFetchingGroupedByRowData || isLoadingGroupedByRowData ? (
+ <LoadingContainer />
+ ) : (
+ <div className="expanded-table">
+ <Table
+ columns={nestedColumns as ColumnType<K8sJobsRowData>[]}
+ dataSource={formattedGroupedByJobsData}
+ pagination={false}
+ scroll={{ x: true }}
+ tableLayout="fixed"
+ size="small"
+ loading={{
+ spinning: isFetchingGroupedByRowData || isLoadingGroupedByRowData,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ showHeader={false}
+ />
+
+ {groupedByRowData?.payload?.data?.total &&
+ groupedByRowData?.payload?.data?.total > 10 ? (
+ <div className="expanded-table-footer">
+ <Button
+ type="default"
+ size="small"
+ className="periscope-btn secondary"
+ onClick={handleExpandedRowViewAllClick}
+ >
+ View All
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ )}
+ </div>
+ );
+
+ const expandRowIconRenderer = ({
+ expanded,
+ onExpand,
+ record,
+ }: {
+ expanded: boolean;
+ onExpand: (
+ record: K8sJobsRowData,
+ e: React.MouseEvent<HTMLButtonElement>,
+ ) => void;
+ record: K8sJobsRowData;
+ }): JSX.Element | null => {
+ if (!isGroupedByAttribute) {
+ return null;
+ }
+
+ return expanded ? (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronDown size={14} />
+ </Button>
+ ) : (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronRight size={14} />
+ </Button>
+ );
+ };
+
+ const handleCloseJobDetail = (): void => {
+ setselectedJobUID(null);
+ };
+
+ const handleGroupByChange = useCallback(
+ (value: IBuilderQuery['groupBy']) => {
+ const groupBy = [];
+
+ for (let index = 0; index < value.length; index++) {
+ const element = (value[index] as unknown) as string;
+
+ const key = groupByFiltersData?.payload?.attributeKeys?.find(
+ (key) => key.key === element,
+ );
+
+ if (key) {
+ groupBy.push(key);
+ }
+ }
+
+ setCurrentPage(1);
+ setGroupBy(groupBy);
+ setExpandedRowKeys([]);
+ },
+ [groupByFiltersData],
+ );
+
+ useEffect(() => {
+ if (groupByFiltersData?.payload) {
+ setGroupByOptions(
+ groupByFiltersData?.payload?.attributeKeys?.map((filter) => ({
+ value: filter.key,
+ label: filter.key,
+ })) || [],
+ );
+ }
+ }, [groupByFiltersData]);
+
+ return (
+ <div className="k8s-list">
+ <K8sHeader
+ isFiltersVisible={isFiltersVisible}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ defaultAddedColumns={defaultAddedColumns}
+ handleFiltersChange={handleFiltersChange}
+ groupByOptions={groupByOptions}
+ isLoadingGroupByFilters={isLoadingGroupByFilters}
+ handleGroupByChange={handleGroupByChange}
+ selectedGroupBy={groupBy}
+ entity={K8sCategory.JOBS}
+ />
+ {isError && <Typography>{data?.error || 'Something went wrong'}</Typography>}
+
+ <Table
+ className={classNames('k8s-list-table', 'jobs-list-table', {
+ 'expanded-jobs-list-table': isGroupedByAttribute,
+ })}
+ dataSource={isFetching || isLoading ? [] : formattedJobsData}
+ columns={columns}
+ pagination={{
+ current: currentPage,
+ pageSize,
+ total: totalCount,
+ showSizeChanger: false,
+ hideOnSinglePage: true,
+ }}
+ scroll={{ x: true }}
+ loading={{
+ spinning: isFetching || isLoading,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ locale={{
+ emptyText:
+ isFetching || isLoading ? null : (
+ <div className="no-filtered-hosts-message-container">
+ <div className="no-filtered-hosts-message-content">
+ <img
+ src="/Icons/emptyState.svg"
+ alt="thinking-emoji"
+ className="empty-state-svg"
+ />
+
+ <Typography.Text className="no-filtered-hosts-message">
+ This query had no results. Edit your query and try again!
+ </Typography.Text>
+ </div>
+ </div>
+ ),
+ }}
+ tableLayout="fixed"
+ onChange={handleTableChange}
+ onRow={(record): { onClick: () => void; className: string } => ({
+ onClick: (): void => handleRowClick(record),
+ className: 'clickable-row',
+ })}
+ expandable={{
+ expandedRowRender: isGroupedByAttribute ? expandedRowRender : undefined,
+ expandIcon: expandRowIconRenderer,
+ expandedRowKeys,
+ }}
+ />
+
+ <JobDetails
+ job={selectedJobData}
+ isModalTimeSelection
+ onClose={handleCloseJobDetail}
+ />
+ </div>
+ );
+}
+
+export default K8sJobsList;
diff --git a/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx
new file mode 100644
index 0000000000..1cc7555b76
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Jobs/utils.tsx
@@ -0,0 +1,382 @@
+import { Color } from '@signozhq/design-tokens';
+import { Tag, Tooltip } from 'antd';
+import { ColumnType } from 'antd/es/table';
+import {
+ K8sJobsData,
+ K8sJobsListPayload,
+} from 'api/infraMonitoring/getK8sJobsList';
+import { Group } from 'lucide-react';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+
+import {
+ EntityProgressBar,
+ formatBytes,
+ ValidateColumnValueWrapper,
+} from '../commonUtils';
+import { K8sCategory } from '../constants';
+import { IEntityColumn } from '../utils';
+
+export const defaultAddedColumns: IEntityColumn[] = [
+ {
+ label: 'Job Name',
+ value: 'jobName',
+ id: 'jobName',
+ canRemove: false,
+ },
+ {
+ label: 'Namespace Name',
+ value: 'namespaceName',
+ id: 'namespaceName',
+ canRemove: false,
+ },
+ {
+ label: 'Successful',
+ value: 'successful_pods',
+ id: 'successful_pods',
+ canRemove: false,
+ },
+ {
+ label: 'Failed',
+ value: 'failed_pods',
+ id: 'failed_pods',
+ canRemove: false,
+ },
+ {
+ label: 'Desired Successful',
+ value: 'desired_successful_pods',
+ id: 'desired_successful_pods',
+ canRemove: false,
+ },
+ {
+ label: 'Active',
+ value: 'active_pods',
+ id: 'active_pods',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Req Usage (%)',
+ value: 'cpu_request',
+ id: 'cpu_request',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Limit Usage (%)',
+ value: 'cpu_limit',
+ id: 'cpu_limit',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Usage (cores)',
+ value: 'cpu',
+ id: 'cpu',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Req Usage (%)',
+ value: 'memory_request',
+ id: 'memory_request',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Limit Usage (%)',
+ value: 'memory_limit',
+ id: 'memory_limit',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Usage',
+ value: 'memory',
+ id: 'memory',
+ canRemove: false,
+ },
+];
+
+export interface K8sJobsRowData {
+ key: string;
+ jobUID: string;
+ jobName: React.ReactNode;
+ namespaceName: React.ReactNode;
+ successful_pods: React.ReactNode;
+ failed_pods: React.ReactNode;
+ active_pods: React.ReactNode;
+ desired_successful_pods: React.ReactNode;
+ cpu_request: React.ReactNode;
+ cpu_limit: React.ReactNode;
+ cpu: React.ReactNode;
+ memory_request: React.ReactNode;
+ memory_limit: React.ReactNode;
+ memory: React.ReactNode;
+ groupedByMeta?: any;
+}
+
+const jobGroupColumnConfig = {
+ title: (
+ <div className="column-header entity-group-header">
+ <Group size={14} /> JOB GROUP
+ </div>
+ ),
+ dataIndex: 'jobGroup',
+ key: 'jobGroup',
+ ellipsis: true,
+ width: 150,
+ align: 'left',
+ sorter: false,
+ className: 'column entity-group-header',
+};
+
+export const getK8sJobsListQuery = (): K8sJobsListPayload => ({
+ filters: {
+ items: [],
+ op: 'and',
+ },
+ orderBy: { columnName: 'cpu', order: 'desc' },
+});
+
+const columnProgressBarClassName = 'column-progress-bar';
+
+const columnsConfig = [
+ {
+ title: <div className="column-header-left job-name-header">Job Name</div>,
+ dataIndex: 'jobName',
+ key: 'jobName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: (
+ <div className="column-header-left namespace-name-header">
+ Namespace Name
+ </div>
+ ),
+ dataIndex: 'namespaceName',
+ key: 'namespaceName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header small-col">Successful</div>,
+ dataIndex: 'successful_pods',
+ key: 'successful_pods',
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Failed</div>,
+ dataIndex: 'failed_pods',
+ key: 'failed_pods',
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Desired Successful</div>,
+ dataIndex: 'desired_successful_pods',
+ key: 'desired_successful_pods',
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Active</div>,
+ dataIndex: 'active_pods',
+ key: 'active_pods',
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Req Usage (%)</div>,
+ dataIndex: 'cpu_request',
+ key: 'cpu_request',
+ width: 180,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Limit Usage (%)</div>,
+ dataIndex: 'cpu_limit',
+ key: 'cpu_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">CPU Usage (cores)</div>,
+ dataIndex: 'cpu',
+ key: 'cpu',
+ width: 80,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Req Usage (%)</div>,
+ dataIndex: 'memory_request',
+ key: 'memory_request',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Limit Usage (%)</div>,
+ dataIndex: 'memory_limit',
+ key: 'memory_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Mem Usage</div>,
+ dataIndex: 'memory',
+ key: 'memory',
+ width: 80,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+];
+
+export const getK8sJobsListColumns = (
+ groupBy: IBuilderQuery['groupBy'],
+): ColumnType<K8sJobsRowData>[] => {
+ if (groupBy.length > 0) {
+ const filteredColumns = [...columnsConfig].filter(
+ (column) => column.key !== 'jobName',
+ );
+ filteredColumns.unshift(jobGroupColumnConfig);
+ return filteredColumns as ColumnType<K8sJobsRowData>[];
+ }
+
+ return columnsConfig as ColumnType<K8sJobsRowData>[];
+};
+
+const getGroupByEle = (
+ job: K8sJobsData,
+ groupBy: IBuilderQuery['groupBy'],
+): React.ReactNode => {
+ const groupByValues: string[] = [];
+
+ groupBy.forEach((group) => {
+ groupByValues.push(job.meta[group.key as keyof typeof job.meta]);
+ });
+
+ return (
+ <div className="pod-group">
+ {groupByValues.map((value) => (
+ <Tag key={value} color={Color.BG_SLATE_400} className="pod-group-tag-item">
+ {value === '' ? '<no-value>' : value}
+ </Tag>
+ ))}
+ </div>
+ );
+};
+
+export const formatDataForTable = (
+ data: K8sJobsData[],
+ groupBy: IBuilderQuery['groupBy'],
+): K8sJobsRowData[] =>
+ data.map((job, index) => ({
+ key: index.toString(),
+ jobUID: job.jobName,
+ jobName: (
+ <Tooltip title={job.meta.k8s_job_name}>
+ {job.meta.k8s_job_name || ''}
+ </Tooltip>
+ ),
+ namespaceName: (
+ <Tooltip title={job.meta.k8s_namespace_name}>
+ {job.meta.k8s_namespace_name || ''}
+ </Tooltip>
+ ),
+ cpu_request: (
+ <ValidateColumnValueWrapper
+ value={job.cpuRequest}
+ entity={K8sCategory.JOBS}
+ attribute="CPU Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={job.cpuRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu_limit: (
+ <ValidateColumnValueWrapper
+ value={job.cpuLimit}
+ entity={K8sCategory.JOBS}
+ attribute="CPU Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={job.cpuLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu: (
+ <ValidateColumnValueWrapper value={job.cpuUsage}>
+ {job.cpuUsage}
+ </ValidateColumnValueWrapper>
+ ),
+ memory_request: (
+ <ValidateColumnValueWrapper
+ value={job.memoryRequest}
+ entity={K8sCategory.JOBS}
+ attribute="Memory Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={job.memoryRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory_limit: (
+ <ValidateColumnValueWrapper
+ value={job.memoryLimit}
+ entity={K8sCategory.JOBS}
+ attribute="Memory Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={job.memoryLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory: (
+ <ValidateColumnValueWrapper value={job.memoryUsage}>
+ {formatBytes(job.memoryUsage)}
+ </ValidateColumnValueWrapper>
+ ),
+ successful_pods: (
+ <ValidateColumnValueWrapper value={job.successfulPods}>
+ {job.successfulPods}
+ </ValidateColumnValueWrapper>
+ ),
+ desired_successful_pods: (
+ <ValidateColumnValueWrapper value={job.desiredSuccessfulPods}>
+ {job.desiredSuccessfulPods}
+ </ValidateColumnValueWrapper>
+ ),
+ failed_pods: (
+ <ValidateColumnValueWrapper value={job.failedPods}>
+ {job.failedPods}
+ </ValidateColumnValueWrapper>
+ ),
+ active_pods: (
+ <ValidateColumnValueWrapper value={job.activePods}>
+ {job.activePods}
+ </ValidateColumnValueWrapper>
+ ),
+ jobGroup: getGroupByEle(job, groupBy),
+ meta: job.meta,
+ ...job.meta,
+ groupedByMeta: job.meta,
+ }));
diff --git a/frontend/src/container/InfraMonitoringK8s/K8sFiltersSidePanel/K8sFiltersSidePanel.styles.scss b/frontend/src/container/InfraMonitoringK8s/K8sFiltersSidePanel/K8sFiltersSidePanel.styles.scss
index addc3fb2d4..c09867d0ed 100644
--- a/frontend/src/container/InfraMonitoringK8s/K8sFiltersSidePanel/K8sFiltersSidePanel.styles.scss
+++ b/frontend/src/container/InfraMonitoringK8s/K8sFiltersSidePanel/K8sFiltersSidePanel.styles.scss
@@ -112,3 +112,15 @@
}
}
}
+
+.lightMode {
+ .k8s-filters-side-panel {
+ background-color: var(--bg-vanilla-100) !important;
+ color: var(--text-slate-400) !important;
+
+ .added-column-item,
+ .available-column-item {
+ color: var(--text-slate-400) !important;
+ }
+ }
+}
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.styles.scss b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.styles.scss
new file mode 100644
index 0000000000..29e3ebe33d
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.styles.scss
@@ -0,0 +1,62 @@
+.infra-monitoring-container {
+ .statefulSets-list-table {
+ .expanded-table-container {
+ padding-left: 20px;
+ }
+
+ .ant-table-cell.column-progress-bar {
+ min-width: 180px;
+ max-width: 180px;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+
+ .progress-container {
+ display: flex;
+ justify-content: start;
+ }
+ }
+}
+
+.ant-table-cell {
+ &:has(.statefulset-name-header) {
+ min-width: 250px !important;
+ max-width: 250px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.namespace-name-header) {
+ min-width: 220px !important;
+ max-width: 220px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.med-col) {
+ min-width: 200px !important;
+ max-width: 200px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.small-col) {
+ min-width: 120px !important;
+ max-width: 120px !important;
+ }
+}
+
+.expanded-statefulsets-list-table {
+ .ant-table-cell {
+ min-width: 180px !important;
+ max-width: 180px !important;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+}
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx
new file mode 100644
index 0000000000..cd85cc5e13
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/K8sStatefulSetsList.tsx
@@ -0,0 +1,518 @@
+/* eslint-disable no-restricted-syntax */
+/* eslint-disable @typescript-eslint/explicit-function-return-type */
+import '../InfraMonitoringK8s.styles.scss';
+import './K8sStatefulSetsList.styles.scss';
+
+import { LoadingOutlined } from '@ant-design/icons';
+import {
+ Button,
+ Spin,
+ Table,
+ TablePaginationConfig,
+ TableProps,
+ Typography,
+} from 'antd';
+import { ColumnType, SorterResult } from 'antd/es/table/interface';
+import logEvent from 'api/common/logEvent';
+import { K8sStatefulSetsListPayload } from 'api/infraMonitoring/getsK8sStatefulSetsList';
+import classNames from 'classnames';
+import { useGetK8sStatefulSetsList } from 'hooks/infraMonitoring/useGetK8sStatefulSetsList';
+import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+import {
+ K8sCategory,
+ K8sEntityToAggregateAttributeMapping,
+} from '../constants';
+import K8sHeader from '../K8sHeader';
+import LoadingContainer from '../LoadingContainer';
+import StatefulSetDetails from './StatefulSetDetails';
+import {
+ defaultAddedColumns,
+ formatDataForTable,
+ getK8sStatefulSetsListColumns,
+ getK8sStatefulSetsListQuery,
+ K8sStatefulSetsRowData,
+} from './utils';
+
+// eslint-disable-next-line sonarjs/cognitive-complexity
+function K8sStatefulSetsList({
+ isFiltersVisible,
+ handleFilterVisibilityChange,
+ quickFiltersLastUpdated,
+}: {
+ isFiltersVisible: boolean;
+ handleFilterVisibilityChange: () => void;
+ quickFiltersLastUpdated: number;
+}): JSX.Element {
+ const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
+ (state) => state.globalTime,
+ );
+
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]);
+
+ const [orderBy, setOrderBy] = useState<{
+ columnName: string;
+ order: 'asc' | 'desc';
+ } | null>(null);
+
+ const [selectedStatefulSetUID, setselectedStatefulSetUID] = useState<
+ string | null
+ >(null);
+
+ const pageSize = 10;
+
+ const [groupBy, setGroupBy] = useState<IBuilderQuery['groupBy']>([]);
+
+ const [
+ selectedRowData,
+ setSelectedRowData,
+ ] = useState<K8sStatefulSetsRowData | null>(null);
+
+ const [groupByOptions, setGroupByOptions] = useState<
+ { value: string; label: string }[]
+ >([]);
+
+ const { currentQuery } = useQueryBuilder();
+
+ const queryFilters = useMemo(
+ () =>
+ currentQuery?.builder?.queryData[0]?.filters || {
+ items: [],
+ op: 'and',
+ },
+ [currentQuery?.builder?.queryData],
+ );
+
+ // Reset pagination every time quick filters are changed
+ useEffect(() => {
+ setCurrentPage(1);
+ }, [quickFiltersLastUpdated]);
+
+ const createFiltersForSelectedRowData = (
+ selectedRowData: K8sStatefulSetsRowData,
+ groupBy: IBuilderQuery['groupBy'],
+ ): IBuilderQuery['filters'] => {
+ const baseFilters: IBuilderQuery['filters'] = {
+ items: [...queryFilters.items],
+ op: 'and',
+ };
+
+ if (!selectedRowData) return baseFilters;
+
+ const { groupedByMeta } = selectedRowData;
+
+ for (const key of groupBy) {
+ baseFilters.items.push({
+ key: {
+ key: key.key,
+ type: null,
+ },
+ op: '=',
+ value: groupedByMeta[key.key],
+ id: key.key,
+ });
+ }
+
+ return baseFilters;
+ };
+
+ const fetchGroupedByRowDataQuery = useMemo(() => {
+ if (!selectedRowData) return null;
+
+ const baseQuery = getK8sStatefulSetsListQuery();
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ return {
+ ...baseQuery,
+ limit: 10,
+ offset: 0,
+ filters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [minTime, maxTime, orderBy, selectedRowData, groupBy]);
+
+ const {
+ data: groupedByRowData,
+ isFetching: isFetchingGroupedByRowData,
+ isLoading: isLoadingGroupedByRowData,
+ isError: isErrorGroupedByRowData,
+ refetch: fetchGroupedByRowData,
+ } = useGetK8sStatefulSetsList(
+ fetchGroupedByRowDataQuery as K8sStatefulSetsListPayload,
+ {
+ queryKey: ['statefulSetList', fetchGroupedByRowDataQuery],
+ enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData,
+ },
+ );
+
+ const {
+ data: groupByFiltersData,
+ isLoading: isLoadingGroupByFilters,
+ } = useGetAggregateKeys(
+ {
+ dataSource: currentQuery.builder.queryData[0].dataSource,
+ aggregateAttribute:
+ K8sEntityToAggregateAttributeMapping[K8sCategory.STATEFULSETS],
+ aggregateOperator: 'noop',
+ searchText: '',
+ tagType: '',
+ },
+ {
+ queryKey: [currentQuery.builder.queryData[0].dataSource, 'noop'],
+ },
+ true,
+ K8sCategory.STATEFULSETS,
+ );
+
+ const query = useMemo(() => {
+ const baseQuery = getK8sStatefulSetsListQuery();
+ const queryPayload = {
+ ...baseQuery,
+ limit: pageSize,
+ offset: (currentPage - 1) * pageSize,
+ filters: queryFilters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ if (groupBy.length > 0) {
+ queryPayload.groupBy = groupBy;
+ }
+ return queryPayload;
+ }, [currentPage, minTime, maxTime, orderBy, groupBy, queryFilters]);
+
+ const formattedGroupedByStatefulSetsData = useMemo(
+ () =>
+ formatDataForTable(groupedByRowData?.payload?.data?.records || [], groupBy),
+ [groupedByRowData, groupBy],
+ );
+
+ const { data, isFetching, isLoading, isError } = useGetK8sStatefulSetsList(
+ query as K8sStatefulSetsListPayload,
+ {
+ queryKey: ['statefulSetList', query],
+ enabled: !!query,
+ },
+ );
+
+ const statefulSetsData = useMemo(() => data?.payload?.data?.records || [], [
+ data,
+ ]);
+ const totalCount = data?.payload?.data?.total || 0;
+
+ const formattedStatefulSetsData = useMemo(
+ () => formatDataForTable(statefulSetsData, groupBy),
+ [statefulSetsData, groupBy],
+ );
+
+ const columns = useMemo(() => getK8sStatefulSetsListColumns(groupBy), [
+ groupBy,
+ ]);
+
+ const handleGroupByRowClick = (record: K8sStatefulSetsRowData): void => {
+ setSelectedRowData(record);
+
+ if (expandedRowKeys.includes(record.key)) {
+ setExpandedRowKeys(expandedRowKeys.filter((key) => key !== record.key));
+ } else {
+ setExpandedRowKeys([record.key]);
+ }
+ };
+
+ useEffect(() => {
+ if (selectedRowData) {
+ fetchGroupedByRowData();
+ }
+ }, [selectedRowData, fetchGroupedByRowData]);
+
+ const handleTableChange: TableProps<K8sStatefulSetsRowData>['onChange'] = useCallback(
+ (
+ pagination: TablePaginationConfig,
+ _filters: Record<string, (string | number | boolean)[] | null>,
+ sorter:
+ | SorterResult<K8sStatefulSetsRowData>
+ | SorterResult<K8sStatefulSetsRowData>[],
+ ): void => {
+ if (pagination.current) {
+ setCurrentPage(pagination.current);
+ }
+
+ if ('field' in sorter && sorter.order) {
+ setOrderBy({
+ columnName: sorter.field as string,
+ order: sorter.order === 'ascend' ? 'asc' : 'desc',
+ });
+ } else {
+ setOrderBy(null);
+ }
+ },
+ [],
+ );
+
+ const { handleChangeQueryData } = useQueryOperations({
+ index: 0,
+ query: currentQuery.builder.queryData[0],
+ entityVersion: '',
+ });
+
+ const handleFiltersChange = useCallback(
+ (value: IBuilderQuery['filters']): void => {
+ handleChangeQueryData('filters', value);
+ setCurrentPage(1);
+
+ logEvent('Infra Monitoring: K8s list filters applied', {
+ filters: value,
+ });
+ },
+ [handleChangeQueryData],
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: K8s list page visited', {});
+ }, []);
+
+ const selectedStatefulSetData = useMemo(() => {
+ if (!selectedStatefulSetUID) return null;
+ return (
+ statefulSetsData.find(
+ (statefulSet) => statefulSet.statefulSetName === selectedStatefulSetUID,
+ ) || null
+ );
+ }, [selectedStatefulSetUID, statefulSetsData]);
+
+ const handleRowClick = (record: K8sStatefulSetsRowData): void => {
+ if (groupBy.length === 0) {
+ setSelectedRowData(null);
+ setselectedStatefulSetUID(record.statefulsetUID);
+ } else {
+ handleGroupByRowClick(record);
+ }
+
+ logEvent('Infra Monitoring: K8s statefulSet list item clicked', {
+ statefulSetName: record.statefulsetName,
+ });
+ };
+
+ const nestedColumns = useMemo(() => getK8sStatefulSetsListColumns([]), []);
+
+ const isGroupedByAttribute = groupBy.length > 0;
+
+ const handleExpandedRowViewAllClick = (): void => {
+ if (!selectedRowData) return;
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ handleFiltersChange(filters);
+
+ setCurrentPage(1);
+ setSelectedRowData(null);
+ setGroupBy([]);
+ setOrderBy(null);
+ };
+
+ const expandedRowRender = (): JSX.Element => (
+ <div className="expanded-table-container">
+ {isErrorGroupedByRowData && (
+ <Typography>{groupedByRowData?.error || 'Something went wrong'}</Typography>
+ )}
+ {isFetchingGroupedByRowData || isLoadingGroupedByRowData ? (
+ <LoadingContainer />
+ ) : (
+ <div className="expanded-table">
+ <Table
+ columns={nestedColumns as ColumnType<K8sStatefulSetsRowData>[]}
+ dataSource={formattedGroupedByStatefulSetsData}
+ pagination={false}
+ scroll={{ x: true }}
+ tableLayout="fixed"
+ size="small"
+ loading={{
+ spinning: isFetchingGroupedByRowData || isLoadingGroupedByRowData,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ showHeader={false}
+ />
+
+ {groupedByRowData?.payload?.data?.total &&
+ groupedByRowData?.payload?.data?.total > 10 ? (
+ <div className="expanded-table-footer">
+ <Button
+ type="default"
+ size="small"
+ className="periscope-btn secondary"
+ onClick={handleExpandedRowViewAllClick}
+ >
+ View All
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ )}
+ </div>
+ );
+
+ const expandRowIconRenderer = ({
+ expanded,
+ onExpand,
+ record,
+ }: {
+ expanded: boolean;
+ onExpand: (
+ record: K8sStatefulSetsRowData,
+ e: React.MouseEvent<HTMLButtonElement>,
+ ) => void;
+ record: K8sStatefulSetsRowData;
+ }): JSX.Element | null => {
+ if (!isGroupedByAttribute) {
+ return null;
+ }
+
+ return expanded ? (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronDown size={14} />
+ </Button>
+ ) : (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronRight size={14} />
+ </Button>
+ );
+ };
+
+ const handleCloseStatefulSetDetail = (): void => {
+ setselectedStatefulSetUID(null);
+ };
+
+ const handleGroupByChange = useCallback(
+ (value: IBuilderQuery['groupBy']) => {
+ const groupBy = [];
+
+ for (let index = 0; index < value.length; index++) {
+ const element = (value[index] as unknown) as string;
+
+ const key = groupByFiltersData?.payload?.attributeKeys?.find(
+ (key) => key.key === element,
+ );
+
+ if (key) {
+ groupBy.push(key);
+ }
+ }
+
+ setCurrentPage(1);
+ setGroupBy(groupBy);
+ setExpandedRowKeys([]);
+ },
+ [groupByFiltersData],
+ );
+
+ useEffect(() => {
+ if (groupByFiltersData?.payload) {
+ setGroupByOptions(
+ groupByFiltersData?.payload?.attributeKeys?.map((filter) => ({
+ value: filter.key,
+ label: filter.key,
+ })) || [],
+ );
+ }
+ }, [groupByFiltersData]);
+
+ return (
+ <div className="k8s-list">
+ <K8sHeader
+ isFiltersVisible={isFiltersVisible}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ defaultAddedColumns={defaultAddedColumns}
+ handleFiltersChange={handleFiltersChange}
+ groupByOptions={groupByOptions}
+ isLoadingGroupByFilters={isLoadingGroupByFilters}
+ handleGroupByChange={handleGroupByChange}
+ selectedGroupBy={groupBy}
+ entity={K8sCategory.STATEFULSETS}
+ />
+ {isError && <Typography>{data?.error || 'Something went wrong'}</Typography>}
+
+ <Table
+ className={classNames('k8s-list-table', 'statefulSets-list-table', {
+ 'expanded-statefulsets-list-table': isGroupedByAttribute,
+ })}
+ dataSource={isFetching || isLoading ? [] : formattedStatefulSetsData}
+ columns={columns}
+ pagination={{
+ current: currentPage,
+ pageSize,
+ total: totalCount,
+ showSizeChanger: false,
+ hideOnSinglePage: true,
+ }}
+ scroll={{ x: true }}
+ loading={{
+ spinning: isFetching || isLoading,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ locale={{
+ emptyText:
+ isFetching || isLoading ? null : (
+ <div className="no-filtered-hosts-message-container">
+ <div className="no-filtered-hosts-message-content">
+ <img
+ src="/Icons/emptyState.svg"
+ alt="thinking-emoji"
+ className="empty-state-svg"
+ />
+
+ <Typography.Text className="no-filtered-hosts-message">
+ This query had no results. Edit your query and try again!
+ </Typography.Text>
+ </div>
+ </div>
+ ),
+ }}
+ tableLayout="fixed"
+ onChange={handleTableChange}
+ onRow={(record): { onClick: () => void; className: string } => ({
+ onClick: (): void => handleRowClick(record),
+ className: 'clickable-row',
+ })}
+ expandable={{
+ expandedRowRender: isGroupedByAttribute ? expandedRowRender : undefined,
+ expandIcon: expandRowIconRenderer,
+ expandedRowKeys,
+ }}
+ />
+
+ <StatefulSetDetails
+ statefulSet={selectedStatefulSetData}
+ isModalTimeSelection
+ onClose={handleCloseStatefulSetDetail}
+ />
+ </div>
+ );
+}
+
+export default K8sStatefulSetsList;
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.interfaces.ts b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.interfaces.ts
new file mode 100644
index 0000000000..135c2b2d1f
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.interfaces.ts
@@ -0,0 +1,7 @@
+import { K8sStatefulSetsData } from 'api/infraMonitoring/getsK8sStatefulSetsList';
+
+export type StatefulSetDetailsProps = {
+ statefulSet: K8sStatefulSetsData | null;
+ isModalTimeSelection: boolean;
+ onClose: () => void;
+};
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.tsx b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.tsx
new file mode 100644
index 0000000000..ec67746bb5
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/StatefulSetDetails.tsx
@@ -0,0 +1,588 @@
+/* eslint-disable sonarjs/no-identical-functions */
+import '../../EntityDetailsUtils/entityDetails.styles.scss';
+
+import { Color, Spacing } from '@signozhq/design-tokens';
+import { Button, Divider, Drawer, Radio, Tooltip, Typography } from 'antd';
+import { RadioChangeEvent } from 'antd/lib';
+import logEvent from 'api/common/logEvent';
+import { VIEW_TYPES, VIEWS } from 'components/HostMetricsDetail/constants';
+import { QueryParams } from 'constants/query';
+import {
+ initialQueryBuilderFormValuesMap,
+ initialQueryState,
+} from 'constants/queryBuilder';
+import ROUTES from 'constants/routes';
+import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
+import EntityEvents from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityEvents';
+import EntityLogs from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityLogs';
+import EntityMetrics from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityMetrics';
+import EntityTraces from 'container/InfraMonitoringK8s/EntityDetailsUtils/EntityTraces';
+import { QUERY_KEYS } from 'container/InfraMonitoringK8s/EntityDetailsUtils/utils';
+import {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/config';
+import { useIsDarkMode } from 'hooks/useDarkMode';
+import useUrlQuery from 'hooks/useUrlQuery';
+import GetMinMax from 'lib/getMinMax';
+import {
+ BarChart2,
+ ChevronsLeftRight,
+ Compass,
+ DraftingCompass,
+ ScrollText,
+ X,
+} from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import {
+ IBuilderQuery,
+ TagFilterItem,
+} from 'types/api/queryBuilder/queryBuilderData';
+import {
+ LogsAggregatorOperator,
+ TracesAggregatorOperator,
+} from 'types/common/queryBuilder';
+import { GlobalReducer } from 'types/reducer/globalTime';
+import { v4 as uuidv4 } from 'uuid';
+
+import {
+ getStatefulSetMetricsQueryPayload,
+ statefulSetWidgetInfo,
+} from './constants';
+import { StatefulSetDetailsProps } from './StatefulSetDetails.interfaces';
+
+function StatefulSetDetails({
+ statefulSet,
+ onClose,
+ isModalTimeSelection,
+}: StatefulSetDetailsProps): JSX.Element {
+ const { maxTime, minTime, selectedTime } = useSelector<
+ AppState,
+ GlobalReducer
+ >((state) => state.globalTime);
+
+ const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
+ minTime,
+ ]);
+ const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
+ maxTime,
+ ]);
+
+ const urlQuery = useUrlQuery();
+
+ const [modalTimeRange, setModalTimeRange] = useState(() => ({
+ startTime: startMs,
+ endTime: endMs,
+ }));
+
+ const [selectedInterval, setSelectedInterval] = useState<Time>(
+ selectedTime as Time,
+ );
+
+ const [selectedView, setSelectedView] = useState<VIEWS>(VIEWS.METRICS);
+ const isDarkMode = useIsDarkMode();
+
+ const initialFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_statefulset_name--string--resource--false',
+ },
+ op: '=',
+ value: statefulSet?.meta.k8s_statefulset_name || '',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_NAMESPACE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_namespace_name--string--resource--false',
+ },
+ op: '=',
+ value: statefulSet?.meta.k8s_namespace_name || '',
+ },
+ ],
+ }),
+ [
+ statefulSet?.meta.k8s_statefulset_name,
+ statefulSet?.meta.k8s_namespace_name,
+ ],
+ );
+
+ const initialEventsFilters = useMemo(
+ () => ({
+ op: 'AND',
+ items: [
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_KIND,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.kind--string--resource--false',
+ },
+ op: '=',
+ value: 'StatefulSet',
+ },
+ {
+ id: uuidv4(),
+ key: {
+ key: QUERY_KEYS.K8S_OBJECT_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s.object.name--string--resource--false',
+ },
+ op: '=',
+ value: statefulSet?.meta.k8s_statefulset_name || '',
+ },
+ ],
+ }),
+ [statefulSet?.meta.k8s_statefulset_name],
+ );
+
+ const [logFilters, setLogFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [tracesFilters, setTracesFilters] = useState<IBuilderQuery['filters']>(
+ initialFilters,
+ );
+
+ const [eventsFilters, setEventsFilters] = useState<IBuilderQuery['filters']>(
+ initialEventsFilters,
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: StatefulSets list details page visited', {
+ statefulSet: statefulSet?.statefulSetName,
+ });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ setLogFilters(initialFilters);
+ setTracesFilters(initialFilters);
+ setEventsFilters(initialEventsFilters);
+ }, [initialFilters, initialEventsFilters]);
+
+ useEffect(() => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ }, [selectedTime, minTime, maxTime]);
+
+ const handleTabChange = (e: RadioChangeEvent): void => {
+ setSelectedView(e.target.value);
+ };
+
+ const handleTimeChange = useCallback(
+ (interval: Time | CustomTimeType, dateTimeRange?: [number, number]): void => {
+ setSelectedInterval(interval as Time);
+
+ if (interval === 'custom' && dateTimeRange) {
+ setModalTimeRange({
+ startTime: Math.floor(dateTimeRange[0] / 1000),
+ endTime: Math.floor(dateTimeRange[1] / 1000),
+ });
+ } else {
+ const { maxTime, minTime } = GetMinMax(interval);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+
+ logEvent('Infra Monitoring: StatefulSets list details time updated', {
+ statefulSet: statefulSet?.statefulSetName,
+ interval,
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeLogFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setLogFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_STATEFUL_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+ const paginationFilter = value.items.find((item) => item.key?.key === 'id');
+ const newFilters = value.items.filter(
+ (item) =>
+ item.key?.key !== 'id' &&
+ item.key?.key !== QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ );
+
+ logEvent(
+ 'Infra Monitoring: StatefulSets list details logs filters applied',
+ {
+ statefulSet: statefulSet?.statefulSetName,
+ },
+ );
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...newFilters,
+ ...(paginationFilter ? [paginationFilter] : []),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeTracesFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setTracesFilters((prevFilters) => {
+ const primaryFilters = prevFilters.items.filter((item) =>
+ [QUERY_KEYS.K8S_STATEFUL_SET_NAME, QUERY_KEYS.K8S_NAMESPACE_NAME].includes(
+ item.key?.key ?? '',
+ ),
+ );
+
+ logEvent(
+ 'Infra Monitoring: StatefulSets list details traces filters applied',
+ {
+ statefulSet: statefulSet?.statefulSetName,
+ },
+ );
+
+ return {
+ op: 'AND',
+ items: [
+ ...primaryFilters,
+ ...value.items.filter(
+ (item) => item.key?.key !== QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleChangeEventsFilters = useCallback(
+ (value: IBuilderQuery['filters']) => {
+ setEventsFilters((prevFilters) => {
+ const statefulSetKindFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_KIND,
+ );
+ const statefulSetNameFilter = prevFilters.items.find(
+ (item) => item.key?.key === QUERY_KEYS.K8S_OBJECT_NAME,
+ );
+
+ logEvent(
+ 'Infra Monitoring: StatefulSets list details events filters applied',
+ {
+ statefulSet: statefulSet?.statefulSetName,
+ },
+ );
+
+ return {
+ op: 'AND',
+ items: [
+ statefulSetKindFilter,
+ statefulSetNameFilter,
+ ...value.items.filter(
+ (item) =>
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_KIND &&
+ item.key?.key !== QUERY_KEYS.K8S_OBJECT_NAME,
+ ),
+ ].filter((item): item is TagFilterItem => item !== undefined),
+ };
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleExplorePagesRedirect = (): void => {
+ if (selectedInterval !== 'custom') {
+ urlQuery.set(QueryParams.relativeTime, selectedInterval);
+ } else {
+ urlQuery.delete(QueryParams.relativeTime);
+ urlQuery.set(QueryParams.startTime, modalTimeRange.startTime.toString());
+ urlQuery.set(QueryParams.endTime, modalTimeRange.endTime.toString());
+ }
+
+ logEvent('Infra Monitoring: StatefulSets list details explore clicked', {
+ statefulSet: statefulSet?.statefulSetName,
+ view: selectedView,
+ });
+
+ if (selectedView === VIEW_TYPES.LOGS) {
+ const filtersWithoutPagination = {
+ ...logFilters,
+ items: logFilters.items.filter((item) => item.key?.key !== 'id'),
+ };
+
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.logs,
+ aggregateOperator: LogsAggregatorOperator.NOOP,
+ filters: filtersWithoutPagination,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.LOGS_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ } else if (selectedView === VIEW_TYPES.TRACES) {
+ const compositeQuery = {
+ ...initialQueryState,
+ queryType: 'builder',
+ builder: {
+ ...initialQueryState.builder,
+ queryData: [
+ {
+ ...initialQueryBuilderFormValuesMap.traces,
+ aggregateOperator: TracesAggregatorOperator.NOOP,
+ filters: tracesFilters,
+ },
+ ],
+ },
+ };
+
+ urlQuery.set('compositeQuery', JSON.stringify(compositeQuery));
+
+ window.open(
+ `${window.location.origin}${ROUTES.TRACES_EXPLORER}?${urlQuery.toString()}`,
+ '_blank',
+ );
+ }
+ };
+
+ const handleClose = (): void => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ setSelectedView(VIEW_TYPES.METRICS);
+ onClose();
+ };
+
+ return (
+ <Drawer
+ width="70%"
+ title={
+ <>
+ <Divider type="vertical" />
+ <Typography.Text className="title">
+ {statefulSet?.meta.k8s_statefulset_name}
+ </Typography.Text>
+ </>
+ }
+ placement="right"
+ onClose={handleClose}
+ open={!!statefulSet}
+ style={{
+ overscrollBehavior: 'contain',
+ background: isDarkMode ? Color.BG_INK_400 : Color.BG_VANILLA_100,
+ }}
+ className="entity-detail-drawer"
+ destroyOnClose
+ closeIcon={<X size={16} style={{ marginTop: Spacing.MARGIN_1 }} />}
+ >
+ {statefulSet && (
+ <>
+ <div className="entity-detail-drawer__entity">
+ <div className="entity-details-grid">
+ <div className="labels-row">
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Statefulset Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Namespace Name
+ </Typography.Text>
+ </div>
+ <div className="values-row">
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={statefulSet.meta.k8s_statefulset_name}>
+ {statefulSet.meta.k8s_statefulset_name}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={statefulSet.meta.k8s_namespace_name}>
+ {statefulSet.meta.k8s_namespace_name}
+ </Tooltip>
+ </Typography.Text>
+ </div>
+ </div>
+ </div>
+
+ <div className="views-tabs-container">
+ <Radio.Group
+ className="views-tabs"
+ onChange={handleTabChange}
+ value={selectedView}
+ >
+ <Radio.Button
+ className={
+ // eslint-disable-next-line sonarjs/no-duplicate-string
+ selectedView === VIEW_TYPES.METRICS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.METRICS}
+ >
+ <div className="view-title">
+ <BarChart2 size={14} />
+ Metrics
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.LOGS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.LOGS}
+ >
+ <div className="view-title">
+ <ScrollText size={14} />
+ Logs
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.TRACES ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.TRACES}
+ >
+ <div className="view-title">
+ <DraftingCompass size={14} />
+ Traces
+ </div>
+ </Radio.Button>
+ <Radio.Button
+ className={
+ selectedView === VIEW_TYPES.EVENTS ? 'selected_view tab' : 'tab'
+ }
+ value={VIEW_TYPES.EVENTS}
+ >
+ <div className="view-title">
+ <ChevronsLeftRight size={14} />
+ Events
+ </div>
+ </Radio.Button>
+ </Radio.Group>
+
+ {(selectedView === VIEW_TYPES.LOGS ||
+ selectedView === VIEW_TYPES.TRACES) && (
+ <Button
+ icon={<Compass size={18} />}
+ className="compass-button"
+ onClick={handleExplorePagesRedirect}
+ />
+ )}
+ </div>
+ {selectedView === VIEW_TYPES.METRICS && (
+ <EntityMetrics
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ entity={statefulSet}
+ entityWidgetInfo={statefulSetWidgetInfo}
+ getEntityQueryPayload={getStatefulSetMetricsQueryPayload}
+ category={K8sCategory.STATEFULSETS}
+ queryKey="statefulsetMetrics"
+ />
+ )}
+ {selectedView === VIEW_TYPES.LOGS && (
+ <EntityLogs
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeLogFilters={handleChangeLogFilters}
+ logFilters={logFilters}
+ selectedInterval={selectedInterval}
+ queryKey="statefulsetLogs"
+ category={K8sCategory.STATEFULSETS}
+ queryKeyFilters={[
+ QUERY_KEYS.K8S_STATEFUL_SET_NAME,
+ QUERY_KEYS.K8S_NAMESPACE_NAME,
+ ]}
+ />
+ )}
+ {selectedView === VIEW_TYPES.TRACES && (
+ <EntityTraces
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ handleChangeTracesFilters={handleChangeTracesFilters}
+ tracesFilters={tracesFilters}
+ selectedInterval={selectedInterval}
+ queryKey="statefulsetTraces"
+ />
+ )}
+ {selectedView === VIEW_TYPES.EVENTS && (
+ <EntityEvents
+ timeRange={modalTimeRange}
+ handleChangeEventFilters={handleChangeEventsFilters}
+ filters={eventsFilters}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ category={K8sCategory.STATEFULSETS}
+ queryKey="statefulsetEvents"
+ />
+ )}
+ </>
+ )}
+ </Drawer>
+ );
+}
+
+export default StatefulSetDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts
new file mode 100644
index 0000000000..c1ae28dd77
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/constants.ts
@@ -0,0 +1,946 @@
+/* eslint-disable sonarjs/no-duplicate-string */
+import { K8sStatefulSetsData } from 'api/infraMonitoring/getsK8sStatefulSetsList';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { EQueryType } from 'types/common/dashboard';
+import { DataSource } from 'types/common/queryBuilder';
+import { v4 } from 'uuid';
+
+export const statefulSetWidgetInfo = [
+ {
+ title: 'CPU usage, request, limits',
+ yAxisUnit: '',
+ },
+ {
+ title: 'CPU request, limit util (%)',
+ yAxisUnit: 'percentunit',
+ },
+ {
+ title: 'Memory usage, request, limits',
+ yAxisUnit: 'bytes',
+ },
+ {
+ title: 'Memory request, limit util (%)',
+ yAxisUnit: 'percentunit',
+ },
+ {
+ title: 'Network IO',
+ yAxisUnit: 'binBps',
+ },
+ {
+ title: 'Network errors count',
+ yAxisUnit: '',
+ },
+];
+
+export const getStatefulSetMetricsQueryPayload = (
+ statefulSet: K8sStatefulSetsData,
+ start: number,
+ end: number,
+): GetQueryResultsProps[] => [
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_cpu_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_cpu_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '8627bd22',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_cpu_request--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_cpu_request',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'latest',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: '82f07131',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'requests',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'latest',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_cpu_limit--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_cpu_limit',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'latest',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'C',
+ filters: {
+ items: [
+ {
+ id: '9c669f4f',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'limits',
+ limit: null,
+ orderBy: [],
+ queryName: 'C',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'latest',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_cpu_request_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_cpu_request_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '3c835082',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'Reqs util %',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'avg',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_cpu_limit_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_cpu_limit_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: 'c0a5e5b1',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'Limit util %',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'avg',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_memory_usage--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_memory_usage',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: 'f8ae7d0f',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'usage',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_memory_request--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_memory_request',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'latest',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: '66fbdd5e',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'requests',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'latest',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_container_memory_limit--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_container_memory_limit',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'latest',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'C',
+ filters: {
+ items: [
+ {
+ id: '1a408383',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_pod_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_pod_name',
+ type: 'tag',
+ },
+ op: 'contains',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'limits',
+ limit: null,
+ orderBy: [],
+ queryName: 'C',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'latest',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_memory_request_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_memory_request_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: 'acdccfa2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'Reqs util %',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'avg',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_memory_limit_utilization--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_memory_limit_utilization',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'B',
+ filters: {
+ items: [
+ {
+ id: 'cc9a85d3',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: 'Limits util %',
+ limit: null,
+ orderBy: [],
+ queryName: 'B',
+ reduceTo: 'avg',
+ spaceAggregation: 'avg',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_io--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_io',
+ type: 'Sum',
+ },
+ aggregateOperator: 'rate',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '2ea33f83',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'rate',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_pod_network_errors--float64--Sum--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_pod_network_errors',
+ type: 'Sum',
+ },
+ aggregateOperator: 'increase',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '7e25d4fb',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_statefulset_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_statefulset_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_statefulset_name,
+ },
+ {
+ id: '47b3adae',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: statefulSet.meta.k8s_namespace_name,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [
+ {
+ dataType: DataTypes.String,
+ id: 'direction--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'direction',
+ type: 'tag',
+ },
+ {
+ dataType: DataTypes.String,
+ id: 'interface--string--tag--false',
+ isColumn: false,
+ isJSON: false,
+ key: 'interface',
+ type: 'tag',
+ },
+ ],
+ having: [],
+ legend: '{{direction}} :: {{interface}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'avg',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'increase',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/index.ts b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/index.ts
new file mode 100644
index 0000000000..efc0182463
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/StatefulSetDetails/index.ts
@@ -0,0 +1,3 @@
+import StatefulSetDetails from './StatefulSetDetails';
+
+export default StatefulSetDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx b/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx
new file mode 100644
index 0000000000..35730263c2
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/StatefulSets/utils.tsx
@@ -0,0 +1,347 @@
+import { Color } from '@signozhq/design-tokens';
+import { Tag, Tooltip } from 'antd';
+import { ColumnType } from 'antd/es/table';
+import {
+ K8sStatefulSetsData,
+ K8sStatefulSetsListPayload,
+} from 'api/infraMonitoring/getsK8sStatefulSetsList';
+import { Group } from 'lucide-react';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+
+import {
+ EntityProgressBar,
+ formatBytes,
+ ValidateColumnValueWrapper,
+} from '../commonUtils';
+import { K8sCategory } from '../constants';
+import { IEntityColumn } from '../utils';
+
+export const defaultAddedColumns: IEntityColumn[] = [
+ {
+ label: 'StatefulSet Name',
+ value: 'statefulsetName',
+ id: 'statefulsetName',
+ canRemove: false,
+ },
+ {
+ label: 'Namespace Name',
+ value: 'namespaceName',
+ id: 'namespaceName',
+ canRemove: false,
+ },
+ {
+ label: 'Available',
+ value: 'available_pods',
+ id: 'available_pods',
+ canRemove: false,
+ },
+ {
+ label: 'Desired',
+ value: 'desired_pods',
+ id: 'desired_pods',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Req Usage (%)',
+ value: 'cpu_request',
+ id: 'cpu_request',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Limit Usage (%)',
+ value: 'cpu_limit',
+ id: 'cpu_limit',
+ canRemove: false,
+ },
+ {
+ label: 'CPU Usage (cores)',
+ value: 'cpu',
+ id: 'cpu',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Req Usage (%)',
+ value: 'memory_request',
+ id: 'memory_request',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Limit Usage (%)',
+ value: 'memory_limit',
+ id: 'memory_limit',
+ canRemove: false,
+ },
+ {
+ label: 'Mem Usage',
+ value: 'memory',
+ id: 'memory',
+ canRemove: false,
+ },
+];
+
+export interface K8sStatefulSetsRowData {
+ key: string;
+ statefulsetUID: string;
+ statefulsetName: React.ReactNode;
+ cpu_request: React.ReactNode;
+ cpu_limit: React.ReactNode;
+ cpu: React.ReactNode;
+ memory_request: React.ReactNode;
+ memory_limit: React.ReactNode;
+ memory: React.ReactNode;
+ desired_pods: React.ReactNode;
+ available_pods: React.ReactNode;
+ namespaceName: React.ReactNode;
+ groupedByMeta?: any;
+}
+
+const statefulSetGroupColumnConfig = {
+ title: (
+ <div className="column-header entity-group-header">
+ <Group size={14} /> STATEFULSET GROUP
+ </div>
+ ),
+ dataIndex: 'statefulSetGroup',
+ key: 'statefulSetGroup',
+ ellipsis: true,
+ width: 150,
+ align: 'left',
+ sorter: false,
+ className: 'column entity-group-header',
+};
+
+export const getK8sStatefulSetsListQuery = (): K8sStatefulSetsListPayload => ({
+ filters: {
+ items: [],
+ op: 'and',
+ },
+ orderBy: { columnName: 'cpu', order: 'desc' },
+});
+
+const columnProgressBarClassName = 'column-progress-bar';
+
+const columnsConfig = [
+ {
+ title: (
+ <div className="column-header-left statefulset-name-header">
+ StatefulSet Name
+ </div>
+ ),
+ dataIndex: 'statefulsetName',
+ key: 'statefulsetName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: (
+ <div className="column-header-left namespace-name-header">
+ Namespace Name
+ </div>
+ ),
+ dataIndex: 'namespaceName',
+ key: 'namespaceName',
+ ellipsis: true,
+ width: 80,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header small-col">Available</div>,
+ dataIndex: 'available_pods',
+ key: 'available_pods',
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column small-col`,
+ },
+ {
+ title: <div className="column-header small-col">Desired</div>,
+ dataIndex: 'desired_pods',
+ key: 'desired_pods',
+ sorter: true,
+ align: 'left',
+ className: `column small-col`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Req Usage (%)</div>,
+ dataIndex: 'cpu_request',
+ key: 'cpu_request',
+ width: 180,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">CPU Limit Usage (%)</div>,
+ dataIndex: 'cpu_limit',
+ key: 'cpu_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">CPU Usage (cores)</div>,
+ dataIndex: 'cpu',
+ key: 'cpu',
+ width: 80,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Req Usage (%)</div>,
+ dataIndex: 'memory_request',
+ key: 'memory_request',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header med-col">Mem Limit Usage (%)</div>,
+ dataIndex: 'memory_limit',
+ key: 'memory_limit',
+ width: 120,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+ {
+ title: <div className="column-header small-col">Mem Usage</div>,
+ dataIndex: 'memory',
+ key: 'memory',
+ width: 80,
+ ellipsis: true,
+ sorter: true,
+ align: 'left',
+ className: `column ${columnProgressBarClassName}`,
+ },
+];
+
+export const getK8sStatefulSetsListColumns = (
+ groupBy: IBuilderQuery['groupBy'],
+): ColumnType<K8sStatefulSetsRowData>[] => {
+ if (groupBy.length > 0) {
+ const filteredColumns = [...columnsConfig].filter(
+ (column) => column.key !== 'statefulsetName',
+ );
+ filteredColumns.unshift(statefulSetGroupColumnConfig);
+ return filteredColumns as ColumnType<K8sStatefulSetsRowData>[];
+ }
+
+ return columnsConfig as ColumnType<K8sStatefulSetsRowData>[];
+};
+
+const getGroupByEle = (
+ statefulSet: K8sStatefulSetsData,
+ groupBy: IBuilderQuery['groupBy'],
+): React.ReactNode => {
+ const groupByValues: string[] = [];
+
+ groupBy.forEach((group) => {
+ groupByValues.push(
+ statefulSet.meta[group.key as keyof typeof statefulSet.meta],
+ );
+ });
+
+ return (
+ <div className="pod-group">
+ {groupByValues.map((value) => (
+ <Tag key={value} color={Color.BG_SLATE_400} className="pod-group-tag-item">
+ {value === '' ? '<no-value>' : value}
+ </Tag>
+ ))}
+ </div>
+ );
+};
+
+export const formatDataForTable = (
+ data: K8sStatefulSetsData[],
+ groupBy: IBuilderQuery['groupBy'],
+): K8sStatefulSetsRowData[] =>
+ data.map((statefulSet, index) => ({
+ key: index.toString(),
+ statefulsetUID: statefulSet.statefulSetName,
+ statefulsetName: (
+ <Tooltip title={statefulSet.meta.k8s_statefulset_name}>
+ {statefulSet.meta.k8s_statefulset_name || ''}
+ </Tooltip>
+ ),
+ namespaceName: (
+ <Tooltip title={statefulSet.meta.k8s_namespace_name}>
+ {statefulSet.meta.k8s_namespace_name || ''}
+ </Tooltip>
+ ),
+ cpu_request: (
+ <ValidateColumnValueWrapper
+ value={statefulSet.cpuRequest}
+ entity={K8sCategory.STATEFULSETS}
+ attribute="CPU Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={statefulSet.cpuRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu_limit: (
+ <ValidateColumnValueWrapper
+ value={statefulSet.cpuLimit}
+ entity={K8sCategory.STATEFULSETS}
+ attribute="CPU Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={statefulSet.cpuLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ cpu: (
+ <ValidateColumnValueWrapper value={statefulSet.cpuUsage}>
+ {statefulSet.cpuUsage}
+ </ValidateColumnValueWrapper>
+ ),
+ memory_request: (
+ <ValidateColumnValueWrapper
+ value={statefulSet.memoryRequest}
+ entity={K8sCategory.STATEFULSETS}
+ attribute="Memory Request"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={statefulSet.memoryRequest} type="request" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory_limit: (
+ <ValidateColumnValueWrapper
+ value={statefulSet.memoryLimit}
+ entity={K8sCategory.STATEFULSETS}
+ attribute="Memory Limit"
+ >
+ <div className="progress-container">
+ <EntityProgressBar value={statefulSet.memoryLimit} type="limit" />
+ </div>
+ </ValidateColumnValueWrapper>
+ ),
+ memory: (
+ <ValidateColumnValueWrapper value={statefulSet.memoryUsage}>
+ {formatBytes(statefulSet.memoryUsage)}
+ </ValidateColumnValueWrapper>
+ ),
+ available_pods: (
+ <ValidateColumnValueWrapper value={statefulSet.availablePods}>
+ {statefulSet.availablePods}
+ </ValidateColumnValueWrapper>
+ ),
+ desired_pods: (
+ <ValidateColumnValueWrapper value={statefulSet.desiredPods}>
+ {statefulSet.desiredPods}
+ </ValidateColumnValueWrapper>
+ ),
+ statefulSetGroup: getGroupByEle(statefulSet, groupBy),
+ meta: statefulSet.meta,
+ ...statefulSet.meta,
+ groupedByMeta: statefulSet.meta,
+ }));
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.styles.scss b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.styles.scss
new file mode 100644
index 0000000000..3d15c37f90
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.styles.scss
@@ -0,0 +1,45 @@
+.infra-monitoring-container {
+ .volumes-list-table {
+ .expanded-table-container {
+ padding-left: 60px;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+ }
+}
+
+.ant-table-cell {
+ &:has(.pvc-name-header) {
+ min-width: 250px !important;
+ max-width: 250px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.namespace-name-header) {
+ min-width: 220px !important;
+ max-width: 220px !important;
+ }
+}
+
+.ant-table-cell {
+ &:has(.small-col) {
+ min-width: 120px !important;
+ max-width: 120px !important;
+ }
+}
+
+.expanded-volumes-list-table {
+ .ant-table-cell {
+ min-width: 223px !important;
+ max-width: 223px !important;
+ }
+
+ .ant-table-row-expand-icon-cell {
+ min-width: 30px !important;
+ max-width: 30px !important;
+ }
+}
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx
new file mode 100644
index 0000000000..149f2cb865
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/K8sVolumesList.tsx
@@ -0,0 +1,508 @@
+/* eslint-disable no-restricted-syntax */
+/* eslint-disable @typescript-eslint/explicit-function-return-type */
+import '../InfraMonitoringK8s.styles.scss';
+import './K8sVolumesList.styles.scss';
+
+import { LoadingOutlined } from '@ant-design/icons';
+import {
+ Button,
+ Spin,
+ Table,
+ TablePaginationConfig,
+ TableProps,
+ Typography,
+} from 'antd';
+import { ColumnType, SorterResult } from 'antd/es/table/interface';
+import logEvent from 'api/common/logEvent';
+import { K8sVolumesListPayload } from 'api/infraMonitoring/getK8sVolumesList';
+import classNames from 'classnames';
+import { useGetK8sVolumesList } from 'hooks/infraMonitoring/useGetK8sVolumesList';
+import { useGetAggregateKeys } from 'hooks/queryBuilder/useGetAggregateKeys';
+import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
+import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+import {
+ K8sCategory,
+ K8sEntityToAggregateAttributeMapping,
+} from '../constants';
+import K8sHeader from '../K8sHeader';
+import LoadingContainer from '../LoadingContainer';
+import {
+ defaultAddedColumns,
+ formatDataForTable,
+ getK8sVolumesListColumns,
+ getK8sVolumesListQuery,
+ K8sVolumesRowData,
+} from './utils';
+import VolumeDetails from './VolumeDetails';
+
+// eslint-disable-next-line sonarjs/cognitive-complexity
+function K8sVolumesList({
+ isFiltersVisible,
+ handleFilterVisibilityChange,
+ quickFiltersLastUpdated,
+}: {
+ isFiltersVisible: boolean;
+ handleFilterVisibilityChange: () => void;
+ quickFiltersLastUpdated: number;
+}): JSX.Element {
+ const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
+ (state) => state.globalTime,
+ );
+
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const [expandedRowKeys, setExpandedRowKeys] = useState<string[]>([]);
+
+ const [orderBy, setOrderBy] = useState<{
+ columnName: string;
+ order: 'asc' | 'desc';
+ } | null>(null);
+
+ const [selectedVolumeUID, setselectedVolumeUID] = useState<string | null>(
+ null,
+ );
+
+ const pageSize = 10;
+
+ const [groupBy, setGroupBy] = useState<IBuilderQuery['groupBy']>([]);
+
+ const [
+ selectedRowData,
+ setSelectedRowData,
+ ] = useState<K8sVolumesRowData | null>(null);
+
+ const [groupByOptions, setGroupByOptions] = useState<
+ { value: string; label: string }[]
+ >([]);
+
+ const { currentQuery } = useQueryBuilder();
+
+ const queryFilters = useMemo(
+ () =>
+ currentQuery?.builder?.queryData[0]?.filters || {
+ items: [],
+ op: 'and',
+ },
+ [currentQuery?.builder?.queryData],
+ );
+
+ // Reset pagination every time quick filters are changed
+ useEffect(() => {
+ setCurrentPage(1);
+ }, [quickFiltersLastUpdated]);
+
+ const createFiltersForSelectedRowData = (
+ selectedRowData: K8sVolumesRowData,
+ groupBy: IBuilderQuery['groupBy'],
+ ): IBuilderQuery['filters'] => {
+ const baseFilters: IBuilderQuery['filters'] = {
+ items: [...queryFilters.items],
+ op: 'and',
+ };
+
+ if (!selectedRowData) return baseFilters;
+
+ const { groupedByMeta } = selectedRowData;
+
+ for (const key of groupBy) {
+ baseFilters.items.push({
+ key: {
+ key: key.key,
+ type: null,
+ },
+ op: '=',
+ value: groupedByMeta[key.key],
+ id: key.key,
+ });
+ }
+
+ return baseFilters;
+ };
+
+ const fetchGroupedByRowDataQuery = useMemo(() => {
+ if (!selectedRowData) return null;
+
+ const baseQuery = getK8sVolumesListQuery();
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ return {
+ ...baseQuery,
+ limit: 10,
+ offset: 0,
+ filters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [minTime, maxTime, orderBy, selectedRowData, groupBy]);
+
+ const {
+ data: groupedByRowData,
+ isFetching: isFetchingGroupedByRowData,
+ isLoading: isLoadingGroupedByRowData,
+ isError: isErrorGroupedByRowData,
+ refetch: fetchGroupedByRowData,
+ } = useGetK8sVolumesList(fetchGroupedByRowDataQuery as K8sVolumesListPayload, {
+ queryKey: ['volumeList', fetchGroupedByRowDataQuery],
+ enabled: !!fetchGroupedByRowDataQuery && !!selectedRowData,
+ });
+
+ const {
+ data: groupByFiltersData,
+ isLoading: isLoadingGroupByFilters,
+ } = useGetAggregateKeys(
+ {
+ dataSource: currentQuery.builder.queryData[0].dataSource,
+ aggregateAttribute: K8sEntityToAggregateAttributeMapping[K8sCategory.NODES],
+ aggregateOperator: 'noop',
+ searchText: '',
+ tagType: '',
+ },
+ {
+ queryKey: [currentQuery.builder.queryData[0].dataSource, 'noop'],
+ },
+ true,
+ K8sCategory.NODES,
+ );
+
+ const query = useMemo(() => {
+ const baseQuery = getK8sVolumesListQuery();
+ const queryPayload = {
+ ...baseQuery,
+ limit: pageSize,
+ offset: (currentPage - 1) * pageSize,
+ filters: queryFilters,
+ start: Math.floor(minTime / 1000000),
+ end: Math.floor(maxTime / 1000000),
+ orderBy,
+ };
+ if (groupBy.length > 0) {
+ queryPayload.groupBy = groupBy;
+ }
+ return queryPayload;
+ }, [currentPage, minTime, maxTime, orderBy, groupBy, queryFilters]);
+
+ const formattedGroupedByVolumesData = useMemo(
+ () =>
+ formatDataForTable(groupedByRowData?.payload?.data?.records || [], groupBy),
+ [groupedByRowData, groupBy],
+ );
+
+ const { data, isFetching, isLoading, isError } = useGetK8sVolumesList(
+ query as K8sVolumesListPayload,
+ {
+ queryKey: ['volumeList', query],
+ enabled: !!query,
+ },
+ );
+
+ const volumesData = useMemo(() => data?.payload?.data?.records || [], [data]);
+ const totalCount = data?.payload?.data?.total || 0;
+
+ const formattedVolumesData = useMemo(
+ () => formatDataForTable(volumesData, groupBy),
+ [volumesData, groupBy],
+ );
+
+ const columns = useMemo(() => getK8sVolumesListColumns(groupBy), [groupBy]);
+
+ const handleGroupByRowClick = (record: K8sVolumesRowData): void => {
+ setSelectedRowData(record);
+
+ if (expandedRowKeys.includes(record.key)) {
+ setExpandedRowKeys(expandedRowKeys.filter((key) => key !== record.key));
+ } else {
+ setExpandedRowKeys([record.key]);
+ }
+ };
+
+ useEffect(() => {
+ if (selectedRowData) {
+ fetchGroupedByRowData();
+ }
+ }, [selectedRowData, fetchGroupedByRowData]);
+
+ const handleTableChange: TableProps<K8sVolumesRowData>['onChange'] = useCallback(
+ (
+ pagination: TablePaginationConfig,
+ _filters: Record<string, (string | number | boolean)[] | null>,
+ sorter: SorterResult<K8sVolumesRowData> | SorterResult<K8sVolumesRowData>[],
+ ): void => {
+ if (pagination.current) {
+ setCurrentPage(pagination.current);
+ }
+
+ if ('field' in sorter && sorter.order) {
+ setOrderBy({
+ columnName: sorter.field as string,
+ order: sorter.order === 'ascend' ? 'asc' : 'desc',
+ });
+ } else {
+ setOrderBy(null);
+ }
+ },
+ [],
+ );
+
+ const { handleChangeQueryData } = useQueryOperations({
+ index: 0,
+ query: currentQuery.builder.queryData[0],
+ entityVersion: '',
+ });
+
+ const handleFiltersChange = useCallback(
+ (value: IBuilderQuery['filters']): void => {
+ handleChangeQueryData('filters', value);
+ setCurrentPage(1);
+
+ logEvent('Infra Monitoring: K8s list filters applied', {
+ filters: value,
+ });
+ },
+ [handleChangeQueryData],
+ );
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: K8s list page visited', {});
+ }, []);
+
+ const selectedVolumeData = useMemo(() => {
+ if (!selectedVolumeUID) return null;
+ return (
+ volumesData.find(
+ (volume) => volume.persistentVolumeClaimName === selectedVolumeUID,
+ ) || null
+ );
+ }, [selectedVolumeUID, volumesData]);
+
+ const handleRowClick = (record: K8sVolumesRowData): void => {
+ if (groupBy.length === 0) {
+ setSelectedRowData(null);
+ setselectedVolumeUID(record.volumeUID);
+ } else {
+ handleGroupByRowClick(record);
+ }
+
+ logEvent('Infra Monitoring: K8s volume list item clicked', {
+ volumeUID: record.volumeUID,
+ });
+ };
+
+ const nestedColumns = useMemo(() => getK8sVolumesListColumns([]), []);
+
+ const isGroupedByAttribute = groupBy.length > 0;
+
+ const handleExpandedRowViewAllClick = (): void => {
+ if (!selectedRowData) return;
+
+ const filters = createFiltersForSelectedRowData(selectedRowData, groupBy);
+
+ handleFiltersChange(filters);
+
+ setCurrentPage(1);
+ setSelectedRowData(null);
+ setGroupBy([]);
+ setOrderBy(null);
+ };
+
+ const expandedRowRender = (): JSX.Element => (
+ <div className="expanded-table-container">
+ {isErrorGroupedByRowData && (
+ <Typography>{groupedByRowData?.error || 'Something went wrong'}</Typography>
+ )}
+ {isFetchingGroupedByRowData || isLoadingGroupedByRowData ? (
+ <LoadingContainer />
+ ) : (
+ <div className="expanded-table">
+ <Table
+ columns={nestedColumns as ColumnType<K8sVolumesRowData>[]}
+ dataSource={formattedGroupedByVolumesData}
+ pagination={false}
+ scroll={{ x: true }}
+ tableLayout="fixed"
+ size="small"
+ loading={{
+ spinning: isFetchingGroupedByRowData || isLoadingGroupedByRowData,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ showHeader={false}
+ />
+
+ {groupedByRowData?.payload?.data?.total &&
+ groupedByRowData?.payload?.data?.total > 10 ? (
+ <div className="expanded-table-footer">
+ <Button
+ type="default"
+ size="small"
+ className="periscope-btn secondary"
+ onClick={handleExpandedRowViewAllClick}
+ >
+ View All
+ </Button>
+ </div>
+ ) : null}
+ </div>
+ )}
+ </div>
+ );
+
+ const expandRowIconRenderer = ({
+ expanded,
+ onExpand,
+ record,
+ }: {
+ expanded: boolean;
+ onExpand: (
+ record: K8sVolumesRowData,
+ e: React.MouseEvent<HTMLButtonElement>,
+ ) => void;
+ record: K8sVolumesRowData;
+ }): JSX.Element | null => {
+ if (!isGroupedByAttribute) {
+ return null;
+ }
+
+ return expanded ? (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronDown size={14} />
+ </Button>
+ ) : (
+ <Button
+ className="periscope-btn ghost"
+ onClick={(e: React.MouseEvent<HTMLButtonElement>): void =>
+ onExpand(record, e)
+ }
+ role="button"
+ >
+ <ChevronRight size={14} />
+ </Button>
+ );
+ };
+
+ const handleCloseVolumeDetail = (): void => {
+ setselectedVolumeUID(null);
+ };
+
+ const handleGroupByChange = useCallback(
+ (value: IBuilderQuery['groupBy']) => {
+ const groupBy = [];
+
+ for (let index = 0; index < value.length; index++) {
+ const element = (value[index] as unknown) as string;
+
+ const key = groupByFiltersData?.payload?.attributeKeys?.find(
+ (key) => key.key === element,
+ );
+
+ if (key) {
+ groupBy.push(key);
+ }
+ }
+
+ setCurrentPage(1);
+ setGroupBy(groupBy);
+ setExpandedRowKeys([]);
+ },
+ [groupByFiltersData],
+ );
+
+ useEffect(() => {
+ if (groupByFiltersData?.payload) {
+ setGroupByOptions(
+ groupByFiltersData?.payload?.attributeKeys?.map((filter) => ({
+ value: filter.key,
+ label: filter.key,
+ })) || [],
+ );
+ }
+ }, [groupByFiltersData]);
+
+ return (
+ <div className="k8s-list">
+ <K8sHeader
+ isFiltersVisible={isFiltersVisible}
+ handleFilterVisibilityChange={handleFilterVisibilityChange}
+ defaultAddedColumns={defaultAddedColumns}
+ handleFiltersChange={handleFiltersChange}
+ groupByOptions={groupByOptions}
+ isLoadingGroupByFilters={isLoadingGroupByFilters}
+ handleGroupByChange={handleGroupByChange}
+ selectedGroupBy={groupBy}
+ entity={K8sCategory.NODES}
+ />
+ {isError && <Typography>{data?.error || 'Something went wrong'}</Typography>}
+
+ <Table
+ className={classNames('k8s-list-table', 'volumes-list-table', {
+ 'expanded-volumes-list-table': isGroupedByAttribute,
+ })}
+ dataSource={isFetching || isLoading ? [] : formattedVolumesData}
+ columns={columns}
+ pagination={{
+ current: currentPage,
+ pageSize,
+ total: totalCount,
+ showSizeChanger: false,
+ hideOnSinglePage: true,
+ }}
+ scroll={{ x: true }}
+ loading={{
+ spinning: isFetching || isLoading,
+ indicator: <Spin indicator={<LoadingOutlined size={14} spin />} />,
+ }}
+ locale={{
+ emptyText:
+ isFetching || isLoading ? null : (
+ <div className="no-filtered-hosts-message-container">
+ <div className="no-filtered-hosts-message-content">
+ <img
+ src="/Icons/emptyState.svg"
+ alt="thinking-emoji"
+ className="empty-state-svg"
+ />
+
+ <Typography.Text className="no-filtered-hosts-message">
+ This query had no results. Edit your query and try again!
+ </Typography.Text>
+ </div>
+ </div>
+ ),
+ }}
+ tableLayout="fixed"
+ onChange={handleTableChange}
+ onRow={(record): { onClick: () => void; className: string } => ({
+ onClick: (): void => handleRowClick(record),
+ className: 'clickable-row',
+ })}
+ expandable={{
+ expandedRowRender: isGroupedByAttribute ? expandedRowRender : undefined,
+ expandIcon: expandRowIconRenderer,
+ expandedRowKeys,
+ }}
+ />
+
+ <VolumeDetails
+ volume={selectedVolumeData}
+ isModalTimeSelection
+ onClose={handleCloseVolumeDetail}
+ />
+ </div>
+ );
+}
+
+export default K8sVolumesList;
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VolumeDetails.tsx b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VolumeDetails.tsx
new file mode 100644
index 0000000000..b5bae03aee
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VolumeDetails.tsx
@@ -0,0 +1,196 @@
+/* eslint-disable sonarjs/no-identical-functions */
+import '../../EntityDetailsUtils/entityDetails.styles.scss';
+
+import { Color, Spacing } from '@signozhq/design-tokens';
+import { Divider, Drawer, Tooltip, Typography } from 'antd';
+import logEvent from 'api/common/logEvent';
+import { K8sCategory } from 'container/InfraMonitoringK8s/constants';
+import {
+ CustomTimeType,
+ Time,
+} from 'container/TopNav/DateTimeSelectionV2/config';
+import { useIsDarkMode } from 'hooks/useDarkMode';
+import GetMinMax from 'lib/getMinMax';
+import { X } from 'lucide-react';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useSelector } from 'react-redux';
+import { AppState } from 'store/reducers';
+import { GlobalReducer } from 'types/reducer/globalTime';
+
+import VolumeMetrics from '../../EntityDetailsUtils/EntityMetrics';
+import { getVolumeQueryPayload, volumeWidgetInfo } from './constants';
+import { VolumeDetailsProps } from './VoumeDetails.interfaces';
+
+function VolumeDetails({
+ volume,
+ onClose,
+ isModalTimeSelection,
+}: VolumeDetailsProps): JSX.Element {
+ const { maxTime, minTime, selectedTime } = useSelector<
+ AppState,
+ GlobalReducer
+ >((state) => state.globalTime);
+
+ const startMs = useMemo(() => Math.floor(Number(minTime) / 1000000000), [
+ minTime,
+ ]);
+ const endMs = useMemo(() => Math.floor(Number(maxTime) / 1000000000), [
+ maxTime,
+ ]);
+
+ const [modalTimeRange, setModalTimeRange] = useState(() => ({
+ startTime: startMs,
+ endTime: endMs,
+ }));
+
+ const [selectedInterval, setSelectedInterval] = useState<Time>(
+ selectedTime as Time,
+ );
+
+ const isDarkMode = useIsDarkMode();
+
+ useEffect(() => {
+ logEvent('Infra Monitoring: Volumes list details page visited', {
+ volume: volume?.persistentVolumeClaimName,
+ });
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ }, [selectedTime, minTime, maxTime]);
+
+ const handleTimeChange = useCallback(
+ (interval: Time | CustomTimeType, dateTimeRange?: [number, number]): void => {
+ setSelectedInterval(interval as Time);
+
+ if (interval === 'custom' && dateTimeRange) {
+ setModalTimeRange({
+ startTime: Math.floor(dateTimeRange[0] / 1000),
+ endTime: Math.floor(dateTimeRange[1] / 1000),
+ });
+ } else {
+ const { maxTime, minTime } = GetMinMax(interval);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+
+ logEvent('Infra Monitoring: Volumes list details time updated', {
+ volume: volume?.persistentVolumeClaimName,
+ interval,
+ });
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const handleClose = (): void => {
+ setSelectedInterval(selectedTime as Time);
+
+ if (selectedTime !== 'custom') {
+ const { maxTime, minTime } = GetMinMax(selectedTime);
+
+ setModalTimeRange({
+ startTime: Math.floor(minTime / 1000000000),
+ endTime: Math.floor(maxTime / 1000000000),
+ });
+ }
+ onClose();
+ };
+
+ return (
+ <Drawer
+ width="70%"
+ title={
+ <>
+ <Divider type="vertical" />
+ <Typography.Text className="title">
+ {volume?.persistentVolumeClaimName}
+ </Typography.Text>
+ </>
+ }
+ placement="right"
+ onClose={handleClose}
+ open={!!volume}
+ style={{
+ overscrollBehavior: 'contain',
+ background: isDarkMode ? Color.BG_INK_400 : Color.BG_VANILLA_100,
+ }}
+ className="entity-detail-drawer"
+ destroyOnClose
+ closeIcon={<X size={16} style={{ marginTop: Spacing.MARGIN_1 }} />}
+ >
+ {volume && (
+ <>
+ <div className="entity-detail-drawer__entity">
+ <div className="entity-details-grid">
+ <div className="labels-row">
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ PVC Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Cluster Name
+ </Typography.Text>
+ <Typography.Text
+ type="secondary"
+ className="entity-details-metadata-label"
+ >
+ Namespace Name
+ </Typography.Text>
+ </div>
+ <div className="values-row">
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={volume.persistentVolumeClaimName}>
+ {volume.persistentVolumeClaimName}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={volume.meta.k8s_cluster_name}>
+ {volume.meta.k8s_cluster_name}
+ </Tooltip>
+ </Typography.Text>
+ <Typography.Text className="entity-details-metadata-value">
+ <Tooltip title={volume.meta.k8s_namespace_name}>
+ {volume.meta.k8s_namespace_name}
+ </Tooltip>
+ </Typography.Text>
+ </div>
+ </div>
+ </div>
+
+ <VolumeMetrics
+ timeRange={modalTimeRange}
+ isModalTimeSelection={isModalTimeSelection}
+ handleTimeChange={handleTimeChange}
+ selectedInterval={selectedInterval}
+ entity={volume}
+ entityWidgetInfo={volumeWidgetInfo}
+ getEntityQueryPayload={getVolumeQueryPayload}
+ queryKey="volumeMetrics"
+ category={K8sCategory.VOLUMES}
+ />
+ </>
+ )}
+ </Drawer>
+ );
+}
+
+export default VolumeDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VoumeDetails.interfaces.ts b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VoumeDetails.interfaces.ts
new file mode 100644
index 0000000000..427ef59da0
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/VoumeDetails.interfaces.ts
@@ -0,0 +1,7 @@
+import { K8sVolumesData } from 'api/infraMonitoring/getK8sVolumesList';
+
+export type VolumeDetailsProps = {
+ volume: K8sVolumesData | null;
+ isModalTimeSelection: boolean;
+ onClose: () => void;
+};
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts
new file mode 100644
index 0000000000..089c097937
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/constants.ts
@@ -0,0 +1,595 @@
+/* eslint-disable sonarjs/no-duplicate-string */
+import { K8sVolumesData } from 'api/infraMonitoring/getK8sVolumesList';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { EQueryType } from 'types/common/dashboard';
+import { DataSource } from 'types/common/queryBuilder';
+import { v4 } from 'uuid';
+
+export const volumeWidgetInfo = [
+ {
+ title: 'Volume available',
+ yAxisUnit: 'bytes',
+ },
+ {
+ title: 'Volume capacity',
+ yAxisUnit: 'bytes',
+ },
+ {
+ title: 'Volume inodes used',
+ yAxisUnit: 'short',
+ },
+ {
+ title: 'Volume inodes',
+ yAxisUnit: 'short',
+ },
+ {
+ title: 'Volume inodes free',
+ yAxisUnit: 'short',
+ },
+];
+
+export const getVolumeQueryPayload = (
+ volume: K8sVolumesData,
+ start: number,
+ end: number,
+): GetQueryResultsProps[] => [
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_volume_available--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_volume_available',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_cluster_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_cluster_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: volume.meta.k8s_cluster_name,
+ },
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: 'in',
+ value: [volume.meta.k8s_namespace_name],
+ },
+ {
+ id: '217757e9',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_volume_type--string--tag--false',
+ isColumn: false,
+ key: 'k8s_volume_type',
+ type: 'tag',
+ },
+ op: 'in',
+ value: ['persistentVolumeClaim'],
+ },
+ {
+ id: '34754bda',
+ key: {
+ key: 'k8s_persistentvolumeclaim_name',
+ dataType: DataTypes.String,
+ type: 'tag',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_persistentvolumeclaim_name--string--tag--false',
+ },
+ op: '=',
+ value: volume.persistentVolumeClaimName,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'sum',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_volume_capacity--float64--Gauge--true',
+ isColumn: true,
+ isJSON: false,
+ key: 'k8s_volume_capacity',
+ type: 'Gauge',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_cluster_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_cluster_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: volume.meta.k8s_cluster_name,
+ },
+ {
+ id: '0cdebb88',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: 'in',
+ value: [volume.meta.k8s_namespace_name],
+ },
+ {
+ id: 'e0e880ce',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_volume_type--string--tag--false',
+ isColumn: false,
+ key: 'k8s_volume_type',
+ type: 'tag',
+ },
+ op: 'in',
+ value: ['persistentVolumeClaim'],
+ },
+ {
+ id: '34754bda',
+ key: {
+ key: 'k8s_persistentvolumeclaim_name',
+ dataType: DataTypes.String,
+ type: 'tag',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_persistentvolumeclaim_name--string--tag--false',
+ },
+ op: '=',
+ value: volume.persistentVolumeClaimName,
+ },
+ ],
+ op: 'AND',
+ },
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'sum',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_volume_inodes_used--float64----true',
+ isColumn: true,
+ key: 'k8s_volume_inodes_used',
+ type: '',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_cluster_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_cluster_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: volume.meta.k8s_cluster_name,
+ },
+ {
+ id: '46393c61',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: 'in',
+ value: [volume.meta.k8s_namespace_name],
+ },
+ {
+ id: '450ee3cb',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_volume_type--string--tag--false',
+ isColumn: false,
+ key: 'k8s_volume_type',
+ type: 'tag',
+ },
+ op: 'in',
+ value: ['persistentVolumeClaim'],
+ },
+ {
+ id: '34754bda',
+ key: {
+ key: 'k8s_persistentvolumeclaim_name',
+ dataType: DataTypes.String,
+ type: 'tag',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_persistentvolumeclaim_name--string--tag--false',
+ },
+ op: '=',
+ value: volume.persistentVolumeClaimName,
+ },
+ ],
+ op: 'AND',
+ },
+ groupBy: [],
+ having: [],
+ legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'sum',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ functions: [],
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_volume_inodes--float64----true',
+ isColumn: true,
+ key: 'k8s_volume_inodes',
+ type: '',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_cluster_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_cluster_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: volume.meta.k8s_cluster_name,
+ },
+ {
+ id: '5a604bad',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: 'in',
+ value: [volume.meta.k8s_namespace_name],
+ },
+ {
+ id: '24b074f3',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_volume_type--string--tag--false',
+ isColumn: false,
+ key: 'k8s_volume_type',
+ type: 'tag',
+ },
+ op: 'in',
+ value: ['persistentVolumeClaim'],
+ },
+ {
+ id: '34754bda',
+ key: {
+ key: 'k8s_persistentvolumeclaim_name',
+ dataType: DataTypes.String,
+ type: 'tag',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_persistentvolumeclaim_name--string--tag--false',
+ },
+ op: '=',
+ value: volume.persistentVolumeClaimName,
+ },
+ ],
+ op: 'AND',
+ },
+ groupBy: [],
+ having: [],
+ legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'sum',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ functions: [],
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+ {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: [
+ {
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: 'k8s_volume_inodes_free--float64----true',
+ isColumn: true,
+ key: 'k8s_volume_inodes_free',
+ type: '',
+ },
+ aggregateOperator: 'avg',
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: 'A',
+ filters: {
+ items: [
+ {
+ id: '6077fbc2',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_cluster_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_cluster_name',
+ type: 'tag',
+ },
+ op: '=',
+ value: volume.meta.k8s_cluster_name,
+ },
+ {
+ id: '8f01b14d',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_namespace_name--string--tag--false',
+ isColumn: false,
+ key: 'k8s_namespace_name',
+ type: 'tag',
+ },
+ op: 'in',
+ value: [volume.meta.k8s_namespace_name],
+ },
+ {
+ id: 'a72c99da',
+ key: {
+ dataType: DataTypes.String,
+ id: 'k8s_volume_type--string--tag--false',
+ isColumn: false,
+ key: 'k8s_volume_type',
+ type: 'tag',
+ },
+ op: 'in',
+ value: ['persistentVolumeClaim'],
+ },
+ {
+ id: '34754bda',
+ key: {
+ key: 'k8s_persistentvolumeclaim_name',
+ dataType: DataTypes.String,
+ type: 'tag',
+ isColumn: false,
+ isJSON: false,
+ id: 'k8s_persistentvolumeclaim_name--string--tag--false',
+ },
+ op: '=',
+ value: volume.persistentVolumeClaimName,
+ },
+ ],
+ op: 'AND',
+ },
+ groupBy: [],
+ having: [],
+ legend: '{{k8s_namespace_name}}-{{k8s_pod_name}}',
+ limit: null,
+ orderBy: [],
+ queryName: 'A',
+ reduceTo: 'sum',
+ spaceAggregation: 'sum',
+ stepInterval: 60,
+ timeAggregation: 'avg',
+ functions: [],
+ },
+ ],
+ queryFormulas: [],
+ },
+ clickhouse_sql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ id: v4(),
+ promql: [
+ {
+ disabled: false,
+ legend: '',
+ name: 'A',
+ query: '',
+ },
+ ],
+ queryType: EQueryType.QUERY_BUILDER,
+ },
+ variables: {},
+ formatForWeb: false,
+ start,
+ end,
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/index.ts b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/index.ts
new file mode 100644
index 0000000000..36bfaf26c4
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/VolumeDetails/index.ts
@@ -0,0 +1,3 @@
+import VolumeDetails from './VolumeDetails';
+
+export default VolumeDetails;
diff --git a/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx b/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx
new file mode 100644
index 0000000000..6b8db6ea48
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8s/Volumes/utils.tsx
@@ -0,0 +1,202 @@
+import { Color } from '@signozhq/design-tokens';
+import { Tag, Tooltip } from 'antd';
+import { ColumnType } from 'antd/es/table';
+import {
+ K8sVolumesData,
+ K8sVolumesListPayload,
+} from 'api/infraMonitoring/getK8sVolumesList';
+import { Group } from 'lucide-react';
+import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
+
+import { formatBytes, ValidateColumnValueWrapper } from '../commonUtils';
+import { IEntityColumn } from '../utils';
+
+export const defaultAddedColumns: IEntityColumn[] = [
+ {
+ label: 'PVC Name',
+ value: 'pvcName',
+ id: 'pvcName',
+ canRemove: false,
+ },
+ {
+ label: 'Namespace Name',
+ value: 'namespaceName',
+ id: 'namespaceName',
+ canRemove: false,
+ },
+ {
+ label: 'Volume Capacity',
+ value: 'capacity',
+ id: 'capacity',
+ canRemove: false,
+ },
+ {
+ label: 'Volume Utilization',
+ value: 'usage',
+ id: 'usage',
+ canRemove: false,
+ },
+ {
+ label: 'Volume Available',
+ value: 'available',
+ id: 'available',
+ canRemove: false,
+ },
+];
+
+export interface K8sVolumesRowData {
+ key: string;
+ volumeUID: string;
+ pvcName: React.ReactNode;
+ namespaceName: React.ReactNode;
+ capacity: React.ReactNode;
+ usage: React.ReactNode;
+ available: React.ReactNode;
+ groupedByMeta?: any;
+}
+
+const volumeGroupColumnConfig = {
+ title: (
+ <div className="column-header entity-group-header">
+ <Group size={14} /> VOLUME GROUP
+ </div>
+ ),
+ dataIndex: 'volumeGroup',
+ key: 'volumeGroup',
+ ellipsis: true,
+ width: 150,
+ align: 'left',
+ sorter: false,
+ className: 'column entity-group-header',
+};
+
+export const getK8sVolumesListQuery = (): K8sVolumesListPayload => ({
+ filters: {
+ items: [],
+ op: 'and',
+ },
+ orderBy: { columnName: 'cpu', order: 'desc' },
+});
+
+const columnsConfig = [
+ {
+ title: <div className="column-header-left pvc-name-header">PVC Name</div>,
+ dataIndex: 'pvcName',
+ key: 'pvcName',
+ ellipsis: true,
+ width: 120,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: (
+ <div className="column-header-left namespace-name-header">
+ Namespace Name
+ </div>
+ ),
+ dataIndex: 'namespaceName',
+ key: 'namespaceName',
+ ellipsis: true,
+ width: 120,
+ sorter: false,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header-left small-col">Volume Capacity</div>,
+ dataIndex: 'capacity',
+ key: 'capacity',
+ ellipsis: true,
+ width: 120,
+ sorter: true,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header-left small-col">Volume Utilization</div>,
+ dataIndex: 'usage',
+ key: 'usage',
+ width: 100,
+ sorter: true,
+ align: 'left',
+ },
+ {
+ title: <div className="column-header-left small-col">Volume Available</div>,
+ dataIndex: 'available',
+ key: 'available',
+ width: 80,
+ sorter: true,
+ align: 'left',
+ },
+];
+
+export const getK8sVolumesListColumns = (
+ groupBy: IBuilderQuery['groupBy'],
+): ColumnType<K8sVolumesRowData>[] => {
+ if (groupBy.length > 0) {
+ const filteredColumns = [...columnsConfig].filter(
+ (column) => column.key !== 'pvcName',
+ );
+ filteredColumns.unshift(volumeGroupColumnConfig);
+ return filteredColumns as ColumnType<K8sVolumesRowData>[];
+ }
+
+ return columnsConfig as ColumnType<K8sVolumesRowData>[];
+};
+
+const getGroupByEle = (
+ volume: K8sVolumesData,
+ groupBy: IBuilderQuery['groupBy'],
+): React.ReactNode => {
+ const groupByValues: string[] = [];
+
+ groupBy.forEach((group) => {
+ groupByValues.push(volume.meta[group.key as keyof typeof volume.meta]);
+ });
+
+ return (
+ <div className="pod-group">
+ {groupByValues.map((value) => (
+ <Tag key={value} color={Color.BG_SLATE_400} className="pod-group-tag-item">
+ {value === '' ? '<no-value>' : value}
+ </Tag>
+ ))}
+ </div>
+ );
+};
+
+export const formatDataForTable = (
+ data: K8sVolumesData[],
+ groupBy: IBuilderQuery['groupBy'],
+): K8sVolumesRowData[] =>
+ data.map((volume, index) => ({
+ key: index.toString(),
+ volumeUID: volume.persistentVolumeClaimName,
+ pvcName: (
+ <Tooltip title={volume.persistentVolumeClaimName}>
+ {volume.persistentVolumeClaimName || ''}
+ </Tooltip>
+ ),
+ namespaceName: (
+ <Tooltip title={volume.meta.k8s_namespace_name}>
+ {volume.meta.k8s_namespace_name || ''}
+ </Tooltip>
+ ),
+ available: (
+ <ValidateColumnValueWrapper value={volume.volumeAvailable}>
+ {formatBytes(volume.volumeAvailable)}
+ </ValidateColumnValueWrapper>
+ ),
+ capacity: (
+ <ValidateColumnValueWrapper value={volume.volumeCapacity}>
+ {formatBytes(volume.volumeCapacity)}
+ </ValidateColumnValueWrapper>
+ ),
+ usage: (
+ <ValidateColumnValueWrapper value={volume.volumeUsage}>
+ {formatBytes(volume.volumeUsage)}
+ </ValidateColumnValueWrapper>
+ ),
+ volumeGroup: getGroupByEle(volume, groupBy),
+ meta: volume.meta,
+ ...volume.meta,
+ groupedByMeta: volume.meta,
+ }));
diff --git a/frontend/src/container/InfraMonitoringK8s/constants.ts b/frontend/src/container/InfraMonitoringK8s/constants.ts
index c04ae05c76..928462fc60 100644
--- a/frontend/src/container/InfraMonitoringK8s/constants.ts
+++ b/frontend/src/container/InfraMonitoringK8s/constants.ts
@@ -44,8 +44,8 @@ export const K8sEntityToAggregateAttributeMapping = {
[K8sCategory.STATEFULSETS]: 'k8s_pod_cpu_utilization',
[K8sCategory.DAEMONSETS]: 'k8s_pod_cpu_utilization',
[K8sCategory.CONTAINERS]: 'k8s_pod_cpu_utilization',
- [K8sCategory.JOBS]: 'k8s_pod_cpu_utilization',
- [K8sCategory.VOLUMES]: 'k8s_pod_cpu_utilization',
+ [K8sCategory.JOBS]: 'k8s_job_desired_successful_pods',
+ [K8sCategory.VOLUMES]: 'k8s_volume_capacity',
};
export const PodsQuickFiltersConfig: IQuickFiltersConfig[] = [
@@ -275,14 +275,47 @@ export const ContainersQuickFiltersConfig: IQuickFiltersConfig[] = [
export const VolumesQuickFiltersConfig: IQuickFiltersConfig[] = [
{
type: FiltersType.CHECKBOX,
- title: 'Volume',
+ title: 'PVC Volume Claim Name',
attributeKey: {
- key: 'k8s_volume_name',
+ key: 'k8s_persistentvolumeclaim_name',
dataType: DataTypes.String,
type: 'resource',
isColumn: false,
isJSON: false,
},
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_volume_capacity',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Namespace Name',
+ attributeKey: {
+ key: 'k8s_namespace_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_volume_capacity',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Cluster Name',
+ attributeKey: {
+ key: 'k8s_cluster_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_volume_capacity',
+ dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
@@ -338,7 +371,7 @@ export const DeploymentsQuickFiltersConfig: IQuickFiltersConfig[] = [
export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
{
type: FiltersType.CHECKBOX,
- title: 'Statefulset',
+ title: 'Statefulset Name',
attributeKey: {
key: 'k8s_statefulset_name',
dataType: DataTypes.String,
@@ -346,6 +379,39 @@ export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
isColumn: false,
isJSON: false,
},
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Namespace Name',
+ attributeKey: {
+ key: 'k8s_namespace_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Cluster Name',
+ attributeKey: {
+ key: 'k8s_cluster_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
@@ -353,7 +419,7 @@ export const StatefulsetsQuickFiltersConfig: IQuickFiltersConfig[] = [
export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
{
type: FiltersType.CHECKBOX,
- title: 'DaemonSet',
+ title: 'DaemonSet Name',
attributeKey: {
key: 'k8s_daemonset_name',
dataType: DataTypes.String,
@@ -361,6 +427,39 @@ export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
isColumn: false,
isJSON: false,
},
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Namespace Name',
+ attributeKey: {
+ key: 'k8s_namespace_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Cluster Name',
+ attributeKey: {
+ key: 'k8s_cluster_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
@@ -368,7 +467,7 @@ export const DaemonSetsQuickFiltersConfig: IQuickFiltersConfig[] = [
export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
{
type: FiltersType.CHECKBOX,
- title: 'Job',
+ title: 'Job Name',
attributeKey: {
key: 'k8s_job_name',
dataType: DataTypes.String,
@@ -376,6 +475,39 @@ export const JobsQuickFiltersConfig: IQuickFiltersConfig[] = [
isColumn: false,
isJSON: false,
},
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Namespace Name',
+ attributeKey: {
+ key: 'k8s_namespace_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Cluster Name',
+ attributeKey: {
+ key: 'k8s_cluster_name',
+ dataType: DataTypes.String,
+ type: 'resource',
+ isColumn: false,
+ isJSON: false,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: 'k8s_pod_cpu_utilization',
+ dataSource: DataSource.METRICS,
defaultOpen: true,
},
];
diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts
new file mode 100644
index 0000000000..5dde5d62fd
--- /dev/null
+++ b/frontend/src/hooks/infraMonitoring/useGetK8sDaemonSetsList.ts
@@ -0,0 +1,54 @@
+import {
+ getK8sDaemonSetsList,
+ K8sDaemonSetsListPayload,
+ K8sDaemonSetsListResponse,
+} from 'api/infraMonitoring/getK8sDaemonSetsList';
+import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
+import { useMemo } from 'react';
+import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+
+type UseGetK8sDaemonSetsList = (
+ requestData: K8sDaemonSetsListPayload,
+
+ options?: UseQueryOptions<
+ SuccessResponse<K8sDaemonSetsListResponse> | ErrorResponse,
+ Error
+ >,
+
+ headers?: Record<string, string>,
+) => UseQueryResult<
+ SuccessResponse<K8sDaemonSetsListResponse> | ErrorResponse,
+ Error
+>;
+
+export const useGetK8sDaemonSetsList: UseGetK8sDaemonSetsList = (
+ requestData,
+
+ options,
+
+ headers,
+) => {
+ const queryKey = useMemo(() => {
+ if (options?.queryKey && Array.isArray(options.queryKey)) {
+ return [...options.queryKey];
+ }
+
+ if (options?.queryKey && typeof options.queryKey === 'string') {
+ return options.queryKey;
+ }
+
+ return [REACT_QUERY_KEY.GET_DAEMONSET_LIST, requestData];
+ }, [options?.queryKey, requestData]);
+
+ return useQuery<
+ SuccessResponse<K8sDaemonSetsListResponse> | ErrorResponse,
+ Error
+ >({
+ queryFn: ({ signal }) => getK8sDaemonSetsList(requestData, signal, headers),
+
+ ...options,
+
+ queryKey,
+ });
+};
diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts
new file mode 100644
index 0000000000..942dc19bfe
--- /dev/null
+++ b/frontend/src/hooks/infraMonitoring/useGetK8sJobsList.ts
@@ -0,0 +1,51 @@
+import {
+ getK8sJobsList,
+ K8sJobsListPayload,
+ K8sJobsListResponse,
+} from 'api/infraMonitoring/getK8sJobsList';
+import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
+import { useMemo } from 'react';
+import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+
+type UseGetK8sJobsList = (
+ requestData: K8sJobsListPayload,
+
+ options?: UseQueryOptions<
+ SuccessResponse<K8sJobsListResponse> | ErrorResponse,
+ Error
+ >,
+
+ headers?: Record<string, string>,
+) => UseQueryResult<
+ SuccessResponse<K8sJobsListResponse> | ErrorResponse,
+ Error
+>;
+
+export const useGetK8sJobsList: UseGetK8sJobsList = (
+ requestData,
+
+ options,
+
+ headers,
+) => {
+ const queryKey = useMemo(() => {
+ if (options?.queryKey && Array.isArray(options.queryKey)) {
+ return [...options.queryKey];
+ }
+
+ if (options?.queryKey && typeof options.queryKey === 'string') {
+ return options.queryKey;
+ }
+
+ return [REACT_QUERY_KEY.GET_JOB_LIST, requestData];
+ }, [options?.queryKey, requestData]);
+
+ return useQuery<SuccessResponse<K8sJobsListResponse> | ErrorResponse, Error>({
+ queryFn: ({ signal }) => getK8sJobsList(requestData, signal, headers),
+
+ ...options,
+
+ queryKey,
+ });
+};
diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts
new file mode 100644
index 0000000000..941942cba1
--- /dev/null
+++ b/frontend/src/hooks/infraMonitoring/useGetK8sStatefulSetsList.ts
@@ -0,0 +1,54 @@
+import {
+ getK8sStatefulSetsList,
+ K8sStatefulSetsListPayload,
+ K8sStatefulSetsListResponse,
+} from 'api/infraMonitoring/getsK8sStatefulSetsList';
+import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
+import { useMemo } from 'react';
+import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+
+type UseGetK8sStatefulSetsList = (
+ requestData: K8sStatefulSetsListPayload,
+
+ options?: UseQueryOptions<
+ SuccessResponse<K8sStatefulSetsListResponse> | ErrorResponse,
+ Error
+ >,
+
+ headers?: Record<string, string>,
+) => UseQueryResult<
+ SuccessResponse<K8sStatefulSetsListResponse> | ErrorResponse,
+ Error
+>;
+
+export const useGetK8sStatefulSetsList: UseGetK8sStatefulSetsList = (
+ requestData,
+
+ options,
+
+ headers,
+) => {
+ const queryKey = useMemo(() => {
+ if (options?.queryKey && Array.isArray(options.queryKey)) {
+ return [...options.queryKey];
+ }
+
+ if (options?.queryKey && typeof options.queryKey === 'string') {
+ return options.queryKey;
+ }
+
+ return [REACT_QUERY_KEY.GET_STATEFULSET_LIST, requestData];
+ }, [options?.queryKey, requestData]);
+
+ return useQuery<
+ SuccessResponse<K8sStatefulSetsListResponse> | ErrorResponse,
+ Error
+ >({
+ queryFn: ({ signal }) => getK8sStatefulSetsList(requestData, signal, headers),
+
+ ...options,
+
+ queryKey,
+ });
+};
diff --git a/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts b/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts
new file mode 100644
index 0000000000..bc1c4961ea
--- /dev/null
+++ b/frontend/src/hooks/infraMonitoring/useGetK8sVolumesList.ts
@@ -0,0 +1,48 @@
+import {
+ getK8sVolumesList,
+ K8sVolumesListPayload,
+ K8sVolumesListResponse,
+} from 'api/infraMonitoring/getK8sVolumesList';
+import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
+import { useMemo } from 'react';
+import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
+import { ErrorResponse, SuccessResponse } from 'types/api';
+
+type UseGetK8sVolumesList = (
+ requestData: K8sVolumesListPayload,
+ options?: UseQueryOptions<
+ SuccessResponse<K8sVolumesListResponse> | ErrorResponse,
+ Error
+ >,
+ headers?: Record<string, string>,
+) => UseQueryResult<
+ SuccessResponse<K8sVolumesListResponse> | ErrorResponse,
+ Error
+>;
+
+export const useGetK8sVolumesList: UseGetK8sVolumesList = (
+ requestData,
+ options,
+ headers,
+) => {
+ const queryKey = useMemo(() => {
+ if (options?.queryKey && Array.isArray(options.queryKey)) {
+ return [...options.queryKey];
+ }
+
+ if (options?.queryKey && typeof options.queryKey === 'string') {
+ return options.queryKey;
+ }
+
+ return [REACT_QUERY_KEY.GET_VOLUME_LIST, requestData];
+ }, [options?.queryKey, requestData]);
+
+ return useQuery<
+ SuccessResponse<K8sVolumesListResponse> | ErrorResponse,
+ Error
+ >({
+ queryFn: ({ signal }) => getK8sVolumesList(requestData, signal, headers),
+ ...options,
+ queryKey,
+ });
+};
diff --git a/pkg/query-service/app/inframetrics/daemonsets.go b/pkg/query-service/app/inframetrics/daemonsets.go
index 74fe71a2d4..c4db9b2084 100644
--- a/pkg/query-service/app/inframetrics/daemonsets.go
+++ b/pkg/query-service/app/inframetrics/daemonsets.go
@@ -296,7 +296,7 @@ func (d *DaemonSetsRepo) GetDaemonSetList(ctx context.Context, req model.DaemonS
// add additional queries for daemon sets
for _, daemonSetQuery := range builderQueriesForDaemonSets {
- query.CompositeQuery.BuilderQueries[daemonSetQuery.QueryName] = daemonSetQuery
+ query.CompositeQuery.BuilderQueries[daemonSetQuery.QueryName] = daemonSetQuery.Clone()
}
for _, query := range query.CompositeQuery.BuilderQueries {
diff --git a/pkg/query-service/app/inframetrics/deployments.go b/pkg/query-service/app/inframetrics/deployments.go
index da11d48bba..346a186f46 100644
--- a/pkg/query-service/app/inframetrics/deployments.go
+++ b/pkg/query-service/app/inframetrics/deployments.go
@@ -296,7 +296,7 @@ func (d *DeploymentsRepo) GetDeploymentList(ctx context.Context, req model.Deplo
// add additional queries for deployments
for _, deploymentQuery := range builderQueriesForDeployments {
- query.CompositeQuery.BuilderQueries[deploymentQuery.QueryName] = deploymentQuery
+ query.CompositeQuery.BuilderQueries[deploymentQuery.QueryName] = deploymentQuery.Clone()
}
for _, query := range query.CompositeQuery.BuilderQueries {
diff --git a/pkg/query-service/app/inframetrics/jobs.go b/pkg/query-service/app/inframetrics/jobs.go
index 52cf96b35b..dc36954e54 100644
--- a/pkg/query-service/app/inframetrics/jobs.go
+++ b/pkg/query-service/app/inframetrics/jobs.go
@@ -15,7 +15,7 @@ import (
)
var (
- metricToUseForJobs = "k8s_pod_cpu_utilization"
+ metricToUseForJobs = "k8s_job_desired_successful_pods"
k8sJobNameAttrKey = "k8s_job_name"
metricNamesForJobs = map[string]string{
@@ -32,17 +32,17 @@ var (
}
queryNamesForJobs = map[string][]string{
- "cpu": {"A"},
- "cpu_request": {"B", "A"},
- "cpu_limit": {"C", "A"},
- "memory": {"D"},
- "memory_request": {"E", "D"},
- "memory_limit": {"F", "D"},
- "restarts": {"G", "A"},
- "desired_pods": {"H"},
- "active_pods": {"I"},
- "failed_pods": {"J"},
- "successful_pods": {"K"},
+ "cpu": {"A"},
+ "cpu_request": {"B", "A"},
+ "cpu_limit": {"C", "A"},
+ "memory": {"D"},
+ "memory_request": {"E", "D"},
+ "memory_limit": {"F", "D"},
+ "restarts": {"G", "A"},
+ "desired_successful_pods": {"H"},
+ "active_pods": {"I"},
+ "failed_pods": {"J"},
+ "successful_pods": {"K"},
}
builderQueriesForJobs = map[string]*v3.BuilderQuery{
@@ -340,7 +340,7 @@ func (d *JobsRepo) GetJobList(ctx context.Context, req model.JobListRequest) (mo
// add additional queries for jobs
for _, jobQuery := range builderQueriesForJobs {
- query.CompositeQuery.BuilderQueries[jobQuery.QueryName] = jobQuery
+ query.CompositeQuery.BuilderQueries[jobQuery.QueryName] = jobQuery.Clone()
}
for _, query := range query.CompositeQuery.BuilderQueries {
diff --git a/pkg/query-service/app/inframetrics/statefulsets.go b/pkg/query-service/app/inframetrics/statefulsets.go
index ef73e9c061..e4562e17b4 100644
--- a/pkg/query-service/app/inframetrics/statefulsets.go
+++ b/pkg/query-service/app/inframetrics/statefulsets.go
@@ -296,7 +296,7 @@ func (d *StatefulSetsRepo) GetStatefulSetList(ctx context.Context, req model.Sta
// add additional queries for stateful sets
for _, statefulSetQuery := range builderQueriesForStatefulSets {
- query.CompositeQuery.BuilderQueries[statefulSetQuery.QueryName] = statefulSetQuery
+ query.CompositeQuery.BuilderQueries[statefulSetQuery.QueryName] = statefulSetQuery.Clone()
}
for _, query := range query.CompositeQuery.BuilderQueries {
diff --git a/pkg/query-service/app/metrics/v4/helpers/sub_query.go b/pkg/query-service/app/metrics/v4/helpers/sub_query.go
index 793cf2c375..1790f31f66 100644
--- a/pkg/query-service/app/metrics/v4/helpers/sub_query.go
+++ b/pkg/query-service/app/metrics/v4/helpers/sub_query.go
@@ -279,7 +279,10 @@ func PrepareTimeseriesFilterQuery(start, end int64, mq *v3.BuilderQuery) (string
if op == v3.FilterOperatorContains || op == v3.FilterOperatorNotContains {
toFormat = fmt.Sprintf("%%%s%%", toFormat)
}
- fmtVal := utils.ClickHouseFormattedValue(toFormat)
+ var fmtVal string
+ if op != v3.FilterOperatorExists && op != v3.FilterOperatorNotExists {
+ fmtVal = utils.ClickHouseFormattedValue(toFormat)
+ }
switch op {
case v3.FilterOperatorEqual:
conditions = append(conditions, fmt.Sprintf("JSONExtractString(labels, '%s') = %s", item.Key.Key, fmtVal))
diff --git a/pkg/query-service/model/infra.go b/pkg/query-service/model/infra.go
index 3c34e64a04..e9c9318efd 100644
--- a/pkg/query-service/model/infra.go
+++ b/pkg/query-service/model/infra.go
@@ -623,7 +623,7 @@ func (r *JobListResponse) SortBy(orderBy *v3.OrderBy) {
sort.Slice(r.Records, func(i, j int) bool {
return r.Records[i].Restarts > r.Records[j].Restarts
})
- case "desired_pods":
+ case "desired_successful_pods":
sort.Slice(r.Records, func(i, j int) bool {
return r.Records[i].DesiredSuccessfulPods > r.Records[j].DesiredSuccessfulPods
})