Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions frontend/src/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const metricsSpaceAggregationOperatorsByType = {
Gauge: metricsGaugeSpaceAggregateOperatorOptions,
Histogram: metricsHistogramSpaceAggregateOperatorOptions,
ExponentialHistogram: metricsHistogramSpaceAggregateOperatorOptions,
Summary: metricsGaugeSpaceAggregateOperatorOptions,
};

export const mapOfQueryFilters: Record<DataSource, QueryAdditionalFilter[]> = {
Expand Down Expand Up @@ -372,6 +373,7 @@ export enum ATTRIBUTE_TYPES {
GAUGE = 'Gauge',
HISTOGRAM = 'Histogram',
EXPONENTIAL_HISTOGRAM = 'ExponentialHistogram',
SUMMARY = 'Summary',
}

export type IQueryBuilderState = 'search';
Expand Down
21 changes: 20 additions & 1 deletion frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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 = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading