fix: summary metric type works with query builder

This commit is contained in:
srikanthccv 2025-10-04 18:52:01 +05:30
parent 101b3668b5
commit be185bdda8
3 changed files with 26 additions and 1 deletions

View File

@ -97,6 +97,7 @@ export const metricsSpaceAggregationOperatorsByType = {
Gauge: metricsGaugeSpaceAggregateOperatorOptions, Gauge: metricsGaugeSpaceAggregateOperatorOptions,
Histogram: metricsHistogramSpaceAggregateOperatorOptions, Histogram: metricsHistogramSpaceAggregateOperatorOptions,
ExponentialHistogram: metricsHistogramSpaceAggregateOperatorOptions, ExponentialHistogram: metricsHistogramSpaceAggregateOperatorOptions,
Summary: metricsGaugeSpaceAggregateOperatorOptions,
}; };
export const mapOfQueryFilters: Record<DataSource, QueryAdditionalFilter[]> = { export const mapOfQueryFilters: Record<DataSource, QueryAdditionalFilter[]> = {
@ -372,6 +373,7 @@ export enum ATTRIBUTE_TYPES {
GAUGE = 'Gauge', GAUGE = 'Gauge',
HISTOGRAM = 'Histogram', HISTOGRAM = 'Histogram',
EXPONENTIAL_HISTOGRAM = 'ExponentialHistogram', EXPONENTIAL_HISTOGRAM = 'ExponentialHistogram',
SUMMARY = 'Summary',
} }
export type IQueryBuilderState = 'search'; export type IQueryBuilderState = 'search';

View File

@ -203,6 +203,10 @@ export const useQueryOperations: UseQueryOperations = ({
case ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM: case ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM:
setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions); setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions);
break; break;
case ATTRIBUTE_TYPES.SUMMARY:
setSpaceAggregationOptions(metricsGaugeSpaceAggregateOperatorOptions);
break;
default: default:
setSpaceAggregationOptions(metricsUnknownSpaceAggregateOperatorOptions); setSpaceAggregationOptions(metricsUnknownSpaceAggregateOperatorOptions);
break; break;
@ -235,11 +239,17 @@ export const useQueryOperations: UseQueryOperations = ({
} else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.GAUGE) { } else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.GAUGE) {
newQuery.aggregateOperator = MetricAggregateOperator.AVG; newQuery.aggregateOperator = MetricAggregateOperator.AVG;
newQuery.timeAggregation = MetricAggregateOperator.AVG; newQuery.timeAggregation = MetricAggregateOperator.AVG;
} else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.SUMMARY) {
newQuery.aggregateOperator = MetricAggregateOperator.MAX;
newQuery.timeAggregation = MetricAggregateOperator.MAX;
newQuery.spaceAggregation = MetricAggregateOperator.MAX;
} else { } else {
newQuery.timeAggregation = ''; newQuery.timeAggregation = '';
} }
newQuery.spaceAggregation = ''; if (newQuery.aggregateAttribute?.type !== ATTRIBUTE_TYPES.SUMMARY) {
newQuery.spaceAggregation = '';
}
// Handled query with unknown metric to avoid 400 and 500 errors // Handled query with unknown metric to avoid 400 and 500 errors
// With metric value typed and not available then - time - 'avg', space - 'avg' // With metric value typed and not available then - time - 'avg', space - 'avg'
@ -285,6 +295,15 @@ export const useQueryOperations: UseQueryOperations = ({
spaceAggregation: '', spaceAggregation: '',
}, },
]; ];
} else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.SUMMARY) {
newQuery.aggregations = [
{
timeAggregation: MetricAggregateOperator.MAX,
metricName: newQuery.aggregateAttribute?.key || '',
temporality: '',
spaceAggregation: MetricAggregateOperator.MAX,
},
];
} else { } else {
newQuery.aggregations = [ newQuery.aggregations = [
{ {

View File

@ -29,6 +29,10 @@ export const getMetricsOperatorsByAttributeType = ({
if (aggregateAttributeType === ATTRIBUTE_TYPES.GAUGE) { if (aggregateAttributeType === ATTRIBUTE_TYPES.GAUGE) {
return metricsOperatorsByType.Gauge; return metricsOperatorsByType.Gauge;
} }
if (aggregateAttributeType === ATTRIBUTE_TYPES.SUMMARY) {
return metricsOperatorsByType.Gauge;
}
} }
if (dataSource === DataSource.METRICS && isEmpty(aggregateAttributeType)) { if (dataSource === DataSource.METRICS && isEmpty(aggregateAttributeType)) {