Frontend for the pluggable entity metrics endpoint (Inputs page) - #26094
Conversation
9915b9f to
e75ca80
Compare
| ): Promise<InputMetricsResponse> => { | ||
| const query = Qs.stringify({ input_ids: inputIds, fields }, { indices: false }); | ||
|
|
||
| return fetch('GET', qualifyUrl(`/system/inputs/metrics?${query}`)); |
There was a problem hiding this comment.
Is there an API stub that we can use instead?
There was a problem hiding this comment.
We don't have the API stub yet because the backend is not ready for it.
| isInitialLoading: boolean; | ||
| isError: boolean; | ||
| } => { | ||
| const stableEntities = useMemo(() => [...entities].sort((a, b) => a.id.localeCompare(b.id)), [entities]); |
There was a problem hiding this comment.
With react compiler I think we might not need this.
| placeholderData: keepPreviousData, | ||
| }); | ||
|
|
||
| const titlesById = useMemo(() => { |
There was a problem hiding this comment.
With react compiler I think we might not need this.
| return result; | ||
| }, [data]); | ||
|
|
||
| const notPermittedIds = useMemo(() => new Set(data?.not_permitted_to_view ?? []), [data]); |
There was a problem hiding this comment.
With react compiler I think we might not need this.
| const stableIds = useMemo(() => sortedUnique(inputIds), [inputIds]); | ||
| const stableFields = useMemo(() => sortedUnique(fields), [fields]); |
There was a problem hiding this comment.
With react compiler I think we might not need useMemo
| }; | ||
|
|
||
| const [visibleInputIds, setVisibleInputIds] = useState<Array<string>>([]); | ||
| const onDataLoaded = useCallback((data: PaginatedResponse<Input>) => { |
There was a problem hiding this comment.
With React Compiler we might not need useCallback
| }, []); | ||
|
|
||
| const { data: layoutPreferences } = useUserLayoutPreferences(resolvedTableLayout.entityTableId); | ||
| const requestedFields = useMemo(() => { |
There was a problem hiding this comment.
With React Compiler we might not need useMemo
| const streamIds = useMemo(() => (messagesPerStream ? Object.keys(messagesPerStream) : []), [messagesPerStream]); | ||
| const titleEntities = useMemo(() => streamIds.map((id) => ({ id, type: 'streams' })), [streamIds]); |
There was a problem hiding this comment.
Same here: useMemo should not be needed?
|
|
||
| import ExtractorsSection from './ExtractorsSection'; | ||
|
|
||
| jest.mock('logic/rest/FetchProvider', () => { |
There was a problem hiding this comment.
If we are using api stubs to fetch this data, we could simply mock the function for that stub. I think mocking the whole fetch provider is not ideal.
| const streamIds = useMemo(() => (messagesPerStream ? Object.keys(messagesPerStream) : []), [messagesPerStream]); | ||
| const titleEntities = useMemo(() => streamIds.map((id) => ({ id, type: 'streams' })), [streamIds]); |
There was a problem hiding this comment.
Again, do we need useMemo?
) * Add useEntityTitles hook for bulk id -> title resolution * Add useInputMetrics hook and per-page metrics context for Inputs * Add Message Count, Extractors, Associated Streams columns to Inputs * adjust extractors permissions * fix review --------- Co-authored-by: Laura Bergenthal-Grotlüschen <197286649+laura-b-g@users.noreply.github.com>

Wires the new
GET /system/inputs/metricsendpoint into the Inputs overview as three opt-in, hidden-by-default columns. No metrics request fires unless the user enables one of them via the column picker.New columns
messages_per_stream(sum of values)POST /system/catalog/entities/titles, deleted streams shown as<id> (deleted)extractor_countGET /system/inputs/{inputId}/extractors; "Manage extractors" lives in the section's actions slotmessages_per_streamkeysEach cell renders as a
CountBadgewith a chevron that flips when the matching section is open. While metrics are loading the cell shows a spinner; on error or missing data it falls back to—— the table itself never blocks on the metrics fetch (two-phase render).Scope
Inputs page only. Streams, Forwarder Inputs, and Event Definitions columns from the broader project PRD are out of scope for this PR and will land with their own backend endpoints.
/nocl
associated to #25997
part of #25928
Types of changes
Checklist: