Yunus M e4505693b0
feat: added the host list view and filters (#6210) (#6501)
* feat: added the host list view and filters (#6210)

* feat: added the host list view and filters

* feat: removed group by filter and added autocomplete for where clause

* feat: updated the table view and added the pagination

* feat: pass updated filters to api to get filtered data in the list

* feat: added global time range and order by for cpu,memory,iowait,load

* feat: added order by and color codes for cpu and memory usage progress bar

* refactor: removed inline styles

* Host lists improvement (#6366)

* style: added new style changes for date time selection in host lists view

* style: added padding to date time selector

* style: removed unnecessary styles for host tabs

* style: removed unused css

* feat: added the host detail view (#6267)

* Host containers (#6297)

* feat: added the host detail view

* feat: completed containers and processes details view

* Show host metrics panels in metrics tab. (#6306)

* feat: added the host detail view

* feat: completed containers and processes details view

* feat: added host metrics panels in metrics tabs

* refactor: removed inline styles from host containers and processes tabs

* style: added top and bottom margin to containers and processes tab

* Metrics time selection (#6360)

* feat: added the host detail view

* feat: completed containers and processes details view

* feat: added host metrics panels in metrics tabs

* refactor: removed inline styles from host containers and processes tabs

* feat: added logs and traces tab in host metrics detail view

* chore: removed console statements

* feat: added DateTimeSelection component in metrics tab

* style: added top and bottom margin to containers and processes tab

* style: removed inline styles

* feat: added logs and traces tab in host metrics detail view (#6359)

* feat: added the host detail view

* feat: completed containers and processes details view

* feat: added host metrics panels in metrics tabs

* refactor: removed inline styles from host containers and processes tabs

* feat: added logs and traces tab in host metrics detail view

* chore: removed console statements

* feat: added filters and time selection in traces tab

* fix: resolved metrics,logs and traces tab issues

* feat: added navigation for logs and traces to respective explorer pages

* fix: added the code for logs tab and navigation to respective explorer page

* fix: added fixes for date time selection custom issue

* style: added styles for light mode

* refactor: removed unused code and added comments

* refactor: added new code for host metric attribute keys

* feat: reset query data once we are on infra monitoring page

* chore: remove optional parameter from get attributes and groupby interfaces

* feat: update ui as per the designs

* fix: logs list, time select and other ui issues

* feat: update title for infra monitoring page

* feat: update copies

* feat: update styles for light mode

* fix: reset page size on filter, open explorers in new tab, enable horizontal scroll

* feat: traces tab updates

* feat: move infra monitoring behind ff

* fix: remove sorting from host listing page

---------

Co-authored-by: Yunus M <myounis.ar@live.com>

* chore: fix lint errors

---------

Co-authored-by: rahulkeswani101 <rahul@signoz.io>
2024-11-21 21:53:05 +05:30

114 lines
2.9 KiB
TypeScript

import { Tag, Typography } from 'antd';
import { ColumnsType } from 'antd/es/table';
import ROUTES from 'constants/routes';
import { getMs } from 'container/Trace/Filters/Panel/PanelBody/Duration/util';
import { formUrlParams } from 'container/TraceDetail/utils';
import dayjs from 'dayjs';
import { RowData } from 'lib/query/createTableColumnsFromQuery';
import { Link } from 'react-router-dom';
import { ILog } from 'types/api/logs/log';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { QueryDataV3 } from 'types/api/widgets/getQuery';
export function BlockLink({
children,
to,
openInNewTab,
}: {
children: React.ReactNode;
to: string;
openInNewTab: boolean;
}): any {
// Display block to make the whole cell clickable
return (
<Link
to={to}
style={{ display: 'block' }}
target={openInNewTab ? '_blank' : '_self'}
>
{children}
</Link>
);
}
export const transformDataWithDate = (
data: QueryDataV3[],
): Omit<ILog, 'timestamp'>[] =>
data[0]?.list?.map(({ data, timestamp }) => ({ ...data, date: timestamp })) ||
[];
export const getTraceLink = (record: RowData): string =>
`${ROUTES.TRACE}/${record.traceID}${formUrlParams({
spanId: record.spanID,
levelUp: 0,
levelDown: 0,
})}`;
export const getListColumns = (
selectedColumns: BaseAutocompleteData[],
): ColumnsType<RowData> => {
const initialColumns: ColumnsType<RowData> = [
{
dataIndex: 'date',
key: 'date',
title: 'Timestamp',
width: 145,
render: (value, item): JSX.Element => {
const date =
typeof value === 'string'
? dayjs(value).format('YYYY-MM-DD HH:mm:ss.SSS')
: dayjs(value / 1e6).format('YYYY-MM-DD HH:mm:ss.SSS');
return (
<BlockLink to={getTraceLink(item)} openInNewTab={false}>
<Typography.Text>{date}</Typography.Text>
</BlockLink>
);
},
},
];
const columns: ColumnsType<RowData> =
selectedColumns.map(({ dataType, key, type }) => ({
title: key,
dataIndex: key,
key: `${key}-${dataType}-${type}`,
width: 145,
render: (value, item): JSX.Element => {
if (value === '') {
return (
<BlockLink to={getTraceLink(item)} openInNewTab={false}>
<Typography data-testid={key}>N/A</Typography>
</BlockLink>
);
}
if (key === 'httpMethod' || key === 'responseStatusCode') {
return (
<BlockLink to={getTraceLink(item)} openInNewTab={false}>
<Tag data-testid={key} color="magenta">
{value}
</Tag>
</BlockLink>
);
}
if (key === 'durationNano') {
return (
<BlockLink to={getTraceLink(item)} openInNewTab={false}>
<Typography data-testid={key}>{getMs(value)}ms</Typography>
</BlockLink>
);
}
return (
<BlockLink to={getTraceLink(item)} openInNewTab={false}>
<Typography data-testid={key}>{value}</Typography>
</BlockLink>
);
},
responsive: ['md'],
})) || [];
return [...initialColumns, ...columns];
};