Skip to content

[Synthetics] Use monitor query id for project monitors package policies !!#248762

Merged
shahzad31 merged 8 commits intoelastic:mainfrom
shahzad31:use-monitor-query-id-for-project-monitors
Jan 15, 2026
Merged

[Synthetics] Use monitor query id for project monitors package policies !!#248762
shahzad31 merged 8 commits intoelastic:mainfrom
shahzad31:use-monitor-query-id-for-project-monitors

Conversation

@shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Jan 12, 2026

Summary

In the Clean up package policies logic, Use monitor query id for project monitors package policies, since for project monitors package policy Id creation, id is used instead of config id of saved object.

This is causing synthetics clean up task to perform extra work and might cause it to timeout at 10m and cause unnecessary package policy clean up

@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Jan 12, 2026
@@ -57,7 +57,7 @@ export async function cleanUpDuplicatedPackagePolicies(
const policyId = privateLocationAPI.getPolicyId(
{
origin: monitor.attributes.origin,
id: monitor.id,
id: monitor.attributes.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

@benakansara @fkanout Context for why this change is needed

monitor.id is the ID of the monitor saved object. monitor.attributes.id is the id that is used when the monitor is ingested into the synthetics documents.

These values are often identical, but unfortunately diverge for project monitors. That is because instead of using the monitor saved object id as the ingested data's id, it uses a human readable id that is a combination of the monitor name, project id, and space id.

This code path actually wants the id used in the synthetics data, not the saved object id. We sometimes call it query id. There's a config key called ConfigKey.MONITOR_QUERY_ID that we sometimes use for it. The value of that enum is just id. So monitor.attributes[ConfigKey.MONITOR_QUERY_IDresolves just tomonitor.attributes.id`.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for this explanation, @dominiqueclarke, very helpful. Not necessarily an issue for right now but it concerns me that this requires this much explanation to understand ... it would be good to write down some ideas in an issue for the future, about how to simplify this for the sake of reducing these kinds of bug surfaces that I imagine come from people not really understanding the difference between these? (As always, I may misunderstand the root problem here.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree @jasonrhodes it's not an architectural decision I'm proud of, and it's hard to back out of.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jasonrhodes scheduled a meeting to discuss and find ways to back out of this nonsense.

@shahzad31 shahzad31 marked this pull request as ready for review January 14, 2026 15:52
@shahzad31 shahzad31 requested a review from a team as a code owner January 14, 2026 15:52
@shahzad31 shahzad31 added release_note:fix backport:version Backport to applied version labels labels Jan 14, 2026
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 14, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #86 / dashboard app - group 6 dashboard snapshots compare controls snapshot in dark mode
  • [job] [logs] FTR Configs #86 / dashboard app - group 6 dashboard snapshots compare controls snapshot in dark mode
  • [job] [logs] Scout: [ observability / observability ] plugin / should display dashboard options in related dashboards dropdown when editing rule
  • [job] [logs] Scout: [ observability / observability ] plugin / stateful - Rule Details Page - Admin - should display dashboard options in related dashboards dropdown when editing rule

Metrics [docs]

✅ unchanged

History

@dominiqueclarke dominiqueclarke self-requested a review January 14, 2026 20:36
@dominiqueclarke
Copy link
Contributor

dominiqueclarke commented Jan 15, 2026

Tested this with a full migration from 8.19.0 to 8.19.8 (with the change applied). I couldn't test on main/the PR because of saved object migrations on the unreleased development branch.

Before you can see that 12500 policies (all from my test project monitors) are being recreated because they were all deleted.

[2026-01-14T15:16:39.926-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] Syncing private location monitors because cleanup performed a change
[2026-01-14T15:16:42.356-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] Processing spaceId: default, monitors count: 2500
[2026-01-14T15:16:42.357-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] Syncing private configs for spaceId: default, privateConfigs count: 2500
[2026-01-14T15:16:45.108-05:00][DEBUG][plugins.synthetics] [editingMonitors] Creating 12500 policies, updating 0 policies, and deleting 0 policies
[2026-01-14T23:32:51.522-05:00][ERROR][plugins.synthetics] Sync of private location monitors failed: Response aborted while reading the body

After

[2026-01-15T00:09:14.417-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] Syncing private location monitors, current task state is {"lastStartedAt":"2026-01-15T04:59:46.726Z","lastTotalParams":0,"lastTotalMWs":0}
[2026-01-15T00:09:14.418-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] Starting cleanup of duplicated package policies
[2026-01-15T00:09:18.689-05:00][DEBUG][plugins.synthetics] Installed synthetics index templates
[2026-01-15T00:09:18.949-05:00][DEBUG][plugins.synthetics] Found 0 params updated and 0 total params
[2026-01-15T00:09:18.951-05:00][DEBUG][plugins.synthetics] Found 0 maintenance windows updated and 0 total maintenance windows
[2026-01-15T00:09:18.951-05:00][DEBUG][plugins.synthetics] [SyncPrivateLocationMonitorsTask] No data has changed since last run 2026-01-15T04:59:46.726Z, skipping sync of private location monitors

All policies retained
Screenshot 2026-01-15 at 12 11 43 AM

Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

LGTM

@shahzad31 shahzad31 merged commit 02eb244 into elastic:main Jan 15, 2026
21 checks passed
@shahzad31 shahzad31 deleted the use-monitor-query-id-for-project-monitors branch January 15, 2026 09:46
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.2, 9.3

https://github.com/elastic/kibana/actions/runs/21026800682

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 15, 2026
…es !! (elastic#248762)

## Summary

In the Clean up package policies logic, Use monitor query id for project
monitors package policies, since for project monitors package policy Id
creation, id is used instead of config id of saved object.

(cherry picked from commit 02eb244)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 15, 2026
…es !! (elastic#248762)

## Summary

In the Clean up package policies logic, Use monitor query id for project
monitors package policies, since for project monitors package policy Id
creation, id is used instead of config id of saved object.

(cherry picked from commit 02eb244)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 15, 2026
…es !! (elastic#248762)

## Summary

In the Clean up package policies logic, Use monitor query id for project
monitors package policies, since for project monitors package policy Id
creation, id is used instead of config id of saved object.

(cherry picked from commit 02eb244)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.2
9.3

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 Jan 15, 2026
…policies !! (#248762) (#249159)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Synthetics] Use monitor query id for project monitors package
policies !! (#248762)](#248762)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-01-15T09:46:36Z","message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","v9.3.0","v9.4.0","author:actionable-obs","Team:obs-ux-management","v9.2.5","v8.19.11"],"title":"[Synthetics]
Use monitor query id for project monitors package policies
!!","number":248762,"url":"https://github.com/elastic/kibana/pull/248762","mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2","8.19"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248762","number":248762,"mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.11","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
kibanamachine added a commit that referenced this pull request Jan 15, 2026
… policies !! (#248762) (#249158)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Synthetics] Use monitor query id for project monitors package
policies !! (#248762)](#248762)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-01-15T09:46:36Z","message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","v9.3.0","v9.4.0","author:actionable-obs","Team:obs-ux-management","v9.2.5","v8.19.11"],"title":"[Synthetics]
Use monitor query id for project monitors package policies
!!","number":248762,"url":"https://github.com/elastic/kibana/pull/248762","mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2","8.19"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248762","number":248762,"mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.11","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
kibanamachine added a commit that referenced this pull request Jan 15, 2026
…policies !! (#248762) (#249160)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Synthetics] Use monitor query id for project monitors package
policies !! (#248762)](#248762)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2026-01-15T09:46:36Z","message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","v9.3.0","v9.4.0","author:actionable-obs","Team:obs-ux-management","v9.2.5","v8.19.11"],"title":"[Synthetics]
Use monitor query id for project monitors package policies
!!","number":248762,"url":"https://github.com/elastic/kibana/pull/248762","mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2","8.19"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248762","number":248762,"mergeCommit":{"message":"[Synthetics]
Use monitor query id for project monitors package policies !!
(#248762)\n\n## Summary\n\nIn the Clean up package policies logic, Use
monitor query id for project\nmonitors package policies, since for
project monitors package policy Id\ncreation, id is used instead of
config id of saved
object.","sha":"02eb24406d130f5d877ed0beea987ebf05e4c40b"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.11","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
Co-authored-by: Dominique Clarke <dominique.clarke@elastic.co>
@shahzad31 shahzad31 added the bug Fixes for quality problems that affect the customer experience label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:fix Team:obs-ux-management v8.19.11 v9.2.5 v9.3.0 v9.4.0

5 participants