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(infra-monitoring): Kubernetes Containers section (#12636)

Ashwin Bhatkaleb2d094b1f77
diff --git a/frontend/src/constants/events.ts b/frontend/src/constants/events.ts
index baa4c573af..5f5a21feed 100644
--- a/frontend/src/constants/events.ts
+++ b/frontend/src/constants/events.ts
@@ -29,6 +29,7 @@ export enum InfraMonitoringEvents {
MetricsView = 'metrics',
Total = 'total',
Cluster = 'cluster',
+ Container = 'container',
DaemonSet = 'daemonSet',
Deployment = 'deployment',
Job = 'job',
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/ColumnHeader.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/ColumnHeader.tsx
index d0a97a9e3e..379254eb7e 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/ColumnHeader.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/ColumnHeader.tsx
@@ -4,8 +4,9 @@ import { TooltipSimple } from '@signozhq/ui/tooltip';
import styles from './ColumnHeader.module.scss';
import cx from 'classnames';
import { MouseEventHandler } from 'react';
+import { DOCS_BASE_URL } from 'constants/app';
-const DOCS_BASE_URL = `${process.env.DOCS_BASE_URL}/docs`;
+const DOCS_ROOT = `${DOCS_BASE_URL}/docs`;
interface ColumnHeaderProps {
children?: React.ReactNode;
@@ -43,7 +44,7 @@ function ColumnHeader({
<div onClick={stopPropagationHandler}>
{tooltipTitle}{' '}
<a
- href={`${DOCS_BASE_URL}${docPath}`}
+ href={`${DOCS_ROOT}${docPath}`}
target="_blank"
rel="noopener"
onClick={stopPropagationHandler}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.module.scss b/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.module.scss
index 587bb3a78a..28c4cce279 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.module.scss
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.module.scss
@@ -2,7 +2,6 @@
display: flex;
align-items: center;
gap: var(--spacing-5);
- padding-left: 4px;
}
.infoIcon {
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.tsx
index 6ef0c46566..742b814796 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/EntityGroupHeader.tsx
@@ -2,8 +2,9 @@ import { Group, Info } from '@signozhq/icons';
import { TooltipSimple } from '@signozhq/ui/tooltip';
import styles from './EntityGroupHeader.module.scss';
+import { DOCS_BASE_URL } from 'constants/app';
-const DOCS_BASE_URL = `${process.env.DOCS_BASE_URL}/docs`;
+const DOCS_ROOT = `${DOCS_BASE_URL}/docs`;
interface EntityGroupHeaderProps {
title: string;
@@ -28,7 +29,7 @@ function EntityGroupHeader({
<>
{tooltipTitle}{' '}
<a
- href={`${DOCS_BASE_URL}${docPath}`}
+ href={`${DOCS_ROOT}${docPath}`}
target="_blank"
rel="noopener"
onClick={(e): void => e.stopPropagation()}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetails.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetails.tsx
index 04b68accb3..5323ce3e8f 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetails.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetails.tsx
@@ -1,12 +1,10 @@
import { useCallback, useEffect, useMemo } from 'react';
import { useQuery } from 'react-query';
-import { useCopyToClipboard } from 'react-use';
-import { Copy, X } from '@signozhq/icons';
+import { X } from '@signozhq/icons';
import { Divider } from '@signozhq/ui/divider';
import { Button } from '@signozhq/ui/button';
import { DrawerWrapper, DrawerWrapperProps } from '@signozhq/ui/drawer';
import { toast } from '@signozhq/ui/sonner';
-import { TooltipSimple } from '@signozhq/ui/tooltip';
import { Typography } from '@signozhq/ui/typography';
import logEvent from 'api/common/logEvent';
import ErrorContent from 'components/ErrorModal/components/ErrorContent';
@@ -20,6 +18,7 @@ import {
import { INFRA_MONITORING_K8S_PARAMS_KEYS } from '../constants';
import { useInfraMonitoringSelectedItemParams } from '../hooks';
+import CopyButton from 'periscope/components/CopyButton/CopyButton';
import LoadingContainer from '../LoadingContainer';
import K8sBaseDetailsContent from './K8sBaseDetailsContent';
@@ -95,12 +94,14 @@ export default function K8sBaseDetails<T>({
selectedItem,
selectedItemParams.clusterName,
selectedItemParams.namespaceName,
+ selectedItemParams.containerName,
),
[
queryKeyPrefix,
selectedItem,
selectedItemParams.clusterName,
selectedItemParams.namespaceName,
+ selectedItemParams.containerName,
selectedTime,
getAutoRefreshQueryKey,
],
@@ -170,14 +171,9 @@ export default function K8sBaseDetails<T>({
[handleClose],
);
- const [, copyToClipboard] = useCopyToClipboard();
-
const handleCopyId = useCallback((): void => {
- if (selectedItem) {
- copyToClipboard(selectedItem);
- toast.success('ID copied to clipboard', { position: 'bottom-left' });
- }
- }, [copyToClipboard, selectedItem]);
+ toast.success('ID copied to clipboard', { position: 'bottom-left' });
+ }, []);
const entityName = entity ? getEntityName(entity) : '';
@@ -211,17 +207,13 @@ export default function K8sBaseDetails<T>({
(isEntityLoading && 'Loading...') ||
'-'}
</Typography.Text>
- <TooltipSimple title="Copy ID">
- <Button
- variant="ghost"
- size="sm"
- color="secondary"
- onClick={handleCopyId}
- data-testid="copy-id-button"
- >
- <Copy size={14} />
- </Button>
- </TooltipSimple>
+ <CopyButton
+ value={selectedItem ?? ''}
+ ariaLabel="Copy ID"
+ className={styles.copyIdButton}
+ testId="copy-id-button"
+ onCopy={handleCopyId}
+ />
</>
) as unknown as string;
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetailsContent.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetailsContent.tsx
index 89743fd888..1d56bb24b6 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetailsContent.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseDetailsContent.tsx
@@ -9,7 +9,6 @@ import {
import { Button } from '@signozhq/ui/button';
import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';
import { TooltipSimple } from '@signozhq/ui/tooltip';
-import { Typography } from '@signozhq/ui/typography';
import logEvent from 'api/common/logEvent';
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
import { InfraMonitoringEvents } from 'constants/events';
@@ -42,6 +41,7 @@ import {
} from '../hooks';
import { EntityCountsSection } from './components/EntityCountsSection/EntityCountsSection';
+import { EntityMetadataItem } from './components/EntityMetadataItem/EntityMetadataItem';
import { K8sBaseDetailsContentProps } from './types';
import { getDrawerDurationMs } from './useDrawerLifecycleStore';
@@ -239,41 +239,18 @@ export default function K8sBaseDetailsContent<T>({
<>
<div className={styles.entityDetailsEntity}>
<div className={styles.entityDetailsGrid}>
- <div className={styles.labelsRow}>
- {metadataConfig.map((config) => (
- <Typography.Text
- key={config.label}
- color="muted"
- size="small"
- weight="medium"
- className={styles.entityDetailsMetadataLabel}
- >
- {config.label}
- </Typography.Text>
- ))}
- </div>
-
- <div className={styles.valuesRow}>
- {metadataConfig.map((config) => {
- const value = config.getValue(entity);
+ {metadataConfig.map((config) => {
+ const value = config.getValue(entity);
- if (config.render) {
- return config.render(value, entity);
- }
-
- const displayValue = String(value);
- return (
- <Typography.Text
- key={config.label}
- size="small"
- weight="medium"
- className={styles.entityDetailsMetadataValue}
- >
- {displayValue}
- </Typography.Text>
- );
- })}
- </div>
+ return (
+ <EntityMetadataItem
+ key={config.label}
+ label={config.label}
+ value={String(value)}
+ renderedValue={config.render?.(value, entity)}
+ />
+ );
+ })}
</div>
{countsConfig &&
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseList.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseList.tsx
index 82e65cdc19..5fd324bc37 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseList.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sBaseList.tsx
@@ -296,6 +296,7 @@ export function K8sBaseList<
params.selectedItem,
params.clusterName,
params.namespaceName,
+ params.containerName,
);
queryClient.setQueryData(detailQueryKey, { data: record });
}
@@ -348,6 +349,12 @@ export function K8sBaseList<
params.namespaceName,
);
}
+ if (params.containerName) {
+ url.searchParams.set(
+ INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CONTAINER_NAME,
+ params.containerName,
+ );
+ }
} else {
url.searchParams.set(
INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM,
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.module.scss b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.module.scss
index b118df1e25..f65f0eabee 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.module.scss
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.module.scss
@@ -19,6 +19,12 @@
& [data-hide-expanded='true'] {
display: none;
}
+
+ // The icon slot is rendered even when the icon inside it is hidden, and the
+ // header's flex gap then indents the title past the values below it.
+ & [data-slot='icon']:has([data-hide-expanded='true']) {
+ display: none;
+ }
}
.expandedTableFooter {
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.tsx
index 728a1f5d8e..3c327ccbd3 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/K8sExpandedRow.tsx
@@ -214,6 +214,7 @@ export function K8sExpandedRow<
params.selectedItem,
params.clusterName,
params.namespaceName,
+ params.containerName,
);
queryClient.setQueryData(detailQueryKey, { data: row });
}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.module.scss b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.module.scss
new file mode 100644
index 0000000000..012a5718f6
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.module.scss
@@ -0,0 +1,44 @@
+.metadataItem {
+ display: flex;
+ flex-direction: column;
+ gap: var(--spacing-1);
+ min-width: 0;
+}
+
+.valueRow {
+ display: flex;
+ align-items: center;
+ gap: var(--spacing-1);
+ min-width: 0;
+}
+
+.label {
+ letter-spacing: 0.44px;
+ text-transform: uppercase;
+}
+
+// Single-line ellipsis rather than Typography's `truncate`, which line-clamps:
+// clamping still wraps the text, so a value breaking at a hyphen ends its line
+// early and leaves a gap between the ellipsis and the copy button.
+//
+// This has to be a block: overflow and text-overflow do not apply to inline
+// boxes, and Typography.Text renders an inline span.
+.value {
+ display: block;
+ min-width: 0;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.valueText {
+ font-family: var(--periscope-font-family-mono);
+}
+
+// Sized to the icon rather than the default 2rem tap target, so it sits flush
+// against the value instead of floating in its own block of padding.
+.copyButton {
+ --button-padding: 2px;
+ --button-height: auto;
+ --button-width: auto;
+}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.tsx
new file mode 100644
index 0000000000..0993b419f3
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/EntityMetadataItem.tsx
@@ -0,0 +1,63 @@
+import { ReactNode, useCallback } from 'react';
+import { toast } from '@signozhq/ui/sonner';
+import { TooltipSimple } from '@signozhq/ui/tooltip';
+import { Typography } from '@signozhq/ui/typography';
+import CopyButton from 'periscope/components/CopyButton/CopyButton';
+
+import styles from './EntityMetadataItem.module.scss';
+
+export interface EntityMetadataItemProps {
+ label: string;
+ value: string;
+ /** An entity-supplied renderer, which opts out of clamping, tooltip and copy. */
+ renderedValue?: ReactNode;
+}
+
+export function EntityMetadataItem({
+ label,
+ value,
+ renderedValue,
+}: EntityMetadataItemProps): JSX.Element {
+ const handleCopy = useCallback((): void => {
+ toast.success(`${label} copied to clipboard`, { position: 'bottom-left' });
+ }, [label]);
+
+ return (
+ <div className={styles.metadataItem}>
+ <Typography.Text
+ color="muted"
+ size="small"
+ weight="medium"
+ className={styles.label}
+ >
+ {label}
+ </Typography.Text>
+
+ {renderedValue ?? (
+ <div className={styles.valueRow}>
+ <TooltipSimple title={value} arrow side="bottom" align="start">
+ <span className={styles.value}>
+ <Typography.Text
+ size="small"
+ weight="medium"
+ className={styles.valueText}
+ >
+ {value}
+ </Typography.Text>
+ </span>
+ </TooltipSimple>
+ {!!value && (
+ <CopyButton
+ value={value}
+ size={10}
+ ariaLabel={`Copy ${label}`}
+ className={styles.copyButton}
+ testId={`copy-metadata-${label.toLowerCase().replace(/\s+/g, '-')}`}
+ onCopy={handleCopy}
+ />
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/__tests__/EntityMetadataItem.test.tsx b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/__tests__/EntityMetadataItem.test.tsx
new file mode 100644
index 0000000000..cdfb0a1948
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/components/EntityMetadataItem/__tests__/EntityMetadataItem.test.tsx
@@ -0,0 +1,110 @@
+import { render, screen, userEvent, waitFor } from 'tests/test-utils';
+
+import { EntityMetadataItem } from '../EntityMetadataItem';
+
+const mockCopyToClipboard = jest.fn();
+
+jest.mock('react-use', () => ({
+ __esModule: true,
+ useCopyToClipboard: (): [unknown, jest.Mock] => [null, mockCopyToClipboard],
+}));
+
+const mockToastSuccess = jest.fn();
+
+jest.mock('@signozhq/ui/sonner', () => ({
+ ...jest.requireActual('@signozhq/ui/sonner'),
+ toast: {
+ success: (...args: unknown[]): unknown => mockToastSuccess(...args),
+ },
+}));
+
+describe('EntityMetadataItem', () => {
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('renders the label and its value', () => {
+ render(<EntityMetadataItem label="Cluster Name" value="prod-cluster" />);
+
+ expect(screen.getByText('Cluster Name')).toBeInTheDocument();
+ expect(screen.getByText('prod-cluster')).toBeInTheDocument();
+ });
+
+ it('copies the full value and confirms which field was copied', async () => {
+ render(
+ <EntityMetadataItem
+ label="Image:Tag"
+ value="ghcr.io/open-telemetry/demo:1.12.0-loadgenerator"
+ />,
+ );
+
+ await userEvent.click(screen.getByTestId('copy-metadata-image:tag'));
+
+ await waitFor(() => {
+ expect(mockCopyToClipboard).toHaveBeenCalledWith(
+ 'ghcr.io/open-telemetry/demo:1.12.0-loadgenerator',
+ );
+ });
+ expect(mockToastSuccess).toHaveBeenCalledWith(
+ 'Image:Tag copied to clipboard',
+ expect.anything(),
+ );
+ });
+
+ it('offers no copy control when the value is empty', () => {
+ render(<EntityMetadataItem label="Node" value="" />);
+
+ expect(screen.queryByTestId('copy-metadata-node')).not.toBeInTheDocument();
+ });
+
+ it('exposes the full value on hover', async () => {
+ render(
+ <EntityMetadataItem
+ label="Node"
+ value="gke-mgmt-pl-generator-e2st4-sp-41c1bdc8-zv4t"
+ />,
+ );
+
+ await userEvent.hover(
+ screen.getByText('gke-mgmt-pl-generator-e2st4-sp-41c1bdc8-zv4t'),
+ );
+
+ await waitFor(() => {
+ expect(
+ screen.getAllByText('gke-mgmt-pl-generator-e2st4-sp-41c1bdc8-zv4t').length,
+ ).toBeGreaterThan(1);
+ });
+ });
+
+ it('never presents the value as clickable', () => {
+ render(<EntityMetadataItem label="Node" value="a-very-long-node-name" />);
+
+ const valueEl = screen.getByText('a-very-long-node-name');
+ expect(valueEl).not.toHaveAttribute('data-interactive');
+ expect(valueEl).not.toHaveAttribute('data-truncate');
+ });
+
+ it('triggers the tooltip from the wrapper, never from the text itself', () => {
+ render(<EntityMetadataItem label="Node" value="a-very-long-node-name" />);
+
+ // Radix merges its handlers onto the trigger, and Typography styles
+ // itself interactive off any merged onClick — so the trigger has to stay
+ // off the text.
+ const textEl = screen.getByText('a-very-long-node-name');
+ expect(textEl).not.toHaveAttribute('data-slot', 'tooltip-trigger');
+ expect(textEl.parentElement).toHaveAttribute('data-slot', 'tooltip-trigger');
+ });
+
+ it('leaves an entity-supplied renderer alone', () => {
+ render(
+ <EntityMetadataItem
+ label="Status"
+ value="running"
+ renderedValue={<span data-testid="custom">custom node</span>}
+ />,
+ );
+
+ expect(screen.getByTestId('custom')).toBeInTheDocument();
+ expect(screen.queryByTestId('copy-metadata-status')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Base/entity.registry.ts b/frontend/src/container/InfraMonitoringK8sV2/Base/entity.registry.ts
index 9783aa3c15..a5cbeb1846 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/Base/entity.registry.ts
+++ b/frontend/src/container/InfraMonitoringK8sV2/Base/entity.registry.ts
@@ -11,6 +11,7 @@ import { jobEntityConfig } from '../Jobs/entity.config';
import { daemonSetEntityConfig } from '../DaemonSets/entity.config';
import { statefulSetEntityConfig } from '../StatefulSets/entity.config';
import { volumeEntityConfig } from '../Volumes/entity.config';
+import { containerEntityConfig } from '../Containers/entity.config';
type AnyEntityConfig = K8sEntityConfig<
K8sEntityData,
@@ -34,6 +35,7 @@ export const entityRegistry: Record<string, AnyEntityConfig> = {
[K8sCategories.DAEMONSETS]: registerConfig(daemonSetEntityConfig),
[K8sCategories.STATEFULSETS]: registerConfig(statefulSetEntityConfig),
[K8sCategories.VOLUMES]: registerConfig(volumeEntityConfig),
+ [K8sCategories.CONTAINERS]: registerConfig(containerEntityConfig),
};
export function getEntityConfig(category: string): AnyEntityConfig | undefined {
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/__tests__/containers.test.ts b/frontend/src/container/InfraMonitoringK8sV2/Containers/__tests__/containers.test.ts
new file mode 100644
index 0000000000..e11e344bfa
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/__tests__/containers.test.ts
@@ -0,0 +1,142 @@
+import { InframonitoringtypesContainerRecordDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ k8sContainerGetSelectedItemExpression,
+ k8sContainerInitialEventsExpression,
+ k8sContainerInitialLogTracesExpression,
+} from 'container/InfraMonitoringK8sV2/Containers/constants';
+import { getContainerMetricsQueryPayload } from 'container/InfraMonitoringK8sV2/Containers/metrics';
+import {
+ getK8sContainerItemKey,
+ getK8sContainerRowKey,
+} from 'container/InfraMonitoringK8sV2/Containers/table.config';
+import { getContainerImageWithTag } from 'container/InfraMonitoringK8sV2/Containers/utils';
+
+function makeContainer(
+ overrides: Partial<InframonitoringtypesContainerRecordDTO> = {},
+): InframonitoringtypesContainerRecordDTO {
+ return {
+ containerName: 'nginx',
+ podUID: 'pod-uid-1',
+ meta: {
+ 'k8s.container.name': 'nginx',
+ 'k8s.pod.uid': 'pod-uid-1',
+ 'k8s.pod.name': 'web-0',
+ 'k8s.namespace.name': 'production',
+ 'k8s.cluster.name': 'prod-cluster',
+ 'container.image.name': 'nginx',
+ 'container.image.tag': '1.27',
+ },
+ ...overrides,
+ } as InframonitoringtypesContainerRecordDTO;
+}
+
+describe('container identity', () => {
+ it('keys a row by the (pod UID, container name) pair', () => {
+ expect(getK8sContainerRowKey(makeContainer())).toBe('pod-uid-1/nginx');
+ });
+
+ it('carries the container name alongside the pod UID into the drawer params', () => {
+ expect(getK8sContainerItemKey(makeContainer())).toStrictEqual({
+ selectedItem: 'pod-uid-1',
+ containerName: 'nginx',
+ clusterName: null,
+ namespaceName: null,
+ });
+ });
+
+ it('falls back to meta when the record fields are empty', () => {
+ const container = makeContainer({ containerName: '', podUID: '' });
+
+ expect(getK8sContainerItemKey(container)).toStrictEqual({
+ selectedItem: 'pod-uid-1',
+ containerName: 'nginx',
+ clusterName: null,
+ namespaceName: null,
+ });
+ });
+
+ it('scopes the details fetch to both halves of the identity', () => {
+ expect(
+ k8sContainerGetSelectedItemExpression({
+ selectedItem: 'pod-uid-1',
+ containerName: 'nginx',
+ }),
+ ).toBe("k8s.pod.uid = 'pod-uid-1' AND k8s.container.name = 'nginx'");
+ });
+});
+
+describe('getContainerImageWithTag', () => {
+ it('renders name and tag together', () => {
+ expect(getContainerImageWithTag(makeContainer())).toBe('nginx:1.27');
+ });
+
+ it('drops the tag when the image is not pinned', () => {
+ const container = makeContainer({
+ meta: { 'container.image.name': 'nginx' },
+ });
+
+ expect(getContainerImageWithTag(container)).toBe('nginx');
+ });
+
+ it('renders nothing when the image name is missing', () => {
+ expect(getContainerImageWithTag(makeContainer({ meta: {} }))).toBe('');
+ });
+});
+
+describe('container drawer expressions', () => {
+ it('scopes logs and traces to the container within its pod', () => {
+ expect(k8sContainerInitialLogTracesExpression(makeContainer())).toBe(
+ "k8s.pod.uid = 'pod-uid-1' AND k8s.cluster.name = 'prod-cluster' AND k8s.namespace.name = 'production' AND k8s.container.name = 'nginx'",
+ );
+ });
+
+ it('scopes events to the pod, since k8s emits events per pod', () => {
+ expect(k8sContainerInitialEventsExpression(makeContainer())).toBe(
+ "k8s.object.kind = 'Pod' AND k8s.object.name = 'web-0' AND k8s.cluster.name = 'prod-cluster' AND attribute.k8s.namespace.name = 'production'",
+ );
+ });
+});
+
+describe('getContainerMetricsQueryPayload', () => {
+ const payloads = getContainerMetricsQueryPayload(makeContainer(), 1000, 2000);
+
+ it('returns one payload per documented chart', () => {
+ expect(payloads).toHaveLength(10);
+ });
+
+ it('scopes every query to the selected container', () => {
+ payloads.forEach((payload) => {
+ payload.query.builder.queryData.forEach((query) => {
+ expect(query.filters?.items).toStrictEqual([
+ expect.objectContaining({
+ key: expect.objectContaining({ key: 'k8s.pod.uid' }),
+ op: '=',
+ value: 'pod-uid-1',
+ }),
+ expect.objectContaining({
+ key: expect.objectContaining({ key: 'k8s.container.name' }),
+ op: '=',
+ value: 'nginx',
+ }),
+ ]);
+ });
+ });
+ });
+
+ it('derives cache memory from the working set and RSS queries', () => {
+ const memoryByState = payloads[4];
+
+ expect(
+ memoryByState.query.builder.queryData.map((query) => [
+ query.queryName,
+ query.aggregateAttribute?.key,
+ ]),
+ ).toStrictEqual([
+ ['A', 'container.memory.rss'],
+ ['B', 'container.memory.working_set'],
+ ]);
+ expect(memoryByState.query.builder.queryFormulas).toStrictEqual([
+ expect.objectContaining({ expression: 'B - A', legend: 'Cache Memory' }),
+ ]);
+ });
+});
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/constants.ts b/frontend/src/container/InfraMonitoringK8sV2/Containers/constants.ts
new file mode 100644
index 0000000000..f98440c48a
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/constants.ts
@@ -0,0 +1,170 @@
+import { InframonitoringtypesContainerRecordDTO } from 'api/generated/services/sigNoz.schemas';
+import { formatValueForExpression } from 'components/QueryBuilderV2/utils';
+
+import {
+ buildEventsExpression,
+ buildLogsTracesExpression,
+} from '../Base/utils';
+import { K8sDetailsMetadataConfig, K8sDetailsWidgetInfo } from '../Base/types';
+import { INFRA_MONITORING_ATTR_KEYS } from '../constants';
+import { SelectedItemParams } from '../hooks';
+import {
+ CONTAINERS_DOC_PATH,
+ getContainerImageWithTag,
+ getContainerName,
+ getContainerPodUID,
+} from './utils';
+
+/** A container row is identified by the (pod UID, container name) pair. */
+export const k8sContainerGetSelectedItemExpression = (
+ params: SelectedItemParams,
+): string =>
+ [
+ `${INFRA_MONITORING_ATTR_KEYS.K8S_POD_UID} = ${formatValueForExpression(
+ params.selectedItem ?? '',
+ )}`,
+ `${INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME} = ${formatValueForExpression(
+ params.containerName ?? '',
+ )}`,
+ ].join(' AND ');
+
+export const k8sContainerGetEntityName = getContainerName;
+
+export const k8sContainerDetailsMetadataConfig: K8sDetailsMetadataConfig<InframonitoringtypesContainerRecordDTO>[] =
+ [
+ {
+ label: 'Pod',
+ getValue: (c): string =>
+ c.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_POD_NAME] || '',
+ },
+ {
+ label: 'NAMESPACE',
+ getValue: (c): string =>
+ c.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME] || '',
+ },
+ {
+ label: 'Node',
+ getValue: (c): string =>
+ c.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME] || '',
+ },
+ {
+ label: 'Cluster Name',
+ getValue: (c): string =>
+ c.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME] || '',
+ },
+ {
+ label: 'Image:Tag',
+ getValue: getContainerImageWithTag,
+ },
+ ];
+
+export const k8sContainerInitialLogTracesExpression = (
+ container: InframonitoringtypesContainerRecordDTO,
+): string => {
+ const base = buildLogsTracesExpression({
+ mainAttributeKey: INFRA_MONITORING_ATTR_KEYS.K8S_POD_UID,
+ mainAttributeValue: getContainerPodUID(container),
+ clusterName: container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME],
+ namespaceName:
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME],
+ });
+
+ const containerName = getContainerName(container);
+ if (!containerName) {
+ return base;
+ }
+
+ const containerClause = `${
+ INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME
+ } = ${formatValueForExpression(containerName)}`;
+
+ return base ? `${base} AND ${containerClause}` : containerClause;
+};
+
+/**
+ * Kubernetes emits events against the pod, not the container, so the events tab
+ * is scoped to the container's pod.
+ */
+export const k8sContainerInitialEventsExpression = (
+ container: InframonitoringtypesContainerRecordDTO,
+): string =>
+ buildEventsExpression({
+ objectKind: 'Pod',
+ objectName: container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_POD_NAME] || '',
+ clusterName: container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME],
+ namespaceName:
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME],
+ });
+
+export const containerWidgetInfo: K8sDetailsWidgetInfo[] = [
+ {
+ title: 'CPU Usage (cores)',
+ yAxisUnit: '',
+ docPath: `${CONTAINERS_DOC_PATH}#cpu-usage-cores-1`,
+ description:
+ 'Avg, max and min CPU consumption of the container in cores, showing how bursty it is.',
+ },
+ {
+ title: 'CPU Request, Limit Utilization',
+ yAxisUnit: 'percentunit',
+ docPath: `${CONTAINERS_DOC_PATH}#cpu-request-limit-utilization`,
+ description:
+ 'Container CPU usage as a fraction of its own CPU request and limit; limit lines near 100% mean throttling.',
+ },
+ {
+ title: 'Memory Usage (bytes)',
+ yAxisUnit: 'bytes',
+ docPath: `${CONTAINERS_DOC_PATH}#memory-usage-bytes`,
+ description:
+ 'Total memory charged to the container, including reclaimable page cache, against the headroom left before its limit.',
+ },
+ {
+ title: 'Memory Request, Limit Utilization',
+ yAxisUnit: 'percentunit',
+ docPath: `${CONTAINERS_DOC_PATH}#memory-request-limit-utilization`,
+ description:
+ 'Container memory usage as a fraction of its own memory request and limit; limit lines near 100% risk an OOMKill.',
+ },
+ {
+ title: 'Memory by State',
+ yAxisUnit: 'bytes',
+ docPath: `${CONTAINERS_DOC_PATH}#memory-by-state`,
+ description:
+ 'RSS, working set and cache memory of the container, separating heap growth from file cache.',
+ },
+ {
+ title: 'Memory Major Page Faults',
+ yAxisUnit: '',
+ docPath: `${CONTAINERS_DOC_PATH}#memory-major-page-faults`,
+ description:
+ 'Major page fault rate of the container; sustained values mean the working set is paging to disk.',
+ },
+ {
+ title: 'File System (bytes)',
+ yAxisUnit: 'bytes',
+ docPath: `${CONTAINERS_DOC_PATH}#file-system-bytes`,
+ description:
+ 'Capacity, available and used bytes of the container filesystem.',
+ },
+ {
+ title: 'Container Uptime',
+ yAxisUnit: 's',
+ docPath: `${CONTAINERS_DOC_PATH}#container-uptime`,
+ description:
+ 'Time since the container last started; a sawtooth of resets means it is restarting repeatedly.',
+ },
+ {
+ title: 'Node CPU Utilization by Container',
+ yAxisUnit: 'percentunit',
+ docPath: `${CONTAINERS_DOC_PATH}#node-cpu-utilization-by-container`,
+ description:
+ "The container's CPU usage as a fraction of the whole node's capacity, to spot noisy neighbours.",
+ },
+ {
+ title: 'Node Memory Utilization by Container',
+ yAxisUnit: 'percentunit',
+ docPath: `${CONTAINERS_DOC_PATH}#node-memory-utilization-by-container`,
+ description:
+ "The container's memory usage as a fraction of the whole node's capacity.",
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/entity.config.ts b/frontend/src/container/InfraMonitoringK8sV2/Containers/entity.config.ts
new file mode 100644
index 0000000000..95f33ca214
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/entity.config.ts
@@ -0,0 +1,140 @@
+import { convertToApiError } from 'api/ErrorResponseHandlerForGeneratedAPIs';
+import { listContainers } from 'api/generated/services/inframonitoring';
+import {
+ InframonitoringtypesContainerRecordDTO,
+ InframonitoringtypesResponseTypeDTO,
+ Querybuildertypesv5OrderDirectionDTO,
+ RenderErrorResponseDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import { AxiosError } from 'axios';
+import { InfraMonitoringEvents } from 'constants/events';
+
+import { K8sEntityConfig } from '../Base/entity.config.types';
+import { K8sBaseFilters, K8sDetailsFilters } from '../Base/types';
+import { InfraMonitoringEntity } from '../constants';
+import { SelectedItemParams } from '../hooks';
+import {
+ containerWidgetInfo,
+ k8sContainerDetailsMetadataConfig,
+ k8sContainerGetEntityName,
+ k8sContainerGetSelectedItemExpression,
+ k8sContainerInitialEventsExpression,
+ k8sContainerInitialLogTracesExpression,
+} from './constants';
+import { getContainerMetricsQueryPayload } from './metrics';
+import {
+ getK8sContainerItemKey,
+ getK8sContainerRowKey,
+ k8sContainerColumnsConfig,
+} from './table.config';
+
+async function fetchListData(
+ filters: K8sBaseFilters,
+ signal?: AbortSignal,
+): ReturnType<
+ K8sEntityConfig<
+ InframonitoringtypesContainerRecordDTO,
+ SelectedItemParams
+ >['list']['fetchListData']
+> {
+ try {
+ const response = await listContainers(
+ {
+ filter: { expression: filters.filter.expression },
+ groupBy: filters.groupBy?.map((g) => ({ name: g.name })),
+ offset: filters.offset,
+ limit: filters.limit ?? 10,
+ start: filters.start,
+ end: filters.end,
+ orderBy: filters.orderBy
+ ? {
+ key: { name: filters.orderBy.key.name },
+ direction:
+ filters.orderBy.direction === 'asc'
+ ? Querybuildertypesv5OrderDirectionDTO.asc
+ : Querybuildertypesv5OrderDirectionDTO.desc,
+ }
+ : undefined,
+ },
+ signal,
+ );
+
+ const data = response.data;
+ return {
+ type:
+ data.type === InframonitoringtypesResponseTypeDTO.grouped_list
+ ? ('grouped_list' as const)
+ : ('list' as const),
+ records: data.records,
+ total: data.total,
+ endTimeBeforeRetention: data.endTimeBeforeRetention,
+ warning: data.warning,
+ };
+ } catch (error) {
+ return {
+ type: 'list' as const,
+ records: [] as InframonitoringtypesContainerRecordDTO[],
+ total: 0,
+ error:
+ convertToApiError(error as AxiosError<RenderErrorResponseDTO>) ?? null,
+ };
+ }
+}
+
+async function fetchEntityData(
+ filters: K8sDetailsFilters,
+ signal?: AbortSignal,
+): ReturnType<
+ K8sEntityConfig<InframonitoringtypesContainerRecordDTO>['details']['fetchEntityData']
+> {
+ try {
+ const response = await listContainers(
+ {
+ filter: { expression: filters.filter.expression },
+ start: filters.start,
+ end: filters.end,
+ limit: 1,
+ offset: 0,
+ },
+ signal,
+ );
+
+ return {
+ data: response.data.records.length > 0 ? response.data.records[0] : null,
+ };
+ } catch (error) {
+ return {
+ data: null,
+ error:
+ convertToApiError(error as AxiosError<RenderErrorResponseDTO>) ?? null,
+ };
+ }
+}
+
+export const containerEntityConfig: K8sEntityConfig<
+ InframonitoringtypesContainerRecordDTO,
+ SelectedItemParams
+> = {
+ list: {
+ entity: InfraMonitoringEntity.CONTAINERS,
+ eventCategory: InfraMonitoringEvents.Container,
+ tableColumns: k8sContainerColumnsConfig,
+ fetchListData,
+ getRowKey: getK8sContainerRowKey,
+ getItemKey: getK8sContainerItemKey,
+ detailsQueryKeyPrefix: 'container',
+ },
+ details: {
+ category: InfraMonitoringEntity.CONTAINERS,
+ eventCategory: InfraMonitoringEvents.Container,
+ queryKeyPrefix: 'container',
+ getSelectedItemExpression: k8sContainerGetSelectedItemExpression,
+ fetchEntityData,
+ getEntityName: k8sContainerGetEntityName,
+ getInitialLogTracesExpression: k8sContainerInitialLogTracesExpression,
+ getInitialEventsExpression: k8sContainerInitialEventsExpression,
+ metadataConfig: k8sContainerDetailsMetadataConfig,
+ entityWidgetInfo: containerWidgetInfo,
+ getEntityQueryPayload: getContainerMetricsQueryPayload,
+ },
+};
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/metrics.ts b/frontend/src/container/InfraMonitoringK8sV2/Containers/metrics.ts
new file mode 100644
index 0000000000..6fd9cb24da
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/metrics.ts
@@ -0,0 +1,275 @@
+import { InframonitoringtypesContainerRecordDTO } from 'api/generated/services/sigNoz.schemas';
+import { PANEL_TYPES } from 'constants/queryBuilder';
+import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
+import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
+import { EQueryType } from 'types/common/dashboard';
+import { DataSource, ReduceOperators } from 'types/common/queryBuilder';
+import { v4 } from 'uuid';
+
+import { INFRA_MONITORING_ATTR_KEYS } from '../constants';
+import { getContainerName, getContainerPodUID } from './utils';
+
+const QUERY_NAMES = ['A', 'B', 'C', 'D', 'E', 'F'];
+const STEP_INTERVAL = 60;
+
+type TimeAggregation = 'avg' | 'max' | 'min' | 'latest';
+type SpaceAggregation = 'sum' | 'avg' | 'max';
+
+interface SeriesSpec {
+ metricKey: string;
+ legend: string;
+ timeAggregation: TimeAggregation;
+ spaceAggregation: SpaceAggregation;
+}
+
+interface FormulaSpec {
+ expression: string;
+ legend: string;
+}
+
+/**
+ * Every panel is scoped to a single container by the (k8s.pod.uid,
+ * k8s.container.name) pair that identifies its row in the list.
+ */
+function buildScopeFilters(
+ container: InframonitoringtypesContainerRecordDTO,
+): TagFilter {
+ return {
+ items: [
+ {
+ id: 'pod-uid',
+ key: {
+ dataType: DataTypes.String,
+ id: `k8s_pod_uid--string--tag--false`,
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_POD_UID,
+ type: 'tag',
+ },
+ op: '=',
+ value: getContainerPodUID(container),
+ },
+ {
+ id: 'container-name',
+ key: {
+ dataType: DataTypes.String,
+ id: `k8s_container_name--string--tag--false`,
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME,
+ type: 'tag',
+ },
+ op: '=',
+ value: getContainerName(container),
+ },
+ ],
+ op: 'AND',
+ };
+}
+
+function buildQuery(
+ container: InframonitoringtypesContainerRecordDTO,
+ start: number,
+ end: number,
+ series: SeriesSpec[],
+ formulas: FormulaSpec[] = [],
+): GetQueryResultsProps {
+ const filters = buildScopeFilters(container);
+
+ return {
+ selectedTime: 'GLOBAL_TIME',
+ graphType: PANEL_TYPES.TIME_SERIES,
+ query: {
+ builder: {
+ queryData: series.map((spec, index) => ({
+ aggregateAttribute: {
+ dataType: DataTypes.Float64,
+ id: `${spec.metricKey.replace(/\./g, '_')}--float64--Gauge--true`,
+ key: spec.metricKey,
+ type: 'Gauge',
+ },
+ aggregateOperator: spec.timeAggregation,
+ dataSource: DataSource.METRICS,
+ disabled: false,
+ expression: QUERY_NAMES[index],
+ filters,
+ functions: [],
+ groupBy: [],
+ having: [],
+ legend: spec.legend,
+ limit: null,
+ orderBy: [],
+ queryName: QUERY_NAMES[index],
+ reduceTo: ReduceOperators.AVG,
+ spaceAggregation: spec.spaceAggregation,
+ stepInterval: STEP_INTERVAL,
+ timeAggregation: spec.timeAggregation,
+ })),
+ queryFormulas: formulas.map((formula, index) => ({
+ disabled: false,
+ expression: formula.expression,
+ legend: formula.legend,
+ queryName: `F${index + 1}`,
+ })),
+ queryTraceOperator: [],
+ },
+ 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,
+ };
+}
+
+/** Absolute usage metrics are summed across series, ratios are averaged. */
+function usageSeries(metricKey: string, legendPrefix = ''): SeriesSpec[] {
+ const prefix = legendPrefix ? `${legendPrefix} - ` : '';
+ return [
+ {
+ metricKey,
+ legend: `${prefix}Avg`,
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ {
+ metricKey,
+ legend: `${prefix}Max`,
+ timeAggregation: 'max',
+ spaceAggregation: 'sum',
+ },
+ {
+ metricKey,
+ legend: `${prefix}Min`,
+ timeAggregation: 'min',
+ spaceAggregation: 'sum',
+ },
+ ];
+}
+
+function utilizationSeries(
+ metricKey: string,
+ legendPrefix: string,
+): SeriesSpec[] {
+ return (['avg', 'max', 'min'] as TimeAggregation[]).map((timeAggregation) => ({
+ metricKey,
+ legend: `${legendPrefix} - ${
+ timeAggregation.charAt(0).toUpperCase() + timeAggregation.slice(1)
+ }`,
+ timeAggregation,
+ spaceAggregation: 'avg' as const,
+ }));
+}
+
+export const getContainerMetricsQueryPayload = (
+ container: InframonitoringtypesContainerRecordDTO,
+ start: number,
+ end: number,
+): GetQueryResultsProps[] => {
+ const query = (
+ series: SeriesSpec[],
+ formulas?: FormulaSpec[],
+ ): GetQueryResultsProps => buildQuery(container, start, end, series, formulas);
+
+ return [
+ query(usageSeries(INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE)),
+ query([
+ ...utilizationSeries(
+ INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_CPU_REQUEST_UTILIZATION,
+ 'Request util %',
+ ),
+ ...utilizationSeries(
+ INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_CPU_LIMIT_UTILIZATION,
+ 'Limit util %',
+ ),
+ ]),
+ query([
+ ...usageSeries(INFRA_MONITORING_ATTR_KEYS.CONTAINER_MEMORY_USAGE, 'Usage'),
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_MEMORY_AVAILABLE,
+ legend: 'Available',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ ]),
+ query([
+ ...utilizationSeries(
+ INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_MEMORY_REQUEST_UTILIZATION,
+ 'Request util %',
+ ),
+ ...utilizationSeries(
+ INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_MEMORY_LIMIT_UTILIZATION,
+ 'Limit util %',
+ ),
+ ]),
+ query(
+ [
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_MEMORY_RSS,
+ legend: 'RSS Memory',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_MEMORY_WORKING_SET,
+ legend: 'Working Set Memory',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ ],
+ [{ expression: 'B - A', legend: 'Cache Memory' }],
+ ),
+ query([
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_MEMORY_MAJOR_PAGE_FAULTS,
+ legend: 'Major Page Faults',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ ]),
+ query([
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_FILESYSTEM_CAPACITY,
+ legend: 'Capacity',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_FILESYSTEM_AVAILABLE,
+ legend: 'Available',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_FILESYSTEM_USAGE,
+ legend: 'Usage',
+ timeAggregation: 'avg',
+ spaceAggregation: 'sum',
+ },
+ ]),
+ query([
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.CONTAINER_UPTIME,
+ legend: 'Uptime',
+ timeAggregation: 'latest',
+ spaceAggregation: 'sum',
+ },
+ ]),
+ query([
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_CPU_NODE_UTILIZATION,
+ legend: 'Node CPU Utilization',
+ timeAggregation: 'avg',
+ spaceAggregation: 'avg',
+ },
+ ]),
+ query([
+ {
+ metricKey: INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_MEMORY_NODE_UTILIZATION,
+ legend: 'Node Memory Utilization',
+ timeAggregation: 'avg',
+ spaceAggregation: 'avg',
+ },
+ ]),
+ ];
+};
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/table.config.tsx b/frontend/src/container/InfraMonitoringK8sV2/Containers/table.config.tsx
new file mode 100644
index 0000000000..9b4c1ecc7b
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/table.config.tsx
@@ -0,0 +1,470 @@
+import { Container } from '@signozhq/icons';
+import { Badge } from '@signozhq/ui/badge';
+import {
+ InframonitoringtypesContainerReadyDTO,
+ InframonitoringtypesContainerRecordDTO,
+ InframonitoringtypesContainerStatusDTO,
+} from 'api/generated/services/sigNoz.schemas';
+import TanStackTable, { TableColumnDef } from 'components/TanStackTableView';
+import { ExpandButtonWrapper } from 'container/InfraMonitoringK8sV2/components';
+
+import ColumnHeader from '../Base/ColumnHeader';
+import EntityGroupHeader from '../Base/EntityGroupHeader';
+import K8sGroupCell from '../Base/K8sGroupCell';
+import { formatBytes } from '../commonUtils';
+import {
+ EntityProgressBar,
+ EntityProgressThresholds,
+ GroupedStatusCounts,
+ TextNoData,
+ ValidateColumnValueWrapper,
+} from '../components';
+import {
+ INFRA_MONITORING_ATTR_KEYS,
+ InfraMonitoringEntity,
+} from '../constants';
+import { SelectedItemParams } from '../hooks';
+import {
+ CONTAINER_READY_COLORS,
+ CONTAINER_READY_LABELS,
+ CONTAINER_STATUS_COLORS,
+ CONTAINER_STATUS_LABELS,
+ CONTAINERS_DOC_PATH,
+ getContainerImageWithTag,
+ getContainerReadyItems,
+ getContainerStatusItems,
+} from './utils';
+
+export function getK8sContainerRowKey(
+ container: InframonitoringtypesContainerRecordDTO,
+): string {
+ return (
+ [container.podUID, container.containerName].filter(Boolean).join('/') ||
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME] ||
+ ''
+ );
+}
+
+export function getK8sContainerItemKey(
+ container: InframonitoringtypesContainerRecordDTO,
+): SelectedItemParams {
+ return {
+ selectedItem:
+ container.podUID ||
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_POD_UID] ||
+ null,
+ containerName:
+ container.containerName ||
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME] ||
+ null,
+ clusterName: null,
+ namespaceName: null,
+ };
+}
+
+export type ContainerTableColumnConfig =
+ TableColumnDef<InframonitoringtypesContainerRecordDTO>;
+
+/**
+ * The grouped table and its nested rows are separate tables, so a column and the
+ * one that replaces it while grouped share a width to keep the two aligned.
+ */
+const NAME_COLUMN_WIDTH = 220;
+const STATUS_COLUMN_WIDTH = 250;
+
+export const k8sContainerColumnsConfig: ContainerTableColumnConfig[] = [
+ {
+ id: 'containerGroup',
+ header: (): React.ReactNode => <EntityGroupHeader title="Container Group" />,
+ accessorFn: (row): string => row.containerName || '',
+ width: { min: NAME_COLUMN_WIDTH },
+ enableSort: false,
+ enableRemove: false,
+ enableMove: false,
+ pin: 'left',
+ visibilityBehavior: 'hidden-on-collapse',
+ cell: ({ isExpanded, toggleExpanded, row }): JSX.Element | null => (
+ <ExpandButtonWrapper isExpanded={isExpanded} toggleExpanded={toggleExpanded}>
+ <K8sGroupCell row={row} />
+ </ExpandButtonWrapper>
+ ),
+ },
+ {
+ id: INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME,
+ header: (): React.ReactNode => (
+ <EntityGroupHeader
+ title="Container Name"
+ icon={<Container data-hide-expanded="true" size={14} />}
+ docPath={`${CONTAINERS_DOC_PATH}#container-name`}
+ />
+ ),
+ accessorFn: (row): string =>
+ row.containerName ||
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME] ||
+ '',
+ width: { min: NAME_COLUMN_WIDTH },
+ enableSort: true,
+ enableRemove: false,
+ enableMove: false,
+ pin: 'left',
+ visibilityBehavior: 'hidden-on-expand',
+ cell: ({ value }): React.ReactNode => (
+ <TanStackTable.Text>{value as string}</TanStackTable.Text>
+ ),
+ },
+ {
+ id: 'podName',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#pod-name`}>
+ Pod Name
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string =>
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_POD_NAME] || '',
+ width: { min: 260 },
+ enableSort: false,
+ cell: ({ value }): React.ReactNode => {
+ const podName = value as string;
+ if (!podName) {
+ return <TextNoData type="tanstack" />;
+ }
+ return <TanStackTable.Text>{podName}</TanStackTable.Text>;
+ },
+ },
+ {
+ id: 'namespace',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#additional-columns`}>
+ Namespace
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string =>
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME] || '',
+ width: { min: 160 },
+ enableSort: false,
+ cell: ({ value }): React.ReactNode => (
+ <TanStackTable.Text>{value as string}</TanStackTable.Text>
+ ),
+ },
+ {
+ id: 'image',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#imagetag`}>
+ Image:Tag
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string => getContainerImageWithTag(row),
+ width: { min: 240 },
+ enableSort: false,
+ cell: ({ value }): React.ReactNode => {
+ const image = value as string;
+ if (!image) {
+ return <TextNoData type="tanstack" />;
+ }
+ return <TanStackTable.Text>{image}</TanStackTable.Text>;
+ },
+ },
+ {
+ id: 'containerStatus',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#status`}>Status</ColumnHeader>
+ ),
+ accessorFn: (row): string => row.status,
+ width: { min: STATUS_COLUMN_WIDTH },
+ enableSort: false,
+ visibilityBehavior: 'hidden-on-expand',
+ cell: ({ row }): React.ReactNode => {
+ if (
+ !row.status ||
+ row.status === InframonitoringtypesContainerStatusDTO.no_data
+ ) {
+ return <TextNoData type="tanstack" />;
+ }
+
+ return (
+ <Badge color={CONTAINER_STATUS_COLORS[row.status]} variant="outline">
+ {CONTAINER_STATUS_LABELS[row.status]}
+ </Badge>
+ );
+ },
+ },
+ {
+ id: 'containerCountsByStatus',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#status`}>Status</ColumnHeader>
+ ),
+ accessorFn: (
+ row,
+ ): InframonitoringtypesContainerRecordDTO['containerCountsByStatus'] =>
+ row.containerCountsByStatus,
+ width: { min: STATUS_COLUMN_WIDTH },
+ enableSort: false,
+ visibilityBehavior: 'hidden-on-collapse',
+ cell: ({ row, rowId }): React.ReactNode => {
+ if (!row.containerCountsByStatus) {
+ return <TextNoData type="tanstack" />;
+ }
+ return (
+ <GroupedStatusCounts
+ items={getContainerStatusItems(row.containerCountsByStatus)}
+ rowId={rowId}
+ />
+ );
+ },
+ },
+ {
+ id: 'containerReady',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#ready`}>Ready</ColumnHeader>
+ ),
+ accessorFn: (row): string => row.ready,
+ width: { min: 130 },
+ enableSort: false,
+ visibilityBehavior: 'hidden-on-expand',
+ cell: ({ row }): React.ReactNode => {
+ if (
+ !row.ready ||
+ row.ready === InframonitoringtypesContainerReadyDTO.no_data
+ ) {
+ return <TextNoData type="tanstack" />;
+ }
+
+ return (
+ <Badge color={CONTAINER_READY_COLORS[row.ready]} variant="outline">
+ {CONTAINER_READY_LABELS[row.ready]}
+ </Badge>
+ );
+ },
+ },
+ {
+ id: 'containerCountsByReady',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#ready`}>Ready</ColumnHeader>
+ ),
+ accessorFn: (
+ row,
+ ): InframonitoringtypesContainerRecordDTO['containerCountsByReady'] =>
+ row.containerCountsByReady,
+ width: { min: 130 },
+ enableSort: false,
+ visibilityBehavior: 'hidden-on-collapse',
+ cell: ({ row, rowId }): React.ReactNode => {
+ if (!row.containerCountsByReady) {
+ return <TextNoData type="tanstack" />;
+ }
+ return (
+ <GroupedStatusCounts
+ items={getContainerReadyItems(row.containerCountsByReady)}
+ rowId={rowId}
+ />
+ );
+ },
+ },
+ {
+ id: 'containerRestarts',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#restarts`}>
+ Restarts
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.restarts,
+ width: { min: 130 },
+ enableSort: false,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="Restarts"
+ >
+ <TanStackTable.Text>{value as number}</TanStackTable.Text>
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'cpu_request',
+ header: (): React.ReactNode => (
+ <ColumnHeader
+ docPath={`${CONTAINERS_DOC_PATH}#cpu-req-usage-`}
+ tooltip={<EntityProgressThresholds type="cpu-request" />}
+ >
+ CPU Request Usage (%)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.cpuRequestUtilization,
+ width: { min: 210 },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="CPU Request"
+ >
+ <EntityProgressBar value={value as number} type="cpu-request" />
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'cpu_limit',
+ header: (): React.ReactNode => (
+ <ColumnHeader
+ docPath={`${CONTAINERS_DOC_PATH}#cpu-limit-usage-`}
+ tooltip={<EntityProgressThresholds type="cpu-limit" />}
+ >
+ CPU Limit Usage (%)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.cpuLimitUtilization,
+ width: { min: 220 },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="CPU Limit"
+ >
+ <EntityProgressBar value={value as number} type="cpu-limit" />
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'cpu',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#cpu-usage-cores`}>
+ CPU Usage (cores)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.cpu,
+ width: { min: 160 },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={Number(value)}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="CPU metric"
+ >
+ <TanStackTable.Text>{Number(value).toFixed(2)}</TanStackTable.Text>
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'memory_request',
+ header: (): React.ReactNode => (
+ <ColumnHeader
+ docPath={`${CONTAINERS_DOC_PATH}#mem-req-usage-`}
+ tooltip={<EntityProgressThresholds type="memory-request" />}
+ >
+ Memory Request Usage (%)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.memoryRequestUtilization,
+ width: { min: 210 },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="Memory Request"
+ >
+ <EntityProgressBar value={value as number} type="memory-request" />
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'memory_limit',
+ header: (): React.ReactNode => (
+ <ColumnHeader
+ docPath={`${CONTAINERS_DOC_PATH}#mem-limit-usage-`}
+ tooltip={<EntityProgressThresholds type="memory-limit" />}
+ >
+ Memory Limit Usage (%)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.memoryLimitUtilization,
+ width: { min: 220 },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="Memory Limit"
+ >
+ <EntityProgressBar value={value as number} type="memory-limit" />
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'memory',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#mem-usage-wss`}>
+ Memory Usage (WSS)
+ </ColumnHeader>
+ ),
+ accessorFn: (row): number => row.memory,
+ width: { min: 210, default: '100%' },
+ enableSort: true,
+ cell: ({ value, rowId }): React.ReactNode => (
+ <ValidateColumnValueWrapper
+ rowId={rowId}
+ value={value as number}
+ entity={InfraMonitoringEntity.CONTAINERS}
+ attribute="memory metric"
+ >
+ <TanStackTable.Text>{formatBytes(value as number)}</TanStackTable.Text>
+ </ValidateColumnValueWrapper>
+ ),
+ },
+ {
+ id: 'node',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#additional-columns`}>
+ Node
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string =>
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME] || '',
+ width: { default: 100 },
+ enableSort: false,
+ defaultVisibility: false,
+ cell: ({ value }): React.ReactNode => (
+ <TanStackTable.Text>{value as string}</TanStackTable.Text>
+ ),
+ },
+ {
+ id: 'cluster',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#additional-columns`}>
+ Cluster
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string =>
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME] || '',
+ width: { default: 100 },
+ enableSort: false,
+ defaultVisibility: false,
+ cell: ({ value }): React.ReactNode => (
+ <TanStackTable.Text>{value as string}</TanStackTable.Text>
+ ),
+ },
+ {
+ id: 'deployment',
+ header: (): React.ReactNode => (
+ <ColumnHeader docPath={`${CONTAINERS_DOC_PATH}#additional-columns`}>
+ Deployment
+ </ColumnHeader>
+ ),
+ accessorFn: (row): string =>
+ row.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_DEPLOYMENT_NAME] || '',
+ width: { default: 100 },
+ enableSort: false,
+ defaultVisibility: false,
+ cell: ({ value }): React.ReactNode => (
+ <TanStackTable.Text>{value as string}</TanStackTable.Text>
+ ),
+ },
+];
diff --git a/frontend/src/container/InfraMonitoringK8sV2/Containers/utils.ts b/frontend/src/container/InfraMonitoringK8sV2/Containers/utils.ts
new file mode 100644
index 0000000000..ce2dfa0cd6
--- /dev/null
+++ b/frontend/src/container/InfraMonitoringK8sV2/Containers/utils.ts
@@ -0,0 +1,169 @@
+import { Color } from '@signozhq/design-tokens';
+import { BadgeColor } from '@signozhq/ui/badge';
+import {
+ InframonitoringtypesContainerCountsByReadyDTO,
+ InframonitoringtypesContainerCountsByStatusDTO,
+ InframonitoringtypesContainerReadyDTO,
+ InframonitoringtypesContainerRecordDTO,
+ InframonitoringtypesContainerStatusDTO,
+} from 'api/generated/services/sigNoz.schemas';
+
+import { StatusCountItem } from '../components/GroupedStatusCounts';
+import { INFRA_MONITORING_ATTR_KEYS } from '../constants';
+
+export const CONTAINERS_DOC_PATH =
+ '/infrastructure-monitoring/kubernetes/containers';
+
+/** Renders as `name:tag`; the tag is dropped when the image is not pinned. */
+export function getContainerImageWithTag(
+ container: InframonitoringtypesContainerRecordDTO,
+): string {
+ const name = container.meta?.[INFRA_MONITORING_ATTR_KEYS.CONTAINER_IMAGE_NAME];
+ const tag = container.meta?.[INFRA_MONITORING_ATTR_KEYS.CONTAINER_IMAGE_TAG];
+
+ if (!name) {
+ return '';
+ }
+
+ return tag ? `${name}:${tag}` : name;
+}
+
+export function getContainerName(
+ container: InframonitoringtypesContainerRecordDTO,
+): string {
+ return (
+ container.containerName ||
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME] ||
+ ''
+ );
+}
+
+export function getContainerPodUID(
+ container: InframonitoringtypesContainerRecordDTO,
+): string {
+ return (
+ container.podUID ||
+ container.meta?.[INFRA_MONITORING_ATTR_KEYS.K8S_POD_UID] ||
+ ''
+ );
+}
+
+export const CONTAINER_STATUS_COLORS: Record<
+ InframonitoringtypesContainerStatusDTO,
+ BadgeColor
+> = {
+ [InframonitoringtypesContainerStatusDTO.running]: 'forest',
+ [InframonitoringtypesContainerStatusDTO.completed]: 'robin',
+ [InframonitoringtypesContainerStatusDTO.waiting]: 'amber',
+ [InframonitoringtypesContainerStatusDTO.containercreating]: 'amber',
+ [InframonitoringtypesContainerStatusDTO.terminated]: 'sienna',
+ [InframonitoringtypesContainerStatusDTO.unknown]: 'vanilla',
+ [InframonitoringtypesContainerStatusDTO.no_data]: 'vanilla',
+ [InframonitoringtypesContainerStatusDTO.crashloopbackoff]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.imagepullbackoff]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.errimagepull]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.createcontainerconfigerror]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.oomkilled]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.error]: 'cherry',
+ [InframonitoringtypesContainerStatusDTO.containercannotrun]: 'cherry',
+};
+
+/** kubectl prints these as single CamelCase words, so the enum value alone is not a usable label. */
+export const CONTAINER_STATUS_LABELS: Record<
+ InframonitoringtypesContainerStatusDTO,
+ string
+> = {
+ [InframonitoringtypesContainerStatusDTO.running]: 'Running',
+ [InframonitoringtypesContainerStatusDTO.completed]: 'Completed',
+ [InframonitoringtypesContainerStatusDTO.waiting]: 'Waiting',
+ [InframonitoringtypesContainerStatusDTO.containercreating]:
+ 'ContainerCreating',
+ [InframonitoringtypesContainerStatusDTO.terminated]: 'Terminated',
+ [InframonitoringtypesContainerStatusDTO.unknown]: 'Unknown',
+ [InframonitoringtypesContainerStatusDTO.no_data]: 'No data',
+ [InframonitoringtypesContainerStatusDTO.crashloopbackoff]: 'CrashLoopBackOff',
+ [InframonitoringtypesContainerStatusDTO.imagepullbackoff]: 'ImagePullBackOff',
+ [InframonitoringtypesContainerStatusDTO.errimagepull]: 'ErrImagePull',
+ [InframonitoringtypesContainerStatusDTO.createcontainerconfigerror]:
+ 'CreateContainerConfigError',
+ [InframonitoringtypesContainerStatusDTO.oomkilled]: 'OOMKilled',
+ [InframonitoringtypesContainerStatusDTO.error]: 'Error',
+ [InframonitoringtypesContainerStatusDTO.containercannotrun]:
+ 'ContainerCannotRun',
+};
+
+const CONTAINER_ERROR_STATUS_LABELS: Partial<
+ Record<keyof InframonitoringtypesContainerCountsByStatusDTO, string>
+> = {
+ crashLoopBackOff: 'CrashLoopBackOff',
+ imagePullBackOff: 'ImagePullBackOff',
+ errImagePull: 'ErrImagePull',
+ createContainerConfigError: 'CreateContainerConfigError',
+ oomKilled: 'OOMKilled',
+ error: 'Error',
+ containerCannotRun: 'ContainerCannotRun',
+};
+
+export function getContainerStatusItems(
+ counts: InframonitoringtypesContainerCountsByStatusDTO,
+): StatusCountItem[] {
+ const errorKeys = Object.keys(CONTAINER_ERROR_STATUS_LABELS) as Array<
+ keyof typeof CONTAINER_ERROR_STATUS_LABELS
+ >;
+
+ return [
+ { value: counts.running, label: 'Running', color: Color.BG_FOREST_500 },
+ { value: counts.completed, label: 'Completed', color: Color.BG_ROBIN_500 },
+ {
+ value: counts.waiting + counts.containerCreating,
+ label: 'Waiting',
+ color: Color.BG_AMBER_500,
+ breakdown: [
+ { label: 'Waiting', value: counts.waiting },
+ { label: 'ContainerCreating', value: counts.containerCreating },
+ ],
+ },
+ {
+ value: counts.terminated,
+ label: 'Terminated',
+ color: Color.BG_SIENNA_500,
+ },
+ { value: counts.unknown, label: 'Unknown', color: Color.BG_SLATE_400 },
+ {
+ value: errorKeys.reduce((sum, key) => sum + counts[key], 0),
+ label: 'Error Status',
+ color: Color.BG_CHERRY_500,
+ breakdown: errorKeys.map((key) => ({
+ label: CONTAINER_ERROR_STATUS_LABELS[key] as string,
+ value: counts[key],
+ })),
+ },
+ ];
+}
+
+export const CONTAINER_READY_COLORS: Record<
+ InframonitoringtypesContainerReadyDTO,
+ BadgeColor
+> = {
+ [InframonitoringtypesContainerReadyDTO.ready]: 'forest',
+ [InframonitoringtypesContainerReadyDTO.not_ready]: 'cherry',
+ [InframonitoringtypesContainerReadyDTO.no_data]: 'vanilla',
+};
+
+export const CONTAINER_READY_LABELS: Record<
+ InframonitoringtypesContainerReadyDTO,
+ string
+> = {
+ [InframonitoringtypesContainerReadyDTO.ready]: 'Ready',
+ [InframonitoringtypesContainerReadyDTO.not_ready]: 'Not Ready',
+ [InframonitoringtypesContainerReadyDTO.no_data]: 'No data',
+};
+
+export function getContainerReadyItems(
+ counts: InframonitoringtypesContainerCountsByReadyDTO,
+): StatusCountItem[] {
+ return [
+ { value: counts.ready, label: 'Ready', color: Color.BG_FOREST_500 },
+ { value: counts.notReady, label: 'Not Ready', color: Color.BG_CHERRY_500 },
+ ];
+}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/ChartHeader.tsx b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/ChartHeader.tsx
index acb38f1902..4ede492430 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/ChartHeader.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/EntityMetrics/ChartHeader.tsx
@@ -3,8 +3,9 @@ import { Compass, Info } from '@signozhq/icons';
import { TooltipSimple } from '@signozhq/ui/tooltip';
import styles from './ChartHeader.module.scss';
+import { DOCS_BASE_URL } from 'constants/app';
-const DOCS_BASE_URL = `${process.env.DOCS_BASE_URL}/docs`;
+const DOCS_ROOT = `${DOCS_BASE_URL}/docs`;
interface ChartHeaderProps {
title: string;
@@ -33,7 +34,7 @@ function ChartHeader({
<>
{tooltipTitle}{' '}
<a
- href={`${DOCS_BASE_URL}${docPath}`}
+ href={`${DOCS_ROOT}${docPath}`}
target="_blank"
rel="noopener"
onClick={(e): void => e.stopPropagation()}
diff --git a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/entityDetails.module.scss b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/entityDetails.module.scss
index be86b26938..355ccf47a2 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/entityDetails.module.scss
+++ b/frontend/src/container/InfraMonitoringK8sV2/EntityDetailsUtils/entityDetails.module.scss
@@ -37,38 +37,28 @@
.title {
font-family: var(--periscope-font-family-mono);
- --typography-margin: 0px var(--spacing-4) 0px 0px;
+ --typography-margin: 0px var(--spacing-1) 0px 0px;
}
-.entityDetailsEntity {
- display: flex;
- flex-direction: column;
+// Sized to the icon rather than the default tap target, so it sits beside the
+// entity name instead of a gap away from it.
+.copyIdButton {
+ --button-padding: 2px;
+ --button-height: auto;
+ --button-width: auto;
}
-.entityDetailsGrid {
+.entityDetailsEntity {
display: flex;
flex-direction: column;
}
-.labelsRow,
-.valuesRow {
+// Tracks size to the entity's field count instead of a fixed four, so entities
+// with more fields stay on one row rather than spilling a near-empty second one.
+.entityDetailsGrid {
display: grid;
- grid-template-columns: 1.5fr 1.5fr 1.5fr 1.5fr;
- gap: 30px;
- align-items: center;
-}
-
-.labelsRow {
- margin-bottom: var(--spacing-4);
-}
-
-.entityDetailsMetadataLabel {
- letter-spacing: 0.44px;
- text-transform: uppercase;
-}
-
-.entityDetailsMetadataValue {
- font-family: var(--periscope-font-family-mono);
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
+ gap: var(--spacing-4) var(--spacing-6);
}
.viewsTabsContainer {
diff --git a/frontend/src/container/InfraMonitoringK8sV2/InfraMonitoringK8s.tsx b/frontend/src/container/InfraMonitoringK8sV2/InfraMonitoringK8s.tsx
index 94e3b9fada..4d402d5361 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/InfraMonitoringK8s.tsx
+++ b/frontend/src/container/InfraMonitoringK8sV2/InfraMonitoringK8s.tsx
@@ -16,6 +16,7 @@ import {
ArrowUpDown,
ArrowUpToLine,
Bolt,
+ Box,
Boxes,
Computer,
Container,
@@ -31,6 +32,7 @@ import { DataSource } from 'types/common/queryBuilder';
import { K8sDynamicList } from './Base/K8sDynamicList';
import {
GetClustersQuickFiltersConfig,
+ GetContainersQuickFiltersConfig,
GetDaemonsetsQuickFiltersConfig,
GetDeploymentsQuickFiltersConfig,
GetJobsQuickFiltersConfig,
@@ -152,6 +154,12 @@ export default function InfraMonitoringK8s(): JSX.Element {
const categories = useMemo(
() => [
+ {
+ key: K8sCategories.CONTAINERS,
+ label: 'Containers',
+ icon: <Box size={14} />,
+ config: GetContainersQuickFiltersConfig(),
+ },
{
key: K8sCategories.PODS,
label: 'Pods',
diff --git a/frontend/src/container/InfraMonitoringK8sV2/constants.ts b/frontend/src/container/InfraMonitoringK8sV2/constants.ts
index f4c4a5236c..d3aae6489d 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/constants.ts
+++ b/frontend/src/container/InfraMonitoringK8sV2/constants.ts
@@ -61,10 +61,26 @@ export const INFRA_MONITORING_ATTR_KEYS = {
K8S_CONTAINER_CPU_LIMIT: 'k8s.container.cpu_limit',
K8S_CONTAINER_MEMORY_REQUEST: 'k8s.container.memory_request',
K8S_CONTAINER_MEMORY_LIMIT: 'k8s.container.memory_limit',
+ K8S_CONTAINER_CPU_REQUEST_UTILIZATION: 'k8s.container.cpu_request_utilization',
+ K8S_CONTAINER_CPU_LIMIT_UTILIZATION: 'k8s.container.cpu_limit_utilization',
+ K8S_CONTAINER_MEMORY_REQUEST_UTILIZATION:
+ 'k8s.container.memory_request_utilization',
+ K8S_CONTAINER_MEMORY_LIMIT_UTILIZATION:
+ 'k8s.container.memory_limit_utilization',
+ K8S_CONTAINER_CPU_NODE_UTILIZATION: 'k8s.container.cpu.node.utilization',
+ K8S_CONTAINER_MEMORY_NODE_UTILIZATION: 'k8s.container.memory.node.utilization',
CONTAINER_CPU_USAGE: 'container.cpu.usage',
CONTAINER_MEMORY_USAGE: 'container.memory.usage',
+ CONTAINER_MEMORY_AVAILABLE: 'container.memory.available',
CONTAINER_MEMORY_WORKING_SET: 'container.memory.working_set',
CONTAINER_MEMORY_RSS: 'container.memory.rss',
+ CONTAINER_MEMORY_MAJOR_PAGE_FAULTS: 'container.memory.major_page_faults',
+ CONTAINER_FILESYSTEM_AVAILABLE: 'container.filesystem.available',
+ CONTAINER_FILESYSTEM_CAPACITY: 'container.filesystem.capacity',
+ CONTAINER_FILESYSTEM_USAGE: 'container.filesystem.usage',
+ CONTAINER_UPTIME: 'container.uptime',
+ CONTAINER_IMAGE_NAME: 'container.image.name',
+ CONTAINER_IMAGE_TAG: 'container.image.tag',
// Deployment
K8S_DEPLOYMENT_NAME: 'k8s.deployment.name',
@@ -165,6 +181,9 @@ export const K8sCategories = {
VOLUMES: 'volumes',
};
+/** The section the Kubernetes view opens on when a link names none. */
+export const DEFAULT_K8S_CATEGORY = K8sCategories.CONTAINERS;
+
const dotMap = {
[InfraMonitoringEntity.HOSTS]:
INFRA_MONITORING_ATTR_KEYS.SYSTEM_CPU_LOAD_AVERAGE_15M,
@@ -181,7 +200,7 @@ const dotMap = {
[InfraMonitoringEntity.DAEMONSETS]:
INFRA_MONITORING_ATTR_KEYS.K8S_POD_CPU_USAGE,
[InfraMonitoringEntity.CONTAINERS]:
- INFRA_MONITORING_ATTR_KEYS.K8S_POD_CPU_USAGE,
+ INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
[InfraMonitoringEntity.JOBS]:
INFRA_MONITORING_ATTR_KEYS.K8S_JOB_DESIRED_SUCCESSFUL_PODS,
[InfraMonitoringEntity.VOLUMES]:
@@ -321,6 +340,161 @@ export function GetPodsQuickFiltersConfig(): IQuickFiltersConfig[] {
];
}
+export function GetContainersQuickFiltersConfig(): IQuickFiltersConfig[] {
+ return [
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Container',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_CONTAINER_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Pod',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_POD_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_POD_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: true,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Namespace',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_NAMESPACE_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Node',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_NODE_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Cluster',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_CLUSTER_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Image',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.CONTAINER_IMAGE_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.CONTAINER_IMAGE_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Deployment',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_DEPLOYMENT_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_DEPLOYMENT_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Statefulset',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_STATEFULSET_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_STATEFULSET_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'DaemonSet',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_DAEMONSET_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_DAEMONSET_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Job',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.K8S_JOB_NAME,
+ dataType: DataTypes.String,
+ type: 'resource',
+ id: `${INFRA_MONITORING_ATTR_KEYS.K8S_JOB_NAME}--string--resource--false`,
+ },
+ aggregateOperator: 'noop',
+ aggregateAttribute: INFRA_MONITORING_ATTR_KEYS.CONTAINER_CPU_USAGE,
+ dataSource: DataSource.METRICS,
+ defaultOpen: false,
+ },
+ {
+ type: FiltersType.CHECKBOX,
+ title: 'Environment',
+ attributeKey: {
+ key: INFRA_MONITORING_ATTR_KEYS.DEPLOYMENT_ENVIRONMENT,
+ dataType: DataTypes.String,
+ type: 'resource',
+ },
+ defaultOpen: true,
+ },
+ ];
+}
+
export function GetNodesQuickFiltersConfig(): IQuickFiltersConfig[] {
return [
{
@@ -767,6 +941,7 @@ export const INFRA_MONITORING_K8S_PARAMS_KEYS = {
SELECTED_ITEM: 'selectedItem',
SELECTED_ITEM_CLUSTER_NAME: 'selectedItemClusterName',
SELECTED_ITEM_NAMESPACE_NAME: 'selectedItemNamespaceName',
+ SELECTED_ITEM_CONTAINER_NAME: 'selectedItemContainerName',
DETAIL_RELATIVE_TIME: 'detailRelativeTime',
DETAIL_START_TIME: 'detailStartTime',
DETAIL_END_TIME: 'detailEndTime',
@@ -783,7 +958,7 @@ export const METRIC_NAMESPACE_BY_ENTITY: Record<InfraMonitoringEntity, string> =
[InfraMonitoringEntity.DEPLOYMENTS]: 'k8s.',
[InfraMonitoringEntity.STATEFULSETS]: 'k8s.',
[InfraMonitoringEntity.DAEMONSETS]: 'k8s.',
- [InfraMonitoringEntity.CONTAINERS]: 'k8s.pod.',
+ [InfraMonitoringEntity.CONTAINERS]: 'k8s.container.',
[InfraMonitoringEntity.JOBS]: 'k8s.',
[InfraMonitoringEntity.VOLUMES]: 'k8s.volume.',
};
diff --git a/frontend/src/container/InfraMonitoringK8sV2/hooks.ts b/frontend/src/container/InfraMonitoringK8sV2/hooks.ts
index 33e4bbd0ba..80ad35c302 100644
--- a/frontend/src/container/InfraMonitoringK8sV2/hooks.ts
+++ b/frontend/src/container/InfraMonitoringK8sV2/hooks.ts
@@ -16,8 +16,8 @@ import {
import { parseAsJsonNoValidate } from 'utils/nuqsParsers';
import {
+ DEFAULT_K8S_CATEGORY,
INFRA_MONITORING_K8S_PARAMS_KEYS,
- K8sCategories,
VIEWS,
} from './constants';
import { orderBySchema, OrderBySchemaType } from './schemas';
@@ -130,19 +130,23 @@ export const useInfraMonitoringCategory = (): UseQueryStateReturn<
> =>
useQueryState(
INFRA_MONITORING_K8S_PARAMS_KEYS.CATEGORY,
- parseAsString.withDefault(K8sCategories.PODS).withOptions(defaultNuqsOptions),
+ parseAsString
+ .withDefault(DEFAULT_K8S_CATEGORY)
+ .withOptions({ ...defaultNuqsOptions, clearOnDefault: false }),
);
export interface SelectedItemParams {
selectedItem: string | null;
clusterName?: string | null;
namespaceName?: string | null;
+ containerName?: string | null;
}
const selectedItemParamsParsers = {
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM]: parseAsString,
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CLUSTER_NAME]: parseAsString,
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_NAMESPACE_NAME]: parseAsString,
+ [INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CONTAINER_NAME]: parseAsString,
};
export type UseSelectedItemParamsReturn = [
@@ -167,6 +171,9 @@ export const useInfraMonitoringSelectedItemParams =
namespaceName:
rawParams[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_NAMESPACE_NAME] ??
null,
+ containerName:
+ rawParams[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CONTAINER_NAME] ??
+ null,
}),
[rawParams],
);
@@ -178,6 +185,7 @@ export const useInfraMonitoringSelectedItemParams =
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM]: null,
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CLUSTER_NAME]: null,
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_NAMESPACE_NAME]: null,
+ [INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CONTAINER_NAME]: null,
});
return;
}
@@ -189,6 +197,8 @@ export const useInfraMonitoringSelectedItemParams =
newParams.clusterName ?? null,
[INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_NAMESPACE_NAME]:
newParams.namespaceName ?? null,
+ [INFRA_MONITORING_K8S_PARAMS_KEYS.SELECTED_ITEM_CONTAINER_NAME]:
+ newParams.containerName ?? null,
});
},
[setRawParams],
diff --git a/frontend/src/pages/InfrastructureMonitoring/constants.tsx b/frontend/src/pages/InfrastructureMonitoring/constants.tsx
index 82c098a5d8..dfb5efafa5 100644
--- a/frontend/src/pages/InfrastructureMonitoring/constants.tsx
+++ b/frontend/src/pages/InfrastructureMonitoring/constants.tsx
@@ -2,6 +2,10 @@ import { TabRoutes } from 'components/RouteTab/types';
import ROUTES from 'constants/routes';
import InfraMonitoringHostsV2 from 'container/InfraMonitoringHostsV2';
import InfraMonitoringK8sV2 from 'container/InfraMonitoringK8sV2';
+import {
+ DEFAULT_K8S_CATEGORY,
+ INFRA_MONITORING_K8S_PARAMS_KEYS,
+} from 'container/InfraMonitoringK8sV2/constants';
import { Inbox } from '@signozhq/icons';
function HostsContainer(): JSX.Element {
@@ -30,6 +34,6 @@ export const Kubernetes: TabRoutes = {
<Inbox size={16} /> Kubernetes
</div>
),
- route: ROUTES.INFRASTRUCTURE_MONITORING_KUBERNETES,
+ route: `${ROUTES.INFRASTRUCTURE_MONITORING_KUBERNETES}?${INFRA_MONITORING_K8S_PARAMS_KEYS.CATEGORY}=${DEFAULT_K8S_CATEGORY}`,
key: ROUTES.INFRASTRUCTURE_MONITORING_KUBERNETES,
};