fix(dataInsight): preserve service filter when rebuilding terms aggregation#28716
Conversation
…gation Live system charts (assets_with_*_live, healthy_data_assets, total_data_assets_live, pipeline_status_live) returned data for other services because the terms aggregation on service.name.keyword was rebuilt to attach sub-aggregations, copying only field+size and dropping the .include/.exclude filters set from includeXAxisFiled. Hoist finalIncludeTerms/finalExcludeTerms to loop-body scope and reapply them in the sub-aggregation rebuild branch, in both the ElasticSearch and OpenSearch line chart aggregators. Adds regression tests that fail without the fix (include filter dropped -> empty). Fixes #28715 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🟡 Playwright Results — all passed (8 flaky)✅ 4272 passed · ❌ 0 failed · 🟡 8 flaky · ⏭️ 88 skipped
🟡 8 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
|
Failed to cherry-pick changes to the 1.13 branch. |
Code Review ✅ ApprovedRestores the missing service filter in Data Insight live chart aggregators by correctly reapplying include/exclude terms during the sub-aggregation rebuild. Verified with new test cases covering both ElasticSearch and OpenSearch implementations. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |



Summary
Fixes the bug where Data Insights live system charts return counts for the wrong service. When a chart is requested with a
serviceNamefilter (e.g. thechartDataStreamwebsocket on a service page), the data pushed back belongs to other services.Closes #28715
Fixes: #28531
Root cause
DataInsightSystemChartRepository.listChartDataapplies the service filter viaincludeXAxisFiled = serviceName.toLowerCase(), which the aggregators turn into a terms aggregation onservice.name.keywordwith.include(regexp(serviceName)).But every live chart's metric carries a
formula, so sub-aggregations are always populated. The aggregator then rebuilds the terms aggregation to attach those sub-aggregations, copying onlyfield+sizeand silently dropping.include/.exclude:So the query aggregates over all services (top-100 buckets), returning other services' data. Affects
assets_with_description_live,assets_with_pii_live,assets_with_tier_live,assets_with_owner_live,healthy_data_assets,total_data_assets_live,pipeline_status_live.Fix
Hoist
finalIncludeTerms/finalExcludeTermsto loop-body scope and reapply them when rebuilding the terms aggregation, in bothElasticSearchLineChartAggregatorandOpenSearchLineChartAggregator.Tests
Added
ElasticSearchLineChartAggregatorTestandOpenSearchLineChartAggregatorTest(4 cases each):total_data_assets_liveshape)The tests build the chart, serialize the resulting
SearchRequestto JSON, and assert the service filter is present on theservice.name.keywordterms aggregation. They fail without the fix (expected: <myservice> but was: <>).Verification
mvn spotless:applyis clean.🤖 Generated with Claude Code