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 all commits
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
2 changes: 1 addition & 1 deletion frontend/public/locales/en-GB/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"dashboard_unsave_changes": "There are unsaved changes in the Query builder, please stage and run the query or the changes will be lost. Press OK to discard.",
"dashboard_save_changes": "Your graph built with {{queryTag}} query will be saved. Press OK to confirm.",
"your_graph_build_with": "Your graph built with",
"dashboar_ok_confirm": "query will be saved. Press OK to confirm."
"dashboard_ok_confirm": "query will be saved. Press OK to confirm."
}
2 changes: 1 addition & 1 deletion frontend/public/locales/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
"dashboard_unsave_changes": "There are unsaved changes in the Query builder, please stage and run the query or the changes will be lost. Press OK to discard.",
"dashboard_save_changes": "Your graph built with {{queryTag}} query will be saved. Press OK to confirm.",
"your_graph_build_with": "Your graph built with",
"dashboar_ok_confirm": "query will be saved. Press OK to confirm."
"dashboard_ok_confirm": "query will be saved. Press OK to confirm."
}
1 change: 1 addition & 0 deletions frontend/src/api/apiV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const apiV1 = '/api/v1/';

export const apiV2 = '/api/v2/';
export const apiV3 = '/api/v3/';
export const apiV4 = '/api/v4/';
export const apiAlertManager = '/api/alertmanager';

export default apiV1;
15 changes: 14 additions & 1 deletion frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ENVIRONMENT } from 'constants/env';
import { LOCALSTORAGE } from 'constants/localStorage';
import store from 'store';

import apiV1, { apiAlertManager, apiV2, apiV3 } from './apiV1';
import apiV1, { apiAlertManager, apiV2, apiV3, apiV4 } from './apiV1';
import { Logout } from './utils';

const interceptorsResponse = (
Expand Down Expand Up @@ -114,13 +114,26 @@ ApiV2Instance.interceptors.request.use(interceptorsRequestResponse);
export const ApiV3Instance = axios.create({
baseURL: `${ENVIRONMENT.baseURL}${apiV3}`,
});

ApiV3Instance.interceptors.response.use(
interceptorsResponse,
interceptorRejected,
);
ApiV3Instance.interceptors.request.use(interceptorsRequestResponse);
//

// axios V4
export const ApiV4Instance = axios.create({
baseURL: `${ENVIRONMENT.baseURL}${apiV4}`,
});

ApiV4Instance.interceptors.response.use(
interceptorsResponse,
interceptorRejected,
);
ApiV4Instance.interceptors.request.use(interceptorsRequestResponse);
//

AxiosAlertManagerInstance.interceptors.response.use(
interceptorsResponse,
interceptorRejected,
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/api/metrics/getQueryRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiV3Instance as axios } from 'api';
import { ApiV3Instance, ApiV4Instance } from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
import { ErrorResponse, SuccessResponse } from 'types/api';
Expand All @@ -9,10 +9,23 @@ import {

export const getMetricsQueryRange = async (
props: QueryRangePayload,
version: string,
signal: AbortSignal,
): Promise<SuccessResponse<MetricRangePayloadV3> | ErrorResponse> => {
try {
const response = await axios.post('/query_range', props, { signal });
if (version && version === 'v4') {
const response = await ApiV4Instance.post('/query_range', props, { signal });

return {
statusCode: 200,
error: null,
message: response.data.status,
payload: response.data,
params: props,
};
}

const response = await ApiV3Instance.post('/query_range', props, { signal });

return {
statusCode: 200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ export default function LogsFormatOptionsMenu({
setAddNewColumn(!addNewColumn);
};

// console.log('optionsMenuConfig', config);

const handleLinesPerRowChange = (maxLinesPerRow: number | null): void => {
if (
maxLinesPerRow &&
Expand Down Expand Up @@ -221,8 +219,6 @@ export default function LogsFormatOptionsMenu({
className="column-name"
key={value}
onClick={(eve): void => {
console.log('coluimn name', label, value);

eve.stopPropagation();

if (addColumn && addColumn?.onSelect) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/constants/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export const SIGNOZ_UPGRADE_PLAN_URL =
'https://upgrade.signoz.io/upgrade-from-app';

export const DASHBOARD_TIME_IN_DURATION = 'refreshInterval';

export const DEFAULT_ENTITY_VERSION = 'v3';
30 changes: 29 additions & 1 deletion frontend/src/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import { v4 as uuid } from 'uuid';
import {
logsAggregateOperatorOptions,
metricAggregateOperatorOptions,
metricsGaugeAggregateOperatorOptions,
metricsGaugeSpaceAggregateOperatorOptions,
metricsHistogramSpaceAggregateOperatorOptions,
metricsSumAggregateOperatorOptions,
metricsSumSpaceAggregateOperatorOptions,
tracesAggregateOperatorOptions,
} from './queryBuilderOperators';

Expand Down Expand Up @@ -74,6 +79,18 @@ export const mapOfOperators = {
traces: tracesAggregateOperatorOptions,
};

export const metricsOperatorsByType = {
Sum: metricsSumAggregateOperatorOptions,
Gauge: metricsGaugeAggregateOperatorOptions,
};

export const metricsSpaceAggregationOperatorsByType = {
Sum: metricsSumSpaceAggregateOperatorOptions,
Gauge: metricsGaugeSpaceAggregateOperatorOptions,
Histogram: metricsHistogramSpaceAggregateOperatorOptions,
ExponentialHistogram: metricsHistogramSpaceAggregateOperatorOptions,
};

export const mapOfQueryFilters: Record<DataSource, QueryAdditionalFilter[]> = {
metrics: [
// eslint-disable-next-line sonarjs/no-duplicate-string
Expand Down Expand Up @@ -148,6 +165,9 @@ export const initialQueryBuilderFormValues: IBuilderQuery = {
queryName: createNewBuilderItemName({ existNames: [], sourceNames: alphabet }),
aggregateOperator: MetricAggregateOperator.COUNT,
aggregateAttribute: initialAutocompleteData,
timeAggregation: MetricAggregateOperator.RATE,
spaceAggregation: MetricAggregateOperator.SUM,
functions: [],
filters: { items: [], op: 'AND' },
expression: createNewBuilderItemName({
existNames: [],
Expand All @@ -160,7 +180,7 @@ export const initialQueryBuilderFormValues: IBuilderQuery = {
orderBy: [],
groupBy: [],
legend: '',
reduceTo: 'sum',
reduceTo: 'avg',
};

const initialQueryBuilderFormLogsValues: IBuilderQuery = {
Expand Down Expand Up @@ -268,6 +288,14 @@ export enum PANEL_TYPES {
EMPTY_WIDGET = 'EMPTY_WIDGET',
}

// eslint-disable-next-line @typescript-eslint/naming-convention
export enum ATTRIBUTE_TYPES {
SUM = 'Sum',
GAUGE = 'Gauge',
HISTOGRAM = 'Histogram',
EXPONENTIAL_HISTOGRAM = 'ExponentialHistogram',
}

export type IQueryBuilderState = 'search';

export const QUERY_BUILDER_SEARCH_VALUES = {
Expand Down
123 changes: 123 additions & 0 deletions frontend/src/constants/queryBuilderOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,126 @@ export const logsAggregateOperatorOptions: SelectOption<string, string>[] = [
label: 'Rate_max',
},
];

export const metricsSumAggregateOperatorOptions: SelectOption<
string,
string
>[] = [
{
value: MetricAggregateOperator.RATE,
label: 'Rate',
},
{
value: MetricAggregateOperator.INCREASE,
label: 'Increase',
},
];

export const metricsGaugeAggregateOperatorOptions: SelectOption<
string,
string
>[] = [
{
value: MetricAggregateOperator.LATEST,
label: 'Latest',
},
{
value: MetricAggregateOperator.SUM,
label: 'Sum',
},
{
value: MetricAggregateOperator.AVG,
label: 'Avg',
},
{
value: MetricAggregateOperator.MIN,
label: 'Min',
},
{
value: MetricAggregateOperator.MAX,
label: 'Max',
},
{
value: MetricAggregateOperator.COUNT,
label: 'Count',
},
{
value: MetricAggregateOperator.COUNT_DISTINCT,
label: 'Count Distinct',
},
];

export const metricsSumSpaceAggregateOperatorOptions: SelectOption<
string,
string
>[] = [
{
value: MetricAggregateOperator.SUM,
label: 'Sum',
},
{
value: MetricAggregateOperator.AVG,
label: 'Avg',
},
{
value: MetricAggregateOperator.MIN,
label: 'Min',
},
{
value: MetricAggregateOperator.MAX,
label: 'Max',
},
];

export const metricsGaugeSpaceAggregateOperatorOptions: SelectOption<
string,
string
>[] = [
{
value: MetricAggregateOperator.SUM,
label: 'Sum',
},
{
value: MetricAggregateOperator.AVG,
label: 'Avg',
},
{
value: MetricAggregateOperator.MIN,
label: 'Min',
},
{
value: MetricAggregateOperator.MAX,
label: 'Max',
},
];

export const metricsHistogramSpaceAggregateOperatorOptions: SelectOption<
string,
string
>[] = [
{
value: MetricAggregateOperator.P50,
label: 'P50',
},
{
value: MetricAggregateOperator.P75,
label: 'P75',
},
{
value: MetricAggregateOperator.P90,
label: 'P90',
},
{
value: MetricAggregateOperator.P95,
label: 'P95',
},
{
value: MetricAggregateOperator.P99,
label: 'P99',
},
];

export const metricsEmptyTimeAggregateOperatorOptions: SelectOption<
string,
string
>[] = [];
Loading
Loading