[Fix] Synthetics monitor health false positives and infinite _health polling#270137
Merged
miguelmartin-elastic merged 2 commits intoMay 20, 2026
Conversation
…void false positives in project monitors
|
Pinging @elastic/actionable-obs-team (Team:actionable-obs) |
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
History
|
Contributor
|
Starting backport for target branches: 9.4 https://github.com/elastic/kibana/actions/runs/26173225448 |
Contributor
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
kibanamachine
added a commit
that referenced
this pull request
May 20, 2026
…ealth polling (#270137) (#270243) # Backport This will backport the following commits from `main` to `9.4`: - [[Fix] Synthetics monitor health false positives and infinite _health polling (#270137)](#270137) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Miguel Martín","email":"miguel.martin@elastic.co"},"sourceCommit":{"committedDate":"2026-05-20T15:39:44Z","message":"[Fix] Synthetics monitor health false positives and infinite _health polling (#270137)\n\n## Summary\n\nFixes #270125\n\n- **Server:** Use `MONITOR_QUERY_ID` (not the saved object UUID) when\nresolving Fleet package policy IDs in the monitor integration health\nAPI. Fixes false `missing_package_policy` for project-origin monitors on\nprivate locations.\n- **Client:** Stabilize monitor ID dependencies in\n`useMonitorIntegrationHealth` so inline `configIds` arrays (e.g. on\nmonitor overview) do not retrigger `_health` fetches on every render.\nFixes infinite polling to `/internal/synthetics/monitors/_health` when\nthe missing-integration banner is shown.\n\n## Test plan\n\n- [ ] Run unit tests:\n ```bash\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/server/services/monitor_integration_health_api.test.ts\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/hooks/use_monitor_integration_health.test.ts\n ```\n- [ ] **Health API fix:** use a project monitor on a private location\nand call `POST /internal/synthetics/monitors/_health` — expect `healthy`\nwhen the Fleet package policy exists.\n- [ ] **Health API regression:** use a UI-origin monitor on a private\nlocation — expect `healthy` (UI monitors use `MONITOR_QUERY_ID ===\nconfig_id`).\n- [ ] **Infinite polling fix:** open a project monitor overview that\nshows the missing-integration banner — confirm a single `_health`\nrequest (or one per refresh interval), not a continuous stream in the\nnetwork tab.","sha":"b92ccaecd5c1518ec7b7fe855f9857225bdb31b8","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:actionable-obs","backport:version","v9.4.0","author:actionable-obs","v9.5.0"],"title":"[Fix] Synthetics monitor health false positives and infinite _health polling","number":270137,"url":"https://github.com/elastic/kibana/pull/270137","mergeCommit":{"message":"[Fix] Synthetics monitor health false positives and infinite _health polling (#270137)\n\n## Summary\n\nFixes #270125\n\n- **Server:** Use `MONITOR_QUERY_ID` (not the saved object UUID) when\nresolving Fleet package policy IDs in the monitor integration health\nAPI. Fixes false `missing_package_policy` for project-origin monitors on\nprivate locations.\n- **Client:** Stabilize monitor ID dependencies in\n`useMonitorIntegrationHealth` so inline `configIds` arrays (e.g. on\nmonitor overview) do not retrigger `_health` fetches on every render.\nFixes infinite polling to `/internal/synthetics/monitors/_health` when\nthe missing-integration banner is shown.\n\n## Test plan\n\n- [ ] Run unit tests:\n ```bash\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/server/services/monitor_integration_health_api.test.ts\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/hooks/use_monitor_integration_health.test.ts\n ```\n- [ ] **Health API fix:** use a project monitor on a private location\nand call `POST /internal/synthetics/monitors/_health` — expect `healthy`\nwhen the Fleet package policy exists.\n- [ ] **Health API regression:** use a UI-origin monitor on a private\nlocation — expect `healthy` (UI monitors use `MONITOR_QUERY_ID ===\nconfig_id`).\n- [ ] **Infinite polling fix:** open a project monitor overview that\nshows the missing-integration banner — confirm a single `_health`\nrequest (or one per refresh interval), not a continuous stream in the\nnetwork tab.","sha":"b92ccaecd5c1518ec7b7fe855f9857225bdb31b8"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/270137","number":270137,"mergeCommit":{"message":"[Fix] Synthetics monitor health false positives and infinite _health polling (#270137)\n\n## Summary\n\nFixes #270125\n\n- **Server:** Use `MONITOR_QUERY_ID` (not the saved object UUID) when\nresolving Fleet package policy IDs in the monitor integration health\nAPI. Fixes false `missing_package_policy` for project-origin monitors on\nprivate locations.\n- **Client:** Stabilize monitor ID dependencies in\n`useMonitorIntegrationHealth` so inline `configIds` arrays (e.g. on\nmonitor overview) do not retrigger `_health` fetches on every render.\nFixes infinite polling to `/internal/synthetics/monitors/_health` when\nthe missing-integration banner is shown.\n\n## Test plan\n\n- [ ] Run unit tests:\n ```bash\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/server/services/monitor_integration_health_api.test.ts\nnode scripts/jest\nx-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/hooks/use_monitor_integration_health.test.ts\n ```\n- [ ] **Health API fix:** use a project monitor on a private location\nand call `POST /internal/synthetics/monitors/_health` — expect `healthy`\nwhen the Fleet package policy exists.\n- [ ] **Health API regression:** use a UI-origin monitor on a private\nlocation — expect `healthy` (UI monitors use `MONITOR_QUERY_ID ===\nconfig_id`).\n- [ ] **Infinite polling fix:** open a project monitor overview that\nshows the missing-integration banner — confirm a single `_health`\nrequest (or one per refresh interval), not a continuous stream in the\nnetwork tab.","sha":"b92ccaecd5c1518ec7b7fe855f9857225bdb31b8"}}]}] BACKPORT--> Co-authored-by: Miguel Martín <miguel.martin@elastic.co>
4 tasks
paulinashakirova
pushed a commit
to paulinashakirova/kibana
that referenced
this pull request
May 22, 2026
…polling (elastic#270137) ## Summary Fixes elastic#270125 - **Server:** Use `MONITOR_QUERY_ID` (not the saved object UUID) when resolving Fleet package policy IDs in the monitor integration health API. Fixes false `missing_package_policy` for project-origin monitors on private locations. - **Client:** Stabilize monitor ID dependencies in `useMonitorIntegrationHealth` so inline `configIds` arrays (e.g. on monitor overview) do not retrigger `_health` fetches on every render. Fixes infinite polling to `/internal/synthetics/monitors/_health` when the missing-integration banner is shown. ## Test plan - [ ] Run unit tests: ```bash node scripts/jest x-pack/solutions/observability/plugins/synthetics/server/services/monitor_integration_health_api.test.ts node scripts/jest x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/hooks/use_monitor_integration_health.test.ts ``` - [ ] **Health API fix:** use a project monitor on a private location and call `POST /internal/synthetics/monitors/_health` — expect `healthy` when the Fleet package policy exists. - [ ] **Health API regression:** use a UI-origin monitor on a private location — expect `healthy` (UI monitors use `MONITOR_QUERY_ID === config_id`). - [ ] **Infinite polling fix:** open a project monitor overview that shows the missing-integration banner — confirm a single `_health` request (or one per refresh interval), not a continuous stream in the network tab.
shahzad31
added a commit
that referenced
this pull request
May 22, 2026
#270540) ## Release note When using Kibana Spaces, the Synthetics monitor health endpoint could incorrectly report monitors as unhealthy — showing errors such as "missing location", "missing agent policy", or "missing package policy" — even when everything was properly configured. This happened because the health check was only looking for monitors, private locations, and Fleet policies in the current space, missing resources that existed in other spaces. These issues are now fixed: the health check correctly resolves monitors, private locations, package policies, and agent policies across all relevant spaces, giving an accurate health status regardless of how resources are distributed across your Kibana Spaces. ## Summary Closes #270477. `POST /internal/synthetics/monitors/_health` returned wrong results when monitors lived outside the request's space — `missing_package_policy` errors when called from the monitor's space, and 404s when called from `default`. Two independent space-scoping bugs: 1. **Package policy lookup ignored space.** `getExistingPackagePoliciesMap` called Fleet's `packagePolicyService.getByIDs` with `createInternalRepository()`, which is scoped to the default namespace. Package policies created for monitors in another space were therefore invisible. 2. **Monitor saved-object lookup was space-scoped.** `MonitorConfigRepository.get` used the request-scoped saved-objects client, restricted to the request's space. Calling `_health` from `default` for a monitor that lives elsewhere returned a 404. ## What changed - **`PackagePolicyService.getByIds`** — accepts a new optional `additionalSpaceIds`, so the wrapper's per-space scoped-client fan-out can broaden beyond `[spaceId, default]`. Existing callers keep their old behavior. - **`MonitorConfigRepository.getAcrossSpaces(id, namespaces, soClient?)`** — new method that resolves a monitor across an arbitrary list of spaces. Uses the multi-space type's per-object `namespaces` array in one bulkGet entry, plus one entry per namespace for the `namespaceType: 'single'` legacy type. Accepts an injected `soClient` so the health API can pass `createInternalRepository()` and bypass the request's space restriction. - **`MonitorIntegrationHealthApi`**: - Computes `allSpaces = { requestSpace, ...allSpacesWithMonitors }` once, up-front. - `fetchMonitors` calls `monitorConfigRepository.getAcrossSpaces` with the internal repository → fixes bug #2. - `getExistingPackagePoliciesMap` uses the `PackagePolicyService` wrapper with `additionalSpaceIds` → fixes bug #1. ## Test plan - [x] `node scripts/jest` on the three affected suites — **77/77 passing** (includes new cross-space coverage and a new `getAcrossSpaces` test block). - [x] `node scripts/type_check --project x-pack/solutions/observability/plugins/synthetics/tsconfig.json` — clean. - [x] `node scripts/eslint` on the changed files — clean. - [ ] Manual: create a monitor with a private location in a non-default space, then call `POST /internal/synthetics/monitors/_health` both from that space and from `default`. Verify each call reports the monitor accurately instead of `missing_package_policy` / 404. ## Related - #270137 — related health API fix (project monitor policy ID + infinite polling). Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Miguel Martín <miguel.martin@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
jcger
pushed a commit
that referenced
this pull request
May 26, 2026
…polling (#270137) ## Summary Fixes #270125 - **Server:** Use `MONITOR_QUERY_ID` (not the saved object UUID) when resolving Fleet package policy IDs in the monitor integration health API. Fixes false `missing_package_policy` for project-origin monitors on private locations. - **Client:** Stabilize monitor ID dependencies in `useMonitorIntegrationHealth` so inline `configIds` arrays (e.g. on monitor overview) do not retrigger `_health` fetches on every render. Fixes infinite polling to `/internal/synthetics/monitors/_health` when the missing-integration banner is shown. ## Test plan - [ ] Run unit tests: ```bash node scripts/jest x-pack/solutions/observability/plugins/synthetics/server/services/monitor_integration_health_api.test.ts node scripts/jest x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/common/hooks/use_monitor_integration_health.test.ts ``` - [ ] **Health API fix:** use a project monitor on a private location and call `POST /internal/synthetics/monitors/_health` — expect `healthy` when the Fleet package policy exists. - [ ] **Health API regression:** use a UI-origin monitor on a private location — expect `healthy` (UI monitors use `MONITOR_QUERY_ID === config_id`). - [ ] **Infinite polling fix:** open a project monitor overview that shows the missing-integration banner — confirm a single `_health` request (or one per refresh interval), not a continuous stream in the network tab.
jcger
pushed a commit
that referenced
this pull request
May 26, 2026
#270540) ## Release note When using Kibana Spaces, the Synthetics monitor health endpoint could incorrectly report monitors as unhealthy — showing errors such as "missing location", "missing agent policy", or "missing package policy" — even when everything was properly configured. This happened because the health check was only looking for monitors, private locations, and Fleet policies in the current space, missing resources that existed in other spaces. These issues are now fixed: the health check correctly resolves monitors, private locations, package policies, and agent policies across all relevant spaces, giving an accurate health status regardless of how resources are distributed across your Kibana Spaces. ## Summary Closes #270477. `POST /internal/synthetics/monitors/_health` returned wrong results when monitors lived outside the request's space — `missing_package_policy` errors when called from the monitor's space, and 404s when called from `default`. Two independent space-scoping bugs: 1. **Package policy lookup ignored space.** `getExistingPackagePoliciesMap` called Fleet's `packagePolicyService.getByIDs` with `createInternalRepository()`, which is scoped to the default namespace. Package policies created for monitors in another space were therefore invisible. 2. **Monitor saved-object lookup was space-scoped.** `MonitorConfigRepository.get` used the request-scoped saved-objects client, restricted to the request's space. Calling `_health` from `default` for a monitor that lives elsewhere returned a 404. ## What changed - **`PackagePolicyService.getByIds`** — accepts a new optional `additionalSpaceIds`, so the wrapper's per-space scoped-client fan-out can broaden beyond `[spaceId, default]`. Existing callers keep their old behavior. - **`MonitorConfigRepository.getAcrossSpaces(id, namespaces, soClient?)`** — new method that resolves a monitor across an arbitrary list of spaces. Uses the multi-space type's per-object `namespaces` array in one bulkGet entry, plus one entry per namespace for the `namespaceType: 'single'` legacy type. Accepts an injected `soClient` so the health API can pass `createInternalRepository()` and bypass the request's space restriction. - **`MonitorIntegrationHealthApi`**: - Computes `allSpaces = { requestSpace, ...allSpacesWithMonitors }` once, up-front. - `fetchMonitors` calls `monitorConfigRepository.getAcrossSpaces` with the internal repository → fixes bug #2. - `getExistingPackagePoliciesMap` uses the `PackagePolicyService` wrapper with `additionalSpaceIds` → fixes bug #1. ## Test plan - [x] `node scripts/jest` on the three affected suites — **77/77 passing** (includes new cross-space coverage and a new `getAcrossSpaces` test block). - [x] `node scripts/type_check --project x-pack/solutions/observability/plugins/synthetics/tsconfig.json` — clean. - [x] `node scripts/eslint` on the changed files — clean. - [ ] Manual: create a monitor with a private location in a non-default space, then call `POST /internal/synthetics/monitors/_health` both from that space and from `default`. Verify each call reports the monitor accurately instead of `missing_package_policy` / 404. ## Related - #270137 — related health API fix (project monitor policy ID + infinite polling). Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Miguel Martín <miguel.martin@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
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.
Release notes
Synthetics — Monitor integration health
• Fixed false “missing integration” on project monitors (private locations): Health checks now use the correct monitor identifier, so project monitors show as
healthy when the integration is installed.
• Fixed repeated health checks on monitor overview: The integration-health hook no longer re-fetches on every render when the missing-integration banner is shown.
Summary
Fixes #270125
MONITOR_QUERY_ID(not the saved object UUID) when resolving Fleet package policy IDs in the monitor integration health API. Fixes falsemissing_package_policyfor project-origin monitors on private locations.useMonitorIntegrationHealthso inlineconfigIdsarrays (e.g. on monitor overview) do not retrigger_healthfetches on every render. Fixes infinite polling to/internal/synthetics/monitors/_healthwhen the missing-integration banner is shown.Test plan
POST /internal/synthetics/monitors/_health— expecthealthywhen the Fleet package policy exists.healthy(UI monitors useMONITOR_QUERY_ID === config_id)._healthrequest (or one per refresh interval), not a continuous stream in the network tab.