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: update query builder to support spatial aggregations and functions #4569

Merged
merged 30 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e0642fd
feat: update query builder to support spatial aggregations and functions
YounixM Feb 18, 2024
e874439
feat: handle query function - value
YounixM Feb 18, 2024
7ca2589
fix: rename guage to gauge, fix styles
YounixM Feb 18, 2024
0dbc483
feat: add shorcuts to dashboard and improve ui
YounixM Feb 18, 2024
f80a76b
feat: dashboard - add panel - ui updates
YounixM Feb 18, 2024
a64c68b
feat: update functions ui and restrict max 3 functions
YounixM Feb 19, 2024
8cb4a79
chore: resolve conflicts
srikanthccv Feb 13, 2024
c6482fe
chore: several fixes
srikanthccv Feb 19, 2024
ed1e172
feat: update dashboard default version to v3
YounixM Feb 19, 2024
14fcc51
feat: update logsConnectionStatus query range payload to add v4 variable
YounixM Feb 19, 2024
ea415a4
feat: show functions and space aggregation in v4 only
YounixM Feb 20, 2024
5e68e01
feat: handle duplicate labels in charts tooltip
YounixM Feb 20, 2024
4dc1e7f
fix: update the spaceAggregation element key
YounixM Feb 21, 2024
244b367
fix: update the spaceAggregation upon time Aggregation change
YounixM Feb 21, 2024
b04dead
chore: fix the aggregate attributes validation
srikanthccv Feb 21, 2024
2638d45
feat: show functions for metrics based alerts v4
YounixM Feb 22, 2024
0441400
Merge branch 'develop' into metrics-qb-change
srikanthccv Feb 27, 2024
9f4fa2f
feat: update functions styles
YounixM Feb 27, 2024
1eb7f3e
Merge branch 'develop' into metrics-qb-change
srikanthccv Feb 27, 2024
8da74c4
chore: add v4 support for rules
srikanthccv Feb 20, 2024
9ab75bc
feat: update create panels list
YounixM Feb 28, 2024
3bfbd36
Merge branch 'develop' into metrics-qb-change
YounixM Feb 28, 2024
3fa5aea
Merge branch 'develop' into metrics-qb-change
srikanthccv Feb 28, 2024
f47ff43
feat: add bar chart option in dashboard
YounixM Feb 28, 2024
680d1d9
chore: remove print and update version
srikanthccv Feb 28, 2024
4606598
feat: handle v3/v4 version to query-range api call for metrics dashbo…
YounixM Feb 28, 2024
78a5614
Merge branch 'develop' into metrics-qb-change
srikanthccv Feb 29, 2024
53a7681
feat: handle version incase of create alerts from dashboard
YounixM Feb 29, 2024
5c2d2ee
feat: show reduce to options in table and value panel types
YounixM Mar 1, 2024
462b059
Merge branch 'develop' into metrics-qb-change
srikanthccv Mar 1, 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
Prev Previous commit
Next Next commit
Merge branch 'develop' into metrics-qb-change
  • Loading branch information
YounixM committed Feb 28, 2024
commit 3bfbd36007c292d32d2428df7a49f5e9dd00ca84
2 changes: 1 addition & 1 deletion frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config: Config.InitialOptions = {
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': 'jest-preview/transforms/file',
},
transformIgnorePatterns: [
'node_modules/(?!(lodash-es|react-dnd|core-dnd|@react-dnd|dnd-core|react-dnd-html5-backend|axios|@signozhq/design-tokens)/)',
'node_modules/(?!(lodash-es|react-dnd|core-dnd|@react-dnd|dnd-core|react-dnd-html5-backend|axios|@signozhq/design-tokens|d3-interpolate|d3-color)/)',
],
setupFilesAfterEnv: ['<rootDir>jest.setup.ts'],
testPathIgnorePatterns: ['/node_modules/', '/public/'],
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/assets/Dashboard/BarIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { CSSProperties } from 'react';

function BarIcon({
fillColor,
}: {
fillColor: CSSProperties['color'];
}): JSX.Element {
return (
<svg
width="30"
height="30"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 2H6C4.89543 2 4 2.89543 4 4V16C4 17.1046 4.89543 18 6 18H8C9.10457 18 10 17.1046 10 16V4C10 2.89543 9.10457 2 8 2Z"
stroke={fillColor}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M18 9H16C14.8954 9 14 9.89543 14 11V16C14 17.1046 14.8954 18 16 18H18C19.1046 18 20 17.1046 20 16V11C20 9.89543 19.1046 9 18 9Z"
stroke={fillColor}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M22 22H2"
stroke={fillColor}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}

export default BarIcon;
2 changes: 2 additions & 0 deletions frontend/src/constants/panelTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const PANEL_TYPES_COMPONENT_MAP = {
[PANEL_TYPES.TRACE]: null,
[PANEL_TYPES.LIST]: LogsPanelComponent,
[PANEL_TYPES.EMPTY_WIDGET]: null,
[PANEL_TYPES.BAR]: Uplot,
} as const;

export const getComponentForPanelType = (
Expand All @@ -27,6 +28,7 @@ export const getComponentForPanelType = (
[PANEL_TYPES.TRACE]: null,
[PANEL_TYPES.LIST]:
dataSource === DataSource.LOGS ? LogsPanelComponent : TracesTableComponent,
[PANEL_TYPES.BAR]: Uplot,
[PANEL_TYPES.EMPTY_WIDGET]: null,
};

Expand Down
1 change: 1 addition & 0 deletions frontend/src/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export enum PANEL_TYPES {
TABLE = 'table',
LIST = 'list',
TRACE = 'trace',
BAR = 'bar',
EMPTY_WIDGET = 'EMPTY_WIDGET',
}

Expand Down
13 changes: 12 additions & 1 deletion frontend/src/container/FormAlertRules/ChartPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { AlertDef } from 'types/api/alerts/def';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
import { GlobalReducer } from 'types/reducer/globalTime';
import { getGraphType } from 'utils/getGraphType';
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
import { getTimeRange } from 'utils/getTimeRange';

import { ChartContainer, FailedMessageContainer } from './styles';
Expand Down Expand Up @@ -86,7 +88,7 @@ function ChartPreview({
{
query: query || initialQueriesMap.metrics,
globalSelectedInterval: selectedInterval,
graphType,
graphType: getGraphType(graphType),
selectedTime,
params: {
allowSelectedIntervalForStepGen,
Expand Down Expand Up @@ -114,6 +116,13 @@ function ChartPreview({
setMaxTimeScale(endTime);
}, [maxTime, minTime, globalSelectedInterval, queryResponse]);

if (queryResponse.data && graphType === PANEL_TYPES.BAR) {
const sortedSeriesData = getSortedSeriesData(
queryResponse.data?.payload.data.result,
);
queryResponse.data.payload.data.result = sortedSeriesData;
}

const chartData = getUPlotChartData(queryResponse?.data?.payload);

const containerDimensions = useResizeObserver(graphRef);
Expand Down Expand Up @@ -153,6 +162,7 @@ function ChartPreview({
],
softMax: null,
softMin: null,
panelType: graphType,
}),
[
yAxisUnit,
Expand All @@ -165,6 +175,7 @@ function ChartPreview({
t,
optionName,
alertDef?.condition.targetUnit,
graphType,
],
);

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/container/FormAlertRules/QuerySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function QuerySection({
alertType,
runQuery,
alertDef,
panelType,
}: QuerySectionProps): JSX.Element {
// init namespace for translations
const { t } = useTranslation('alerts');
Expand All @@ -48,7 +49,7 @@ function QuerySection({

const renderMetricUI = (): JSX.Element => (
<QueryBuilder
panelType={PANEL_TYPES.TIME_SERIES}
panelType={panelType}
config={{
queryVariant: 'static',
initialDataSource: ALERTS_DATA_SOURCE_MAP[alertType],
Expand Down Expand Up @@ -215,6 +216,7 @@ interface QuerySectionProps {
alertType: AlertTypes;
runQuery: VoidFunction;
alertDef: AlertDef;
panelType: PANEL_TYPES;
}

export default QuerySection;
19 changes: 17 additions & 2 deletions frontend/src/container/FormAlertRules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import saveAlertApi from 'api/alerts/save';
import testAlertApi from 'api/alerts/testAlert';
import { FeatureKeys } from 'constants/features';
import { QueryParams } from 'constants/query';
import { PANEL_TYPES } from 'constants/queryBuilder';
import ROUTES from 'constants/routes';
import QueryTypeTag from 'container/NewWidget/LeftContainer/QueryTypeTag';
Expand All @@ -20,6 +21,7 @@ import { useShareBuilderUrl } from 'hooks/queryBuilder/useShareBuilderUrl';
import { updateStepInterval } from 'hooks/queryBuilder/useStepInterval';
import { MESSAGE, useIsFeatureDisabled } from 'hooks/useFeatureFlag';
import { useNotifications } from 'hooks/useNotifications';
import useUrlQuery from 'hooks/useUrlQuery';
import history from 'lib/history';
import { mapQueryDataFromApi } from 'lib/newQueryBuilder/queryBuilderMappers/mapQueryDataFromApi';
import { mapQueryDataToApi } from 'lib/newQueryBuilder/queryBuilderMappers/mapQueryDataToApi';
Expand Down Expand Up @@ -68,14 +70,23 @@ function FormAlertRules({
GlobalReducer
>((state) => state.globalTime);

const urlQuery = useUrlQuery();

const panelType = urlQuery.get(QueryParams.panelTypes) as PANEL_TYPES | null;

const {
currentQuery,
panelType,
stagedQuery,
handleRunQuery,
handleSetConfig,
initialDataSource,
redirectWithQueryBuilderData,
} = useQueryBuilder();

useEffect(() => {
handleSetConfig(panelType || PANEL_TYPES.TIME_SERIES, initialDataSource);
}, [handleSetConfig, initialDataSource, panelType]);

// use query client
const ruleCache = useQueryClient();

Expand Down Expand Up @@ -277,7 +288,7 @@ function FormAlertRules({
promQueries: mapQueryDataToApi(currentQuery.promql, 'name').data,
chQueries: mapQueryDataToApi(currentQuery.clickhouse_sql, 'name').data,
queryType: currentQuery.queryType,
panelType: initQuery.panelType,
panelType: panelType || initQuery.panelType,
unit: currentQuery.unit,
},
},
Expand All @@ -290,6 +301,7 @@ function FormAlertRules({
alertDef,
alertType,
initQuery,
panelType,
]);

const isAlertAvailable = useIsFeatureDisabled(
Expand Down Expand Up @@ -423,6 +435,7 @@ function FormAlertRules({
selectedInterval={globalSelectedInterval}
alertDef={alertDef}
yAxisUnit={yAxisUnit || ''}
graphType={panelType || PANEL_TYPES.TIME_SERIES}
/>
);

Expand All @@ -439,6 +452,7 @@ function FormAlertRules({
alertDef={alertDef}
selectedInterval={globalSelectedInterval}
yAxisUnit={yAxisUnit || ''}
graphType={panelType || PANEL_TYPES.TIME_SERIES}
/>
);

Expand Down Expand Up @@ -496,6 +510,7 @@ function FormAlertRules({
alertType={alertType || AlertTypes.METRICS_BASED_ALERT}
runQuery={handleRunQuery}
alertDef={alertDef}
panelType={panelType || PANEL_TYPES.TIME_SERIES}
/>

<RuleOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export const PANEL_TYPES_VS_FULL_VIEW_TABLE: PanelTypeAndGraphManagerVisibilityP
TABLE: false,
LIST: false,
TRACE: false,
BAR: true,
EMPTY_WIDGET: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
import uPlot from 'uplot';
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
import { getTimeRange } from 'utils/getTimeRange';

import { getGraphVisibilityStateOnDataChange } from '../utils';
import { PANEL_TYPES_VS_FULL_VIEW_TABLE } from './contants';
import GraphManager from './GraphManager';
// import GraphManager from './GraphManager';
import { GraphContainer, TimeContainer } from './styles';
import { FullViewProps } from './types';

Expand Down Expand Up @@ -107,6 +107,13 @@ function FullView({
panelTypeAndGraphManagerVisibility: PANEL_TYPES_VS_FULL_VIEW_TABLE,
});

if (response.data && widget.panelTypes === PANEL_TYPES.BAR) {
const sortedSeriesData = getSortedSeriesData(
response.data?.payload.data.result,
);
response.data.payload.data.result = sortedSeriesData;
}

const chartData = getUPlotChartData(response?.data?.payload, widget.fillSpans);

const isDarkMode = useIsDarkMode();
Expand Down Expand Up @@ -152,6 +159,7 @@ function FullView({
maxTimeScale,
softMax: widget.softMax === undefined ? null : widget.softMax,
softMin: widget.softMin === undefined ? null : widget.softMin,
panelType: widget.panelTypes,
});

setChartOptions(newChartOptions);
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/container/GridCardLayout/GridCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { useLocation } from 'react-router-dom';
import { UpdateTimeInterval } from 'store/actions';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
import { getGraphType } from 'utils/getGraphType';
import { getSortedSeriesData } from 'utils/getSortedSeriesData';
import { getTimeRange } from 'utils/getTimeRange';

import EmptyWidget from '../EmptyWidget';
Expand Down Expand Up @@ -125,7 +127,7 @@ function GridCardGraph({
const queryResponse = useGetQueryRange(
{
selectedTime: widget?.timePreferance,
graphType: widget?.panelTypes,
graphType: getGraphType(widget.panelTypes),
query: updatedQuery,
globalSelectedInterval,
variables: getDashboardVariables(variables),
Expand Down Expand Up @@ -160,6 +162,13 @@ function GridCardGraph({
setMaxTimeScale(endTime);
}, [maxTime, minTime, globalSelectedInterval, queryResponse]);

if (queryResponse.data && widget.panelTypes === PANEL_TYPES.BAR) {
const sortedSeriesData = getSortedSeriesData(
queryResponse.data?.payload.data.result,
);
queryResponse.data.payload.data.result = sortedSeriesData;
}

const chartData = getUPlotChartData(queryResponse?.data?.payload, fillSpans);

const isDarkMode = useIsDarkMode();
Expand Down Expand Up @@ -191,6 +200,7 @@ function GridCardGraph({
softMin: widget.softMin === undefined ? null : widget.softMin,
graphsVisibilityStates: graphVisibility,
setGraphsVisibilityStates: setGraphVisibility,
panelType: widget.panelTypes,
}),
[
widget?.id,
Expand All @@ -207,6 +217,7 @@ function GridCardGraph({
maxTimeScale,
graphVisibility,
setGraphVisibility,
widget.panelTypes,
],
);

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/container/GridPanelSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ const GridPanelSwitch = forwardRef<
selectedTime,
},
[PANEL_TYPES.TRACE]: null,
[PANEL_TYPES.BAR]: {
data,
options,
ref,
},
[PANEL_TYPES.EMPTY_WIDGET]: null,
};

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/container/GridPanelSwitch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ export type PropsTypePropsMap = {
[PANEL_TYPES.TABLE]: GridTableComponentProps;
[PANEL_TYPES.TRACE]: null;
[PANEL_TYPES.LIST]: LogsPanelComponentProps | TracesTableComponentProps;
[PANEL_TYPES.BAR]: UplotProps & {
ref: ForwardedRef<ToggleGraphProps | undefined>;
};
[PANEL_TYPES.EMPTY_WIDGET]: null;
};
4 changes: 3 additions & 1 deletion frontend/src/container/ListAlertRules/ListAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
history.push(
`${ROUTES.EDIT_ALERTS}?ruleId=${record.id.toString()}&${
QueryParams.compositeQuery
}=${encodeURIComponent(JSON.stringify(compositeQuery))}`,
}=${encodeURIComponent(JSON.stringify(compositeQuery))}&panelTypes=${
record.condition.compositeQuery.panelType
}`,
);
})
.catch(handleError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const PANEL_TYPES_INITIAL_QUERY = {
[PANEL_TYPES.TABLE]: initialQueriesMap.metrics,
[PANEL_TYPES.LIST]: initialQueriesMap.logs,
[PANEL_TYPES.TRACE]: initialQueriesMap.traces,
[PANEL_TYPES.BAR]: initialQueriesMap.metrics,
[PANEL_TYPES.EMPTY_WIDGET]: initialQueriesMap.metrics,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { WidgetGraphProps } from 'container/NewWidget/types';
import { useGetWidgetQueryRange } from 'hooks/queryBuilder/useGetWidgetQueryRange';
import useUrlQuery from 'hooks/useUrlQuery';
import { useDashboard } from 'providers/Dashboard/Dashboard';
import { getGraphType } from 'utils/getGraphType';
import { getSortedSeriesData } from 'utils/getSortedSeriesData';

import { NotFoundContainer } from './styles';
import WidgetGraph from './WidgetGraphs';
Expand All @@ -31,10 +33,17 @@ function WidgetGraphContainer({
const selectedWidget = widgets.find((e) => e.id === widgetId);

const getWidgetQueryRange = useGetWidgetQueryRange({
graphType: selectedGraph,
graphType: getGraphType(selectedGraph),
selectedTime: selectedTime.enum,
});

if (getWidgetQueryRange.data && selectedGraph === PANEL_TYPES.BAR) {
const sortedSeriesData = getSortedSeriesData(
getWidgetQueryRange.data?.payload.data.result,
);
getWidgetQueryRange.data.payload.data.result = sortedSeriesData;
}

if (selectedWidget === undefined) {
return <Card>Invalid widget</Card>;
}
Expand Down Expand Up @@ -83,6 +92,7 @@ function WidgetGraphContainer({
selectedLogFields={selectedLogFields}
selectedTracesFields={selectedTracesFields}
selectedTime={selectedTime}
selectedGraph={selectedGraph}
/>
);
}
Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.