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

[8.x] [Response Ops][Event Log] Updating event log mappings if data stream and index template already exist (#193205) #193589

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

…and index template already exist (elastic#193205)

Resolves elastic#192682

## Summary

As of 8.8, we started writing all event log documents to the
`.kibana-event-log-ds` index. Prior to this, we created a new index
template and data stream for every version (`.kibana-event-log-8.7` for
example) so any mapping updates that were added for the version were
created in the new index on upgrade.

With the static index name and serverless, we need a way to update
mappings in existing indices. This PR uses the same mechanism that we
use for the alerts index to update the index template mappings and the
mappings for the concrete backing indices of a datastream.

## To Verify

Run ES and Kibana in `main` to test the upgrade path for serverless
a. Check out `main`, run ES: `yarn es snapshot --license trial --ssl -E
path.data=../test_el_upgrade` and Kibana `yarn start --ssl`
  b. Create a rule and let it run to populate the event log index
c. Switch to this PR branch. Make a mapping update to the event log
index:

```
--- a/x-pack/plugins/event_log/generated/mappings.json
+++ b/x-pack/plugins/event_log/generated/mappings.json
@@ -172,6 +172,9 @@
         },
         "rule": {
             "properties": {
+                "test": {
+                  "type": "keyword"
+                },
                 "author": {
                     "ignore_above": 1024,
                     "type": "keyword",
```
  d. Start ES and Kibana with the same commands as above
e. Verify that the `.kibana-event-log-ds` index is created and has the
updated mapping:
-
https://localhost:5601/app/management/data/index_management/templates/.kibana-event-log-template
-
https://localhost:5601/app/management/data/index_management/indices/index_details?indexName=.ds-.kibana-event-log-ds-2024.09.17-000001&filter=.kibana-&includeHiddenIndices=true&tab=mappings

I also verified the following:
1. Run ES and Kibana in 8.7 to test the upgrade path from 8.7 (when
event log indices were versioned) to now
2. Run ES and Kibana in 8.15 to test the upgrade path from the previous
release to now

However, I had to create an 8.x branch and cherry pick this commit
because `main` is now on 9.0 and we can't upgrade directly from older
8.x version to 9.0!

---------

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit e2798de)
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
eventLog 112 116 +4
Unknown metric groups

API count

id before after diff
eventLog 112 116 +4

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @ymao1

@kibanamachine kibanamachine merged commit 2933ad6 into elastic:8.x Sep 20, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants