mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-18 16:07:10 +00:00
feat: group by severity logs explorer page by default (#5772)
* feat: initial setup for group by severity logs explorer page * chore: reduce the height of the histogram * chore: pr cleanup * chore: minor color update * chore: clean the PR * chore: clean the PR * chore: better base handling * fix: append query names to the legends in case of multiple queries * feat: make the changes only for list view and add back legends
This commit is contained in:
parent
6661aa7686
commit
43577c7ead
@ -139,6 +139,7 @@ export const getGraphOptions = (
|
|||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: {
|
x: {
|
||||||
|
stacked: isStacked,
|
||||||
grid: {
|
grid: {
|
||||||
display: true,
|
display: true,
|
||||||
color: getGridColor(),
|
color: getGridColor(),
|
||||||
@ -165,6 +166,7 @@ export const getGraphOptions = (
|
|||||||
ticks: { color: getAxisLabelColor(currentTheme) },
|
ticks: { color: getAxisLabelColor(currentTheme) },
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
|
stacked: isStacked,
|
||||||
display: true,
|
display: true,
|
||||||
grid: {
|
grid: {
|
||||||
display: true,
|
display: true,
|
||||||
@ -178,9 +180,6 @@ export const getGraphOptions = (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
stacked: {
|
|
||||||
display: isStacked === undefined ? false : 'auto',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
elements: {
|
elements: {
|
||||||
line: {
|
line: {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { QueryData } from 'types/api/widgets/getQuery';
|
|||||||
export type LogsExplorerChartProps = {
|
export type LogsExplorerChartProps = {
|
||||||
data: QueryData[];
|
data: QueryData[];
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
isLogsExplorerViews?: boolean;
|
||||||
isLabelEnabled?: boolean;
|
isLabelEnabled?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,12 +16,14 @@ import { UpdateTimeInterval } from 'store/actions';
|
|||||||
|
|
||||||
import { LogsExplorerChartProps } from './LogsExplorerChart.interfaces';
|
import { LogsExplorerChartProps } from './LogsExplorerChart.interfaces';
|
||||||
import { CardStyled } from './LogsExplorerChart.styled';
|
import { CardStyled } from './LogsExplorerChart.styled';
|
||||||
|
import { getColorsForSeverityLabels } from './utils';
|
||||||
|
|
||||||
function LogsExplorerChart({
|
function LogsExplorerChart({
|
||||||
data,
|
data,
|
||||||
isLoading,
|
isLoading,
|
||||||
isLabelEnabled = true,
|
isLabelEnabled = true,
|
||||||
className,
|
className,
|
||||||
|
isLogsExplorerViews = false,
|
||||||
}: LogsExplorerChartProps): JSX.Element {
|
}: LogsExplorerChartProps): JSX.Element {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const urlQuery = useUrlQuery();
|
const urlQuery = useUrlQuery();
|
||||||
@ -29,15 +31,19 @@ function LogsExplorerChart({
|
|||||||
const handleCreateDatasets: Required<GetChartDataProps>['createDataset'] = useCallback(
|
const handleCreateDatasets: Required<GetChartDataProps>['createDataset'] = useCallback(
|
||||||
(element, index, allLabels) => ({
|
(element, index, allLabels) => ({
|
||||||
data: element,
|
data: element,
|
||||||
backgroundColor: colors[index % colors.length] || themeColors.red,
|
backgroundColor: isLogsExplorerViews
|
||||||
borderColor: colors[index % colors.length] || themeColors.red,
|
? getColorsForSeverityLabels(allLabels[index], index)
|
||||||
|
: colors[index % colors.length] || themeColors.red,
|
||||||
|
borderColor: isLogsExplorerViews
|
||||||
|
? getColorsForSeverityLabels(allLabels[index], index)
|
||||||
|
: colors[index % colors.length] || themeColors.red,
|
||||||
...(isLabelEnabled
|
...(isLabelEnabled
|
||||||
? {
|
? {
|
||||||
label: allLabels[index],
|
label: allLabels[index],
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
}),
|
}),
|
||||||
[isLabelEnabled],
|
[isLabelEnabled, isLogsExplorerViews],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onDragSelect = useCallback(
|
const onDragSelect = useCallback(
|
||||||
@ -112,6 +118,7 @@ function LogsExplorerChart({
|
|||||||
<Graph
|
<Graph
|
||||||
name="logsExplorerChart"
|
name="logsExplorerChart"
|
||||||
data={graphData.data}
|
data={graphData.data}
|
||||||
|
isStacked={isLogsExplorerViews}
|
||||||
type="bar"
|
type="bar"
|
||||||
animate
|
animate
|
||||||
onDragSelect={onDragSelect}
|
onDragSelect={onDragSelect}
|
||||||
|
|||||||
36
frontend/src/container/LogsExplorerChart/utils.ts
Normal file
36
frontend/src/container/LogsExplorerChart/utils.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { Color } from '@signozhq/design-tokens';
|
||||||
|
import { themeColors } from 'constants/theme';
|
||||||
|
import { colors } from 'lib/getRandomColor';
|
||||||
|
|
||||||
|
export function getColorsForSeverityLabels(
|
||||||
|
label: string,
|
||||||
|
index: number,
|
||||||
|
): string {
|
||||||
|
const lowerCaseLabel = label.toLowerCase();
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="trace"}`)) {
|
||||||
|
return Color.BG_ROBIN_300;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="debug"}`)) {
|
||||||
|
return Color.BG_FOREST_500;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="info"}`)) {
|
||||||
|
return Color.BG_SLATE_400;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="warn"}`)) {
|
||||||
|
return Color.BG_AMBER_500;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="error"}`)) {
|
||||||
|
return Color.BG_CHERRY_500;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowerCaseLabel.includes(`{severity_text="fatal"}`)) {
|
||||||
|
return Color.BG_SAKURA_500;
|
||||||
|
}
|
||||||
|
|
||||||
|
return colors[index % colors.length] || themeColors.red;
|
||||||
|
}
|
||||||
@ -147,6 +147,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.logs-histogram {
|
.logs-histogram {
|
||||||
|
.ant-card-body {
|
||||||
|
height: 140px;
|
||||||
|
min-height: 140px;
|
||||||
|
padding: 0 16px 22px 16px;
|
||||||
|
font-family: 'Geist Mono';
|
||||||
|
}
|
||||||
|
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,7 @@ import { useHistory } from 'react-router-dom';
|
|||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { Dashboard } from 'types/api/dashboard/getAll';
|
import { Dashboard } from 'types/api/dashboard/getAll';
|
||||||
import { ILog } from 'types/api/logs/log';
|
import { ILog } from 'types/api/logs/log';
|
||||||
|
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||||
import {
|
import {
|
||||||
IBuilderQuery,
|
IBuilderQuery,
|
||||||
OrderByPayload,
|
OrderByPayload,
|
||||||
@ -188,6 +189,16 @@ function LogsExplorerViews({
|
|||||||
const modifiedQueryData: IBuilderQuery = {
|
const modifiedQueryData: IBuilderQuery = {
|
||||||
...listQuery,
|
...listQuery,
|
||||||
aggregateOperator: LogsAggregatorOperator.COUNT,
|
aggregateOperator: LogsAggregatorOperator.COUNT,
|
||||||
|
groupBy: [
|
||||||
|
{
|
||||||
|
key: 'severity_text',
|
||||||
|
dataType: DataTypes.String,
|
||||||
|
type: '',
|
||||||
|
isColumn: true,
|
||||||
|
isJSON: false,
|
||||||
|
id: 'severity_text--string----true',
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const modifiedQuery: Query = {
|
const modifiedQuery: Query = {
|
||||||
@ -661,6 +672,7 @@ function LogsExplorerViews({
|
|||||||
className="logs-histogram"
|
className="logs-histogram"
|
||||||
isLoading={isFetchingListChartData || isLoadingListChartData}
|
isLoading={isFetchingListChartData || isLoadingListChartData}
|
||||||
data={chartData}
|
data={chartData}
|
||||||
|
isLogsExplorerViews={panelType === PANEL_TYPES.LIST}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user