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

rollover and delete custom result index candidates with conditions #1229

Conversation

jackiehanyang
Copy link
Collaborator

Description

rollover and delete custom result index candidates with conditions

This is a draft pr that includes a commit form kaituo. Will create this pr officially after kaituo's change is merged

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

kaituo and others added 4 commits June 6, 2024 16:44
Previously, we used configured custom result index names as the index name, creating the index only when a detector was created. This approach caused several problems for index management:

1. **Index State Management (ISM) Incompatibility**: ISM requires an alias for rolling over an index, but we only had the index name.
2. **Index Recognition Issue**: Even if we managed to roll over an index, AD could not recognize it because the index would not be recreated unless the detector was recreated.
3. **Result History and Top Anomaly Results**: The result history on the dashboard and top anomaly results were reading from a single index instead of an index pattern. Thus, after rolling over an index, the result history and top anomaly results would be lost.

This PR addresses these issues:

1. **Custom Result Index Creation**: We now create a custom result index with the name `<custom-name-history-{now/d}-1>` and use the alias `custom-name` to point to it.
2. **Index Recreation**: We recreate an index when failing to find a result index, updating the configured alias to point to the new index. This ensures continuity when an index is rolled over and new indices do not exist.
3. **Query Index Pattern**: The top anomaly result API now queries an index pattern instead of a single index. The result history on the dashboard follows the same approach. The dashboard code will be posted in a separate PR.

Additionally, this PR updates the custom result index mapping when the mapping is outdated, similar to existing logic on the default result index.

**Testing Done**:
* Successfully updated the mapping of the custom result index when the mapping is outdated.
* Verified that the frontend can still see old and new results after a rollover.
* Confirmed that the backend can still write to new indices after a rollover.
* Ensured all existing tests pass.

More tests will be added in the following PRs.

Signed-off-by: Kaituo Li <[email protected]>
Signed-off-by: Jackie Han <[email protected]>
Signed-off-by: Jackie Han <[email protected]>
@opensearch-trigger-bot opensearch-trigger-bot bot added infra Changes to infrastructure, testing, CI/CD, pipelines, etc. backport 2.x labels Jun 10, 2024
@jackiehanyang jackiehanyang marked this pull request as ready for review June 10, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x infra Changes to infrastructure, testing, CI/CD, pipelines, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants