Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps][Alerting] Migrate to using Saved Object References array to reference index patterns from Rules #107066

Closed
ymao1 opened this issue Jul 28, 2021 · 1 comment · Fixed by #114559
Assignees
Labels
chore [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v7.16.0 v8.0.0

Comments

@ymao1
Copy link
Contributor

ymao1 commented Jul 28, 2021

Currently, geo containment rules stores two index pattern Saved Object IDs inside the rule params inside params.indexId and params.boundaryIndexId:

Example geo containment rule
{
	"alert": {
		"params": {
			"index": "tracks*",
			"indexId": "f3acd150-e8c6-11eb-bc58-13b6ae6d011a",
			"entity": "azimuth",
			"dateField": "@timestamp",
			"boundaryType": "entireIndex",
			"geoField": "location",
			"boundaryIndexTitle": "manhattan_boundaries",
			"boundaryIndexId": "a2e7a1f0-e8c6-11eb-bc58-13b6ae6d011a",
			"boundaryGeoField": "coordinates",
			"boundaryNameField": "<nothing selected>"
		},
		"consumer": "alerts",
		"schedule": {
			"interval": "1m"
		},
		"tags": [],
		"name": "map",
		"actions": [],
		"enabled": true,
		"throttle": null,
		"alertTypeId": ".geo-containment",
		"notifyWhen": "onActionGroupChange",
		"apiKeyOwner": "elastic",
		"apiKey": "HcRdCvA7pjzG170nbE5NJdtSPB2fQ/yKy3i+rOApxnjCw/G/7MaA5X1sSblceYMD5u7eoot3CKiFFOgKeiz3w9Glmvnk4scpGLAtHdQYn4lUtY5m5lYaO5Xzj+v8SIN/Ogqpx8/Tg+qLSVPRlpEWNrBh+sPnL0k0SofOfUkIurU4TRJQq4yDjZIf+DI6hgA1qOFd1aQckgnq0A==",
		"createdBy": "elastic",
		"updatedBy": "elastic",
		"createdAt": "2021-07-19T19:25:15.787Z",
		"updatedAt": "2021-07-19T19:25:15.787Z",
		"muteAll": false,
		"mutedInstanceIds": [],
		"executionStatus": {
			"status": "active",
			"lastExecutionDate": "2021-07-19T19:26:22.339Z",
			"error": null
		},
		"meta": {
			"versionApiKeyLastmodified": "8.0.0"
		},
		"scheduledTaskId": "0c1068b0-e8c7-11eb-bc58-13b6ae6d011a"
	},
	"type": "alert",
	"references": [],
	"namespace": "my-space",
	"migrationVersion": {
		"alert": "7.13.0"
	},
	"coreMigrationVersion": "8.0.0",
	"updated_at": "2021-07-19T19:26:22.631Z"
}

In 8.0, index-pattern saved objects will be converted to share-capable (meta issue). This means all index pattern SO IDs will be regenerated and the index pattern SO IDs stored within the geo containment rule params will be outdated.

What does this mean?

Rule Execution
It doesn't look like the SO IDs are actually directly used during geo containment rule execution so rule execution continues to run successfully even if the index pattern IDs are outdated.

Rules UI
Index pattern SO IDs are used to re-populate the UI field when editing the geo containment rule so because the index pattern SO IDs are outdated, the edit form will be cleared out for user who try to edit geo containment rules.

Recommended approach

With this resolution of this issue with this PR, the alerting framework allows rule types to specify extract and inject hooks for pulling out SO references from rule parameters. POC for adding it to the geo containment rule type is available here: https://github.com/elastic/kibana/pull/106733/files. While implementing these hooks will affect rules that are created/updated after implementation, a migration will also need to be added for the geo containment rule to update existing rules.

Alternative approach

Since the indexId and boundaryIndexId SO IDs are only used during rule editing, there is the option to use the client side .resolve function provided by the saved objects client in order to resolve the outdated index pattern SO ID.

When does this need to be done?

These changes should be completed by 7.16 FF as the saved object type conversions will be done in 8.0

@botelastic botelastic bot added the needs-team Issues missing a team label label Jul 28, 2021
@ymao1 ymao1 added [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation and removed needs-team Issues missing a team label labels Jul 28, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v7.16.0 v8.0.0
Projects
None yet
4 participants