diff --git a/frontend/src/constants/queryBuilder.ts b/frontend/src/constants/queryBuilder.ts index 4638cb7c27fa..45d1dfcb1b9b 100644 --- a/frontend/src/constants/queryBuilder.ts +++ b/frontend/src/constants/queryBuilder.ts @@ -97,6 +97,7 @@ export const metricsSpaceAggregationOperatorsByType = { Gauge: metricsGaugeSpaceAggregateOperatorOptions, Histogram: metricsHistogramSpaceAggregateOperatorOptions, ExponentialHistogram: metricsHistogramSpaceAggregateOperatorOptions, + Summary: metricsGaugeSpaceAggregateOperatorOptions, }; export const mapOfQueryFilters: Record = { @@ -372,6 +373,7 @@ export enum ATTRIBUTE_TYPES { GAUGE = 'Gauge', HISTOGRAM = 'Histogram', EXPONENTIAL_HISTOGRAM = 'ExponentialHistogram', + SUMMARY = 'Summary', } export type IQueryBuilderState = 'search'; diff --git a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts index 4a8fbd839891..40b0c2342599 100644 --- a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts +++ b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts @@ -203,6 +203,10 @@ export const useQueryOperations: UseQueryOperations = ({ case ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM: setSpaceAggregationOptions(metricsHistogramSpaceAggregateOperatorOptions); break; + + case ATTRIBUTE_TYPES.SUMMARY: + setSpaceAggregationOptions(metricsGaugeSpaceAggregateOperatorOptions); + break; default: setSpaceAggregationOptions(metricsUnknownSpaceAggregateOperatorOptions); break; @@ -235,11 +239,17 @@ export const useQueryOperations: UseQueryOperations = ({ } else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.GAUGE) { newQuery.aggregateOperator = 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 { newQuery.timeAggregation = ''; } - newQuery.spaceAggregation = ''; + if (newQuery.aggregateAttribute?.type !== ATTRIBUTE_TYPES.SUMMARY) { + newQuery.spaceAggregation = ''; + } // Handled query with unknown metric to avoid 400 and 500 errors // With metric value typed and not available then - time - 'avg', space - 'avg' @@ -285,6 +295,15 @@ export const useQueryOperations: UseQueryOperations = ({ spaceAggregation: '', }, ]; + } else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.SUMMARY) { + newQuery.aggregations = [ + { + timeAggregation: MetricAggregateOperator.MAX, + metricName: newQuery.aggregateAttribute?.key || '', + temporality: '', + spaceAggregation: MetricAggregateOperator.MAX, + }, + ]; } else { newQuery.aggregations = [ { diff --git a/frontend/src/lib/newQueryBuilder/getMetricsOperatorsByAttributeType.ts b/frontend/src/lib/newQueryBuilder/getMetricsOperatorsByAttributeType.ts index add80602a623..568fb1218308 100644 --- a/frontend/src/lib/newQueryBuilder/getMetricsOperatorsByAttributeType.ts +++ b/frontend/src/lib/newQueryBuilder/getMetricsOperatorsByAttributeType.ts @@ -29,6 +29,10 @@ export const getMetricsOperatorsByAttributeType = ({ if (aggregateAttributeType === ATTRIBUTE_TYPES.GAUGE) { return metricsOperatorsByType.Gauge; } + + if (aggregateAttributeType === ATTRIBUTE_TYPES.SUMMARY) { + return metricsOperatorsByType.Gauge; + } } if (dataSource === DataSource.METRICS && isEmpty(aggregateAttributeType)) {