mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 10:15:54 +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,
|
||||||
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,
|
PANEL_TYPES,
|
||||||
} from 'constants/queryBuilder';
|
} from 'constants/queryBuilder';
|
||||||
import {
|
import {
|
||||||
|
metricAggregateOperatorOptions,
|
||||||
|
metricsEmptySpaceAggregateOperatorOptions,
|
||||||
metricsGaugeSpaceAggregateOperatorOptions,
|
metricsGaugeSpaceAggregateOperatorOptions,
|
||||||
metricsHistogramSpaceAggregateOperatorOptions,
|
metricsHistogramSpaceAggregateOperatorOptions,
|
||||||
metricsSumSpaceAggregateOperatorOptions,
|
metricsSumSpaceAggregateOperatorOptions,
|
||||||
@ -21,6 +23,7 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
|||||||
import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';
|
import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';
|
||||||
import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';
|
import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';
|
||||||
import { findDataTypeOfOperator } from 'lib/query/findDataTypeOfOperator';
|
import { findDataTypeOfOperator } from 'lib/query/findDataTypeOfOperator';
|
||||||
|
import { isEmpty } from 'lodash-es';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||||
import {
|
import {
|
||||||
@ -145,12 +148,14 @@ export const useQueryOperations: UseQueryOperations = ({
|
|||||||
|
|
||||||
const handleMetricAggregateAtributeTypes = useCallback(
|
const handleMetricAggregateAtributeTypes = useCallback(
|
||||||
(aggregateAttribute: BaseAutocompleteData): any => {
|
(aggregateAttribute: BaseAutocompleteData): any => {
|
||||||
const newOperators = getMetricsOperatorsByAttributeType({
|
const newOperators = !isEmpty(aggregateAttribute.type)
|
||||||
dataSource: DataSource.METRICS,
|
? getMetricsOperatorsByAttributeType({
|
||||||
panelType: panelType || PANEL_TYPES.TIME_SERIES,
|
dataSource: DataSource.METRICS,
|
||||||
aggregateAttributeType:
|
panelType: panelType || PANEL_TYPES.TIME_SERIES,
|
||||||
(aggregateAttribute.type as ATTRIBUTE_TYPES) || ATTRIBUTE_TYPES.GAUGE,
|
aggregateAttributeType:
|
||||||
});
|
(aggregateAttribute.type as ATTRIBUTE_TYPES) || ATTRIBUTE_TYPES.GAUGE,
|
||||||
|
})
|
||||||
|
: metricAggregateOperatorOptions;
|
||||||
|
|
||||||
switch (aggregateAttribute.type) {
|
switch (aggregateAttribute.type) {
|
||||||
case ATTRIBUTE_TYPES.SUM:
|
case ATTRIBUTE_TYPES.SUM:
|
||||||
@ -168,7 +173,7 @@ export const useQueryOperations: UseQueryOperations = ({
|
|||||||
setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions);
|
setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
setSpaceAggregationOptions(metricsGaugeSpaceAggregateOperatorOptions);
|
setSpaceAggregationOptions(metricsEmptySpaceAggregateOperatorOptions);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,14 +199,12 @@ export const useQueryOperations: UseQueryOperations = ({
|
|||||||
if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.SUM) {
|
if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.SUM) {
|
||||||
newQuery.aggregateOperator = MetricAggregateOperator.RATE;
|
newQuery.aggregateOperator = MetricAggregateOperator.RATE;
|
||||||
newQuery.timeAggregation = MetricAggregateOperator.RATE;
|
newQuery.timeAggregation = MetricAggregateOperator.RATE;
|
||||||
} else if (newQuery.aggregateAttribute.type === ATTRIBUTE_TYPES.GAUGE) {
|
newQuery.spaceAggregation = MetricAggregateOperator.SUM;
|
||||||
|
} else {
|
||||||
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
|
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
|
||||||
newQuery.timeAggregation = MetricAggregateOperator.AVG;
|
newQuery.timeAggregation = MetricAggregateOperator.AVG;
|
||||||
} else {
|
newQuery.spaceAggregation = MetricAggregateOperator.AVG;
|
||||||
newQuery.timeAggregation = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newQuery.spaceAggregation = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSetQueryData(index, newQuery);
|
handleSetQueryData(index, newQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user