Skip to content

Add collector health status - #26840

Open
thll wants to merge 29 commits into
masterfrom
add/collector-health-status
Open

Add collector health status#26840
thll wants to merge 29 commits into
masterfrom
add/collector-health-status

Conversation

@thll

@thll thll commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Adds server-side handling for health reports of collectors. Stores reported health in the collector_instances collection and exposes it through the REST API as well as on the Details drawer of the collector instance.

E.g. for a previously unhealthy, but currently offline collector:
image

For an unhealthy collector:
image

For a healthy collector:
image

Additionally to the reported health tree, remembers the last time that the root components healthy attribute 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

thll and others added 15 commits July 30, 2026 16:14
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via CollectorInstanceResponse.
  • Frontend: extend RelativeTime/relativeDifference to 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.

thll and others added 4 commits July 31, 2026 15:52
IDE auto-format artifact from the projection refactor; no functional change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@thll
thll marked this pull request as ready for review July 31, 2026 14:44
@thll
thll requested review from bernd and kroepke July 31, 2026 14:44
@thll thll added the collector label Jul 31, 2026
@bernd bernd self-assigned this Aug 5, 2026
bernd added 2 commits August 5, 2026 18:07
Returns a MongoJack codec for the given class without binding it to a
collection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose Collector health in the user interface

3 participants