Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement deployment details page for infra monitoring #6699

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e8d39c3
feat: base setup for k8s infra monitoring
YounixM Nov 27, 2024
974ec05
feat: setup k8s pods components
YounixM Dec 9, 2024
e90ae39
chore: move pods related files in pods folder
YounixM Dec 9, 2024
ab2ad8e
feat: events tab integration
YounixM Dec 10, 2024
a4a1d85
feat: integrate queries for the metrics tab
YounixM Dec 10, 2024
84a4ac4
feat: update query to fetch logs and traces
YounixM Dec 11, 2024
086416c
feat: update query for quick filters
YounixM Dec 11, 2024
3878212
feat: handle quick filter categorization
YounixM Dec 11, 2024
39d9888
feat: handle category change
YounixM Dec 11, 2024
f1be4d6
feat: handle groupby
YounixM Dec 17, 2024
e6ff2f1
feat: handle quick filters and qb search sync
YounixM Dec 18, 2024
c044f31
feat: do not update url on filters change
YounixM Dec 18, 2024
14eb19a
feat: ui fixes
YounixM Dec 18, 2024
4dfcd0c
feat: group by attribute - show nested table and handle view all
YounixM Dec 18, 2024
791b530
feat: update query for metrics
YounixM Dec 18, 2024
939103b
feat: set size for nested table
YounixM Dec 18, 2024
c19ca09
feat: handle only one expanded row at a time
YounixM Dec 19, 2024
172d693
Merge branch 'main' into feat/infra-monitoring-k8s
srikanthccv Dec 19, 2024
ad5aa1a
feat: implement nodes list table in infra-monitoring
amlannandy Dec 11, 2024
ebf5630
chore: update header props
amlannandy Dec 11, 2024
4317ebe
chore: update columns
amlannandy Dec 15, 2024
1120fad
chore: add cluster name column
amlannandy Dec 16, 2024
82c657d
chore: update props
amlannandy Dec 18, 2024
49a381a
feat: implement group-by and quick select in node list table
amlannandy Dec 18, 2024
60e98fd
feat: implement nested view
amlannandy Dec 19, 2024
7f95f65
chore: styling changes
amlannandy Dec 19, 2024
b5d57e1
chore: fix expand issues
amlannandy Dec 19, 2024
a7010b9
feat: implement nodes list table in infra-monitoring
amlannandy Dec 11, 2024
5699514
feat: implement deployments list table in infra monitoring
amlannandy Dec 11, 2024
0dd674b
chore: remove comments
amlannandy Dec 12, 2024
0d79ce8
feat: remove nodes data
amlannandy Dec 22, 2024
1798c04
feat: implement quick filters and group by
amlannandy Dec 22, 2024
e8cea7e
feat: implement deployment details page
amlannandy Dec 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/public/locales/en-GB/titles.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
"DEFAULT": "Open source Observability Platform | SigNoz",
"ALERT_HISTORY": "SigNoz | Alert Rule History",
"ALERT_OVERVIEW": "SigNoz | Alert Rule Overview",
"INFRASTRUCTURE_MONITORING_HOSTS": "SigNoz | Infra Monitoring"
"INFRASTRUCTURE_MONITORING_HOSTS": "SigNoz | Infra Monitoring",
"INFRASTRUCTURE_MONITORING_KUBERNETES": "SigNoz | Infra Monitoring"
}
3 changes: 2 additions & 1 deletion frontend/public/locales/en/titles.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"ALERT_HISTORY": "SigNoz | Alert Rule History",
"ALERT_OVERVIEW": "SigNoz | Alert Rule Overview",
"MESSAGING_QUEUES": "SigNoz | Messaging Queues",
"INFRASTRUCTURE_MONITORING_HOSTS": "SigNoz | Infra Monitoring"
"INFRASTRUCTURE_MONITORING_HOSTS": "SigNoz | Infra Monitoring",
"INFRASTRUCTURE_MONITORING_KUBERNETES": "SigNoz | Infra Monitoring"
}
7 changes: 7 additions & 0 deletions frontend/src/AppRoutes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@ const routes: AppRoutes[] = [
key: 'INFRASTRUCTURE_MONITORING_HOSTS',
isPrivate: true,
},
{
path: ROUTES.INFRASTRUCTURE_MONITORING_KUBERNETES,
exact: true,
component: InfrastructureMonitoring,
key: 'INFRASTRUCTURE_MONITORING_KUBERNETES',
isPrivate: true,
},
];

export const SUPPORT_ROUTE: AppRoutes = {
Expand Down
70 changes: 70 additions & 0 deletions frontend/src/api/infraMonitoring/getK8sDeploymentsList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { ApiBaseInstance } 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 K8sDeploymentsListPayload {
filters: TagFilter;
groupBy?: BaseAutocompleteData[];
offset?: number;
limit?: number;
orderBy?: {
columnName: string;
order: 'asc' | 'desc';
};
}

export interface K8sDeploymentsData {
deploymentName: string;
cpuUsage: number;
memoryUsage: number;
desiredPods: number;
availablePods: number;
cpuRequest: number;
memoryRequest: number;
cpuLimit: number;
memoryLimit: number;
restarts: number;
meta: {
k8s_cluster_name: string;
k8s_deployment_name: string;
k8s_namespace_name: string;
};
}

export interface K8sDeploymentsListResponse {
status: string;
data: {
type: string;
records: K8sDeploymentsData[];
groups: null;
total: number;
sentAnyHostMetricsData: boolean;
isSendingK8SAgentMetrics: boolean;
};
}

export const getK8sDeploymentsList = async (
props: K8sDeploymentsListPayload,
signal?: AbortSignal,
headers?: Record<string, string>,
): Promise<SuccessResponse<K8sDeploymentsListResponse> | ErrorResponse> => {
try {
const response = await ApiBaseInstance.post('/deployments/list', props, {
signal,
headers,
});

return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
}
};
93 changes: 93 additions & 0 deletions frontend/src/api/infraMonitoring/getK8sPodsList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { ApiBaseInstance } 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 K8sPodsListPayload {
filters: TagFilter;
groupBy?: BaseAutocompleteData[];
offset?: number;
limit?: number;
orderBy?: {
columnName: string;
order: 'asc' | 'desc';
};
}

export interface TimeSeriesValue {
timestamp: number;
value: string;
}

export interface TimeSeries {
labels: Record<string, string>;
labelsArray: Array<Record<string, string>>;
values: TimeSeriesValue[];
}

export interface K8sPodsData {
podUID: string;
podCPU: number;
podCPURequest: number;
podCPULimit: number;
podMemory: number;
podMemoryRequest: number;
podMemoryLimit: number;
restartCount: number;
meta: {
k8s_cronjob_name: string;
k8s_daemonset_name: string;
k8s_deployment_name: string;
k8s_job_name: string;
k8s_namespace_name: string;
k8s_node_name: string;
k8s_pod_name: string;
k8s_pod_uid: string;
k8s_statefulset_name: string;
k8s_cluster_name: string;
};
countByPhase: {
pending: number;
running: number;
succeeded: number;
failed: number;
unknown: number;
};
}

export interface K8sPodsListResponse {
status: string;
data: {
type: string;
records: K8sPodsData[];
groups: null;
total: number;
sentAnyHostMetricsData: boolean;
isSendingK8SAgentMetrics: boolean;
};
}

export const getK8sPodsList = async (
props: K8sPodsListPayload,
signal?: AbortSignal,
headers?: Record<string, string>,
): Promise<SuccessResponse<K8sPodsListResponse> | ErrorResponse> => {
try {
const response = await ApiBaseInstance.post('/pods/list', props, {
signal,
headers,
});

return {
statusCode: 200,
error: null,
message: 'Success',
payload: response.data,
params: props,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
width: calc(100% - 24px);
cursor: pointer;

&.filter-disabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { OPERATORS } from 'constants/queryBuilder';
import { getOperatorValue } from 'container/QueryBuilder/filters/QueryBuilderSearch/utils';
import { useGetAggregateValues } from 'hooks/queryBuilder/useGetAggregateValues';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { cloneDeep, isArray, isEmpty, isEqual } from 'lodash-es';
import { cloneDeep, isArray, isEmpty, isEqual, isFunction } from 'lodash-es';
import { ChevronDown, ChevronRight } from 'lucide-react';
import { useMemo, useState } from 'react';
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
Expand All @@ -34,10 +34,11 @@ function setDefaultValues(
}
interface ICheckboxProps {
filter: IQuickFiltersConfig;
onFilterChange?: (query: Query) => void;
}

export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {
const { filter } = props;
const { filter, onFilterChange } = props;
const [searchText, setSearchText] = useState<string>('');
const [isOpen, setIsOpen] = useState<boolean>(filter.defaultOpen);
const [visibleItemsCount, setVisibleItemsCount] = useState<number>(10);
Expand All @@ -50,9 +51,9 @@ export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {

const { data, isLoading } = useGetAggregateValues(
{
aggregateOperator: 'noop',
dataSource: DataSource.LOGS,
aggregateAttribute: '',
aggregateOperator: filter.aggregateOperator || 'noop',
dataSource: filter.dataSource || DataSource.LOGS,
aggregateAttribute: filter.aggregateAttribute || '',
attributeKey: filter.attributeKey.key,
filterAttributeKeyDataType: filter.attributeKey.dataType || DataTypes.EMPTY,
tagType: filter.attributeKey.type || '',
Expand All @@ -72,7 +73,7 @@ export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {
);
const currentAttributeKeys = attributeValues.slice(0, visibleItemsCount);

// derive the state of each filter key here in the renderer itself and keep it in sync with staged query
// derive the state of each filter key here in the renderer itself and keep it in sync with current query
// also we need to keep a note of last focussed query.
// eslint-disable-next-line sonarjs/cognitive-complexity
const currentFilterState = useMemo(() => {
Expand Down Expand Up @@ -159,7 +160,12 @@ export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {
})),
},
};
redirectWithQueryBuilderData(preparedQuery);

if (onFilterChange && isFunction(onFilterChange)) {
onFilterChange(preparedQuery);
} else {
redirectWithQueryBuilderData(preparedQuery);
}
};

const isSomeFilterPresentForCurrentAttribute = currentQuery.builder.queryData?.[
Expand Down Expand Up @@ -391,7 +397,11 @@ export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {
},
};

redirectWithQueryBuilderData(finalQuery);
if (onFilterChange && isFunction(onFilterChange)) {
onFilterChange(finalQuery);
} else {
redirectWithQueryBuilderData(finalQuery);
}
};

return (
Expand Down Expand Up @@ -511,3 +521,7 @@ export default function CheckboxFilter(props: ICheckboxProps): JSX.Element {
</div>
);
}

CheckboxFilter.defaultProps = {
onFilterChange: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
display: flex;
align-items: center;
gap: 6px;
width: 100%;
justify-content: flex-start;

.text {
color: var(--bg-vanilla-400);
Expand Down Expand Up @@ -50,6 +52,8 @@
display: flex;
align-items: center;
gap: 12px;
width: 100%;
justify-content: flex-end;

.divider-filter {
width: 1px;
Expand Down
Loading
Loading