Add collector health status - #26840
Open
thll wants to merge 29 commits into
Open
Conversation
Covers the OpAMP ComponentHealth proto mapping in OpAmpService (recursion, proto3-default and blank-string normalization, capability gating) and the health snapshot + healthy_changed_at semantics in CollectorInstanceService.updateFromReport (first report, identical re-send, root flip, no-flip content change, absent health, recursive round trip, stored document shape). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The backend now serves collector health on instance responses. Map it into CollectorInstanceView so a later task can render it in the instance details drawer.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Polling the instance for a fresh drawer is a background refresh and must follow the module's NO_SESSION_EXT convention; the one-shot form keeps extending the session as before. Also pins the drawer's polling options and the hook's session opt-out with dedicated assertions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The error block now uses the feature's code-block chrome (per InstallCommand's CommandBlock) instead of a novel red-on-pre hybrid, with break-word wrapping so words stay intact. Offline de-emphasis relies on the muted default label instead of opacity dimming, which has no precedent in the product and was not theme-safe. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Offline time would silently inflate the "for <duration>" (healthy for an hour, then offline three days is not "Healthy for 3 days"); the Last Seen row conveys staleness for offline instances. A last_error carried by a malformed or stale healthy report is no longer rendered next to a green badge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Product-wide, machine text renders as a bare pre wearing the global theme styles (fill/border/text, theme-aware) with at most a whitespace tweak — e.g. ShowMessagePage's error rendering. The CommandBlock-style chrome was a one-off whose contentBackground fill vanished against the drawer and whose cards.border is barely visible in dark mode. Only the wrapping is customized: pre-wrap with word-break: normal, since Bootstrap's defaults (no wrap, or break-all) both read badly for long single-line errors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end collector health reporting: the server maps OpAMP ComponentHealth reports into a persisted health snapshot (including a server-clocked “healthy changed at” timestamp), exposes it via the collector instances REST API, and updates the web UI to display instance health with an optional suffix-less relative time (“for 12 days”).
Changes:
- Backend: extract and persist OpAMP component health trees, tracking
healthy_changed_at, and expose health viaCollectorInstanceResponse. - Frontend: extend
RelativeTime/relativeDifferenceto support suffix-less rendering and add a drawer “Health” section for collector instances. - Tests: add/extend unit tests across server and web to cover health mapping, persistence semantics, and UI rendering.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
graylog2-web-interface/src/util/DateTime.ts |
Adds withoutSuffix support to relative time formatting. |
graylog2-web-interface/src/components/common/RelativeTime.tsx |
Exposes withoutSuffix prop and forwards to relativeDifference. |
graylog2-web-interface/src/components/common/RelativeTime.test.tsx |
Tests suffix-less relative time output. |
graylog2-web-interface/src/components/collectors/types.ts |
Adds CollectorHealth / ComponentHealth types and wires health into CollectorInstanceView. |
graylog2-web-interface/src/components/collectors/overview/FirstOnboarding.test.tsx |
Updates instance fixture to include health: null. |
graylog2-web-interface/src/components/collectors/instances/InstanceHealthSection.tsx |
New UI section for displaying collector health, duration, and error text. |
graylog2-web-interface/src/components/collectors/instances/InstanceHealthSection.test.tsx |
Tests health section rendering for online/offline/unknown/healthy/unhealthy cases. |
graylog2-web-interface/src/components/collectors/instances/InstanceDetailDrawer.tsx |
Adds health section and polls fresh instance data while drawer is open. |
graylog2-web-interface/src/components/collectors/instances/InstanceDetailDrawer.test.tsx |
Mocks polling and validates fresh-vs-stale instance data behavior including health rendering. |
graylog2-web-interface/src/components/collectors/instances/InstanceActions.test.tsx |
Updates instance fixture to include health: null. |
graylog2-web-interface/src/components/collectors/instances/ColumnRenderers.test.tsx |
Updates instance fixture to include health: null. |
graylog2-web-interface/src/components/collectors/hooks/useInstanceQueries.ts |
Maps health into views; updates useInstance API to support polling/session-extension behavior and silent mode. |
graylog2-web-interface/src/components/collectors/hooks/useInstanceQueries.test.ts |
Tests polling session extension behavior and health mapping/normalization. |
graylog2-server/src/test/java/org/graylog/collectors/opamp/OpAmpServiceTransactionLogTruncationTest.java |
Updates DTO construction for new health field in minimal instance DTO. |
graylog2-server/src/test/java/org/graylog/collectors/opamp/OpAmpServiceHealthReportTest.java |
New tests verifying OpAMP health payload mapping into CollectorInstanceReport. |
graylog2-server/src/test/java/org/graylog/collectors/opamp/CollectorInstanceServiceTest.java |
Adds tests for persisting health snapshots and healthy_changed_at semantics. |
graylog2-server/src/main/java/org/graylog/collectors/rest/CollectorInstancesResource.java |
Includes health in instance REST responses. |
graylog2-server/src/main/java/org/graylog/collectors/rest/CollectorInstanceResponse.java |
Adds health field to the REST record. |
graylog2-server/src/main/java/org/graylog/collectors/opamp/OpAmpService.java |
Extracts OpAMP ComponentHealth (including recursion) into DTOs and attaches to reports. |
graylog2-server/src/main/java/org/graylog/collectors/db/ComponentHealthDTO.java |
New DTO representing recursive component health snapshots. |
graylog2-server/src/main/java/org/graylog/collectors/db/CollectorInstanceReport.java |
Extends instance reports to optionally carry health updates. |
graylog2-server/src/main/java/org/graylog/collectors/db/CollectorInstanceDTO.java |
Adds optional persisted health field to instance documents. |
graylog2-server/src/main/java/org/graylog/collectors/db/CollectorHealthDTO.java |
New envelope DTO (healthy_changed_at + component_health). |
graylog2-server/src/main/java/org/graylog/collectors/CollectorInstanceService.java |
Persists health snapshots and maintains healthy_changed_at across updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
IDE auto-format artifact from the projection refactor; no functional change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Returns a MongoJack codec for the given class without binding it to a collection.
Add a ComponentHealthExtractor that adheres to limits when extracting the health tree.
Use a MongoDB aggregation pipeline to update health and its transition timestamp together, and remove stale health when the agent stops reporting it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds server-side handling for
healthreports of collectors. Stores reported health in thecollector_instancescollection and exposes it through the REST API as well as on theDetailsdrawer of the collector instance.E.g. for a previously unhealthy, but currently offline collector:

For an unhealthy collector:

For a healthy collector:

Additionally to the reported health tree, remembers the last time that the root components
healthyattribute changed, so that information like "unhealthy since ..." can be relayed to the user.Currently we only show root component health information because that's what our collectors report. We store the complete health tree, though, so that we can add visualization for that in a follow-up.
Fixes #26800