mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 05:36:03 +08:00
fix: added default value to time,space aggregation to fix query_range getting 500 for metric (#7414)
* fix: added default value to time,space aggregation to fix query_range getting 500 for metric * fix: added all available operators as default when no attribute type is present * fix: changed operator, time and space values to avg when empty attribute type
This commit is contained in:
parent
d8d8191a32
commit
8c4c357351
@ -425,3 +425,45 @@ export const metricsEmptyTimeAggregateOperatorOptions: SelectOption<
|
||||
string,
|
||||
string
|
||||
>[] = [];
|
||||
|
||||
export const metricsEmptySpaceAggregateOperatorOptions: SelectOption<
|
||||
string,
|
||||
string
|
||||
>[] = [
|
||||
{
|
||||
value: MetricAggregateOperator.SUM,
|
||||
label: 'Sum',
|
||||
},
|
||||
{
|
||||
value: MetricAggregateOperator.AVG,
|
||||
label: 'Avg',
|
||||
},
|
||||
{
|
||||
value: MetricAggregateOperator.MIN,
|
||||
label: 'Min',
|
||||
},
|
||||
{
|
||||
value: MetricAggregateOperator.MAX,
|
||||
label: 'Max',
|
||||
},
|
||||
{
|
||||
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',
|
||||
},
|
||||
];
|
||||
|
@ -9,6 +9,8 @@ import {
|
||||
PANEL_TYPES,
|
||||
} from 'constants/queryBuilder';
|
||||
import {
|
||||
metricAggregateOperatorOptions,
|
||||
metricsEmptySpaceAggregateOperatorOptions,
|
||||
metricsGaugeSpaceAggregateOperatorOptions,
|
||||
metricsHistogramSpaceAggregateOperatorOptions,
|
||||
metricsSumSpaceAggregateOperatorOptions,
|
||||
@ -21,6 +23,7 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';
|
||||
import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';
|
||||
import { findDataTypeOfOperator } from 'lib/query/findDataTypeOfOperator';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import {
|
||||
@ -145,12 +148,14 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
|
||||
const handleMetricAggregateAtributeTypes = useCallback(
|
||||
(aggregateAttribute: BaseAutocompleteData): any => {
|
||||
const newOperators = getMetricsOperatorsByAttributeType({
|
||||
dataSource: DataSource.METRICS,
|
||||
panelType: panelType || PANEL_TYPES.TIME_SERIES,
|
||||
aggregateAttributeType:
|
||||
(aggregateAttribute.type as ATTRIBUTE_TYPES) || ATTRIBUTE_TYPES.GAUGE,
|
||||
});
|
||||
const newOperators = !isEmpty(aggregateAttribute.type)
|
||||
? getMetricsOperatorsByAttributeType({
|
||||
dataSource: DataSource.METRICS,
|
||||
panelType: panelType || PANEL_TYPES.TIME_SERIES,
|
||||
aggregateAttributeType:
|
||||
(aggregateAttribute.type as ATTRIBUTE_TYPES) || ATTRIBUTE_TYPES.GAUGE,
|
||||
})
|
||||
: metricAggregateOperatorOptions;
|
||||
|
||||
switch (aggregateAttribute.type) {
|
||||
case ATTRIBUTE_TYPES.SUM:
|
||||
@ -168,7 +173,7 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions);
|
||||
break;
|
||||
default:
|
||||
setSpaceAggregationOptions(metricsGaugeSpaceAggregateOperatorOptions);
|
||||
setSpaceAggregationOptions(metricsEmptySpaceAggregateOperatorOptions);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -194,14 +199,12 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.SUM) {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.RATE;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.RATE;
|
||||
} else if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.GAUGE) {
|
||||
newQuery.spaceAggregation = MetricAggregateOperator.SUM;
|
||||
} else {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.AVG;
|
||||
} else {
|
||||
newQuery.timeAggregation = '';
|
||||
newQuery.spaceAggregation = MetricAggregateOperator.AVG;
|
||||
}
|
||||
|
||||
newQuery.spaceAggregation = '';
|
||||
}
|
||||
|
||||
handleSetQueryData(index, newQuery);
|
||||
|
Loading…
x
Reference in New Issue
Block a user