diff --git a/runtime/queries/metricsview.go b/runtime/queries/metricsview.go index a762a891567..1820d3cf786 100644 --- a/runtime/queries/metricsview.go +++ b/runtime/queries/metricsview.go @@ -551,19 +551,25 @@ func convertFilterToExpression(filter *runtimev1.MetricsViewFilter) *runtimev1.E if len(filter.Include) > 0 { var includeExprs []*runtimev1.Expression for _, cond := range filter.Include { - domExpr := convertDimensionFilterToExpression(cond, false) - if domExpr != nil { - includeExprs = append(includeExprs, domExpr) + if len(cond.In) > 0 { + domExpr := convertDimensionFilterToExpression(cond, false) + if domExpr != nil { + includeExprs = append(includeExprs, domExpr) + } } } - exprs = append(exprs, expressionpb.Or(includeExprs)) + if len(includeExprs) > 0 { + exprs = append(exprs, expressionpb.Or(includeExprs)) + } } if len(filter.Exclude) > 0 { for _, cond := range filter.Exclude { - domExpr := convertDimensionFilterToExpression(cond, true) - if domExpr != nil { - exprs = append(exprs, domExpr) + if len(cond.In) > 0 { + domExpr := convertDimensionFilterToExpression(cond, true) + if domExpr != nil { + exprs = append(exprs, domExpr) + } } } } diff --git a/web-common/src/features/dashboards/rows-viewer/RowsViewerAccordion.svelte b/web-common/src/features/dashboards/rows-viewer/RowsViewerAccordion.svelte index fb58784bd05..b4b576a2af3 100644 --- a/web-common/src/features/dashboards/rows-viewer/RowsViewerAccordion.svelte +++ b/web-common/src/features/dashboards/rows-viewer/RowsViewerAccordion.svelte @@ -63,7 +63,10 @@ ], timeStart: $timeControlsStore.timeStart, timeEnd, - filter: $dashboardStore?.filters, + filter: { + exclude: $dashboardStore.filters.exclude?.filter((f) => f.in?.length), + include: $dashboardStore.filters.include?.filter((f) => f.in?.length), + }, }, { query: { diff --git a/web-common/src/features/dashboards/selectors.ts b/web-common/src/features/dashboards/selectors.ts index 78871ae1f08..c340949c6ad 100644 --- a/web-common/src/features/dashboards/selectors.ts +++ b/web-common/src/features/dashboards/selectors.ts @@ -119,14 +119,22 @@ export const getFiltersForOtherDimensions = ( const filter: V1MetricsViewFilter = { include: filters.include - ?.filter((dimensionValues) => dimensionName !== dimensionValues.name) + ?.filter((dimensionValues) => { + return ( + dimensionName !== dimensionValues.name && dimensionValues.in?.length + ); + }) .map((dimensionValues) => ({ name: dimensionValues.name, in: dimensionValues.in, })) ?? [], exclude: filters.exclude - ?.filter((dimensionValues) => dimensionName !== dimensionValues.name) + ?.filter((dimensionValues) => { + return ( + dimensionName !== dimensionValues.name && dimensionValues.in?.length + ); + }) .map((dimensionValues) => ({ name: dimensionValues.name, in: dimensionValues.in, diff --git a/web-common/src/features/dashboards/time-series/timeseries-data-store.ts b/web-common/src/features/dashboards/time-series/timeseries-data-store.ts index d65d45275ff..56ff07bfad5 100644 --- a/web-common/src/features/dashboards/time-series/timeseries-data-store.ts +++ b/web-common/src/features/dashboards/time-series/timeseries-data-store.ts @@ -50,7 +50,14 @@ function createMetricsViewTimeSeries( metricViewName, { measureNames: measures, - filter: dashboardStore?.filters, + filter: { + exclude: dashboardStore.filters.exclude?.filter( + (f) => f.in?.length + ), + include: dashboardStore.filters.include?.filter( + (f) => f.in?.length + ), + }, timeStart: isComparison ? timeControls.comparisonAdjustedStart : timeControls.adjustedStart, diff --git a/web-common/src/features/dashboards/time-series/totals-data-store.ts b/web-common/src/features/dashboards/time-series/totals-data-store.ts index 7cb4142bee2..a03c3a3a661 100644 --- a/web-common/src/features/dashboards/time-series/totals-data-store.ts +++ b/web-common/src/features/dashboards/time-series/totals-data-store.ts @@ -26,7 +26,12 @@ export function createTotalsForMeasure( metricsViewName, { measures: measures.map((measure) => ({ name: measure })), - filter: noFilter ? { include: [], exclude: [] } : dashboard?.filters, + filter: noFilter + ? { include: [], exclude: [] } + : { + exclude: dashboard.filters.exclude?.filter((f) => f.in?.length), + include: dashboard.filters.include?.filter((f) => f.in?.length), + }, timeStart: isComparison ? timeControls?.comparisonTimeStart : timeControls.timeStart,