Health panel backend#26462
Open
patrickmann wants to merge 12 commits into
Open
Conversation
Replace the mock health report with a react-query poll against GET /plugins/org.graylog.plugins.health/cluster, implementing the ?since/204 conditional-poll contract: echo generated_at verbatim, keep the last report on 204, and treat an unsolicited 204 (no ?since sent) as an error. Polling is gated on the existing ?health=on visibility toggle. useHealthModule/useHealthSummary now derive from the poll; the HealthModule test mocks the new hook with the existing mock report fixture. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The backend now assembles a fresh full report on every request, so the frontend polls plainly: no ?since=, no 204, no version token. Treat generated_at as a display-only timestamp. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…POC) - Migrate the panel/badge visibility gate from the ?health=on URL toggle to the clusterhealth:read permission (Decision 6); register the permission type. - Re-key the FE copy and mock from the old graylog.* ids to the backend's server.* ids so curated copy matches a live report. - Add the FE-owned unit-noun lookup and id->title overrides (CPU, IdP Sync, MongoDB) that follow from the backend shipping no copy map. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-health-panel' into poc/system-overview-health-panel
Contributor
There was a problem hiding this comment.
Pull request overview
Adds core server and web-interface support needed for the upcoming “Health panel” feature, including a new polled health report fetch on the frontend and MongoDB timeout/utility improvements on the backend.
Changes:
- Frontend: switch Health module visibility gating from URL param to
clusterhealth:readpermission; adduseHealthReportpolling hook and wire it into the module/summary UI. - Frontend: introduce title/unit overrides and align mock report IDs/tests with new backend-emitted IDs.
- Backend: add client-side operation timeout (CSOT) support and introduce MongoDB utility overloads to propagate “capacity unknown” vs “0% used”.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
graylog2-web-interface/src/components/navigation/HealthStatusBadge.tsx |
Removes URL-param based link behavior; badge links to System Overview directly. |
graylog2-web-interface/src/components/health/useHealthReport.ts |
New react-query polling hook for cluster health report endpoint. |
graylog2-web-interface/src/components/health/useHealthModuleVisible.ts |
Changes visibility gate to permission-based (clusterhealth:read). |
graylog2-web-interface/src/components/health/useHealthModule.ts |
Replaces static mock state with polled report data and adds title overrides. |
graylog2-web-interface/src/components/health/mockHealthReport.ts |
Updates mock IDs/titles to match new naming scheme. |
graylog2-web-interface/src/components/health/HealthModule.test.tsx |
Adjusts tests to mock useHealthReport and updated labels/IDs. |
graylog2-web-interface/src/components/health/HealthDetailsPane.tsx |
Applies title overrides and new “unit noun” logic to count summaries. |
graylog2-web-interface/src/components/health/healthCheckDefinitions.ts |
Renames definition keys; adds unit nouns and title overrides helpers. |
graylog2-web-interface/src/@types/graylog-web-plugin/index.d.ts |
Adds clusterhealth:read permission typing. |
graylog2-server/src/test/java/org/graylog2/cluster/nodes/mongodb/MongodbNodeUtilsTest.java |
New tests covering CSOT overload and capacity=0 behavior. |
graylog2-server/src/main/java/org/graylog2/database/MongoEntityCollection.java |
Implements withTimeout(Duration) on the MongoCollection wrapper. |
graylog2-server/src/main/java/org/graylog2/database/MongoCollection.java |
Adds withTimeout(Duration) to the MongoCollection abstraction. |
graylog2-server/src/main/java/org/graylog2/cluster/nodes/mongodb/ReplicaSetMongodbNodes.java |
Adds memberStates(Duration) for lightweight replica-set membership with CSOT. |
graylog2-server/src/main/java/org/graylog2/cluster/nodes/mongodb/MongodbNodeUtils.java |
Adds CSOT overloads and distinguishes “capacity unknown” via exception propagation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+22
to
+45
|
|
||
| import type { HealthReport } from './HealthReport.types'; | ||
| import useHealthModuleVisible from './useHealthModuleVisible'; | ||
|
|
||
| // Pinned literal path -- must match the backend resource (HealthReportResource @Path + HealthModule package). | ||
| const HEALTH_REPORT_URL = '/plugins/org.graylog.plugins.health/cluster'; | ||
| const HEALTH_REPORT_QUERY_KEY = ['health', 'cluster-report'] as const; | ||
| const POLL_INTERVAL_MS = 5000; | ||
|
|
||
| /** | ||
| * Poll for the cluster health report. | ||
| * | ||
| * The backend assembles a fresh full report on every request, so each poll returns a complete `200` | ||
| * body -- there is no conditional polling: no `?since=`, no `204`, no version token. `generated_at` is | ||
| * a display timestamp the backend stamps at assembly time; we render it but never echo it back. | ||
| */ | ||
| const fetchHealthReport = (): Promise<HealthReport> => fetch('GET', qualifyUrl(HEALTH_REPORT_URL)); | ||
|
|
||
| const useHealthReport = (): UseQueryResult<HealthReport> => { | ||
| // Only poll when the feature is enabled, so we don't hit the (license/permission-gated) endpoint for | ||
| // every user. Mirrors the visibility gate the consumers already apply before rendering. | ||
| const enabled = useHealthModuleVisible(); | ||
|
|
||
| return useQuery({ |
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.
/prd Graylog2/graylog-plugin-enterprise#14591
/nocl
Spec: https://github.com/Graylog2/specs/pull/2
Adding functionality required to support health panel checks. See linked enterprise PR for details.