Conversation
There was a problem hiding this comment.
Pull request overview
Adds a “Filter Rules” count column to the Streams Overview, including an expandable section to view configured destination filter rules per stream. This supports the enterprise issue requesting visibility into destination filter rule usage directly from the streams list.
Changes:
- Web UI: adds
destination_filterscolumn (count badge) and an expanded “Filter Rules” section + actions. - Web UI: introduces a batched React Query hook to fetch filter rule counts across streams.
- Server: adds an API endpoint and service method to compute per-stream destination filter rule counts (plus tests).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| graylog2-web-interface/src/routing/ApiRoutes.ts | Adds route for destination filter rule counts endpoint. |
| graylog2-web-interface/src/components/streams/hooks/useStreamOutputFilters.ts | Allows fetching filters without a destination type (for “all destinations” view). |
| graylog2-web-interface/src/components/streams/hooks/useStreamDestinationFilterRuleCount.ts | New batched hook to fetch per-stream filter rule counts. |
| graylog2-web-interface/src/components/streams/hooks/useStreamDestinationFilterRuleCount.test.ts | Verifies batching behavior for the new count hook. |
| graylog2-web-interface/src/components/streams/StreamsOverview/hooks/useTableComponents.tsx | Registers new expanded section and actions for destination filter rules. |
| graylog2-web-interface/src/components/streams/StreamsOverview/cells/DestinationFilterRulesCell.tsx | New table cell rendering the filter rule count badge + expand toggle. |
| graylog2-web-interface/src/components/streams/StreamsOverview/StreamsOverview.test.tsx | Extends StreamsOverview tests to cover the new filter rules expand/collapse behavior. |
| graylog2-web-interface/src/components/streams/StreamsOverview/ExpandedDestinationFilterRulesSection.tsx | New expanded section listing destination filter rules with pagination. |
| graylog2-web-interface/src/components/streams/StreamsOverview/ExpandedDestinationFilterRulesActions.tsx | Adds “Manage Filter Rules” link action for the expanded section. |
| graylog2-web-interface/src/components/streams/StreamsOverview/Constants.ts | Adds destination_filters attribute and updates column titles/order defaults. |
| graylog2-web-interface/src/components/streams/StreamsOverview/ColumnRenderers.tsx | Wires new column renderer for destination_filters. |
| graylog2-server/src/test/java/org/graylog2/streams/filters/StreamDestinationFilterServiceTest.java | Adds unit test for counting filter rules by stream IDs. |
| graylog2-server/src/main/java/org/graylog2/streams/filters/StreamDestinationFilterService.java | Adds countByStreamIds implementation. |
| graylog2-server/src/main/java/org/graylog2/rest/resources/streams/StreamResource.java | Adds /streams/destinations/filters/count endpoint for counts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| final Map<String, Long> countsByStreamId = new HashMap<>(); | ||
| collection.find(in(FIELD_STREAM_ID, streamIds)).forEach(dto -> { | ||
| if (permissionSelector.test(dto.id())) { | ||
| countsByStreamId.merge(dto.streamId(), 1L, Long::sum); | ||
| } | ||
| }); |
There was a problem hiding this comment.
countByStreamIds iterates collection.find(...) and deserializes full StreamDestinationFilterRuleDTO objects (including the potentially large rule payload) just to count items. This can become unnecessarily expensive on the Streams Overview when many streams/rules are present. Consider using a projection / lightweight result class (e.g., only _id + stream_id) for this query, or an aggregation that returns only the fields required for counting, to reduce DB transfer and decoding overhead.
Motivation and Context
fixes https://github.com/Graylog2/graylog-plugin-enterprise/issues/13217
/nocl
Screenshots (if appropriate):
Types of changes
Checklist: