-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ResponseOps] event log mapping from template not applied #127029
Comments
Pinging @elastic/response-ops (Team:ResponseOps) |
Looking at the first event log documents for that index, as I was wondering if some sort of specific event was managing to avoid the "ready" checks for the index resources (template, etc). Nope. The first two documents were first two event log docs[
{
"_index": ".kibana-event-log-7.16.3-000001",
"_type": "_doc",
"_score": null,
"_source": {
"@timestamp": "2022-01-31T10:27:40.965Z",
"event": {
"provider": "eventLog",
"action": "starting"
},
"message": "eventLog starting",
"ecs": {
"version": "1.8.0"
},
"kibana": {
"server_uuid": "7c1898ba-6cb1-444d-92b1-b45c7fff2668",
"version": "7.16.3"
}
}
},
{
"_index": ".kibana-event-log-7.16.3-000001",
"_type": "_doc",
"_score": null,
"_source": {
"@timestamp": "2022-01-31T10:27:41.002Z",
"event": {
"provider": "eventLog",
"action": "starting"
},
"message": "eventLog starting",
"ecs": {
"version": "1.8.0"
},
"kibana": {
"server_uuid": "410c0f34-0314-4c70-94d1-abdfce00c4ab",
"version": "7.16.3"
}
}
}
] About 6 seconds after those documents, So, no smoking gun yet. |
Quick tour of the processing going on here. The elasticsearch resources are created here: kibana/x-pack/plugins/event_log/server/es/init.ts Lines 28 to 36 in e3e5df6
The mappings are in the template, so the template should exist before we try to create the index. When we create the index, we use the "initial name", which has a suffix of kibana/x-pack/plugins/event_log/server/es/init.ts Lines 204 to 216 in e3e5df6
One problem we've seen in the past is if for some reason the initial index doesn't actually get created, the event log currently writes to the alias, and the alias doesn't exist, so ES auto-creates an index with the name of the alias, which is obviously a mess. But that didn't happen here. The alias did get created, and the event log indexed the documents in the right place, but for some reason, didn't apply the mappings, which should have been setup when the template was created, before this. Also keep in mind there are two Kibanas, starting at the same time, so there's a potential for a race condition. But we've not seen any race conditions with this code AFAIK. I'm wondering if there's some underlying ES-ish race condition, where one of the Kibanas might call My only thought on trying to lock this down more is to add an additional delay after the initialization code, to have it wait "a bit more". The other possibility is that the "ready" signal on the write end of the event log is being set too early, or perhaps not being checked for some reason. The code that checks/waits for initialization complete, before writing, is here: kibana/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts Lines 99 to 106 in e3e5df6
The kibana/x-pack/plugins/event_log/server/es/context.ts Lines 48 to 77 in e3e5df6
|
A bit more poking around the ES diagnostic bundle. Looking at the 7.16.3 event log settings {
"settings" : {
"index" : {
"creation_date_string" : "2022-01-31T10:27:49.225Z",
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"number_of_shards" : "1",
"auto_expand_replicas" : "false",
"blocks" : {
"read_only_allow_delete" : "false"
},
"provided_name" : ".kibana-event-log-7.16.3-000001",
"creation_date" : "1643624869225",
"number_of_replicas" : "0",
"uuid" : "jMdaqkJvSm6Ci9xbb36VBA",
"version" : {
"created_string" : "7.16.3",
"created" : "7160399"
}
}
}
} 7.16.2 event log settings {
"settings" : {
"index" : {
"lifecycle" : {
"name" : "kibana-event-log-policy",
"rollover_alias" : ".kibana-event-log-7.16.2",
"indexing_complete" : "true"
},
"creation_date_string" : "2022-01-12T00:02:48.113Z",
"routing" : {
"allocation" : {
"include" : {
"_tier_preference" : "data_content"
}
}
},
"hidden" : "true",
"number_of_shards" : "1",
"auto_expand_replicas" : "0-1",
"provided_name" : ".kibana-event-log-7.16.2-000001",
"creation_date" : "1641945768113",
"number_of_replicas" : "0",
"uuid" : "z2rJtrXWSzafIVkGUsLC_g",
"version" : {
"created_string" : "7.16.2",
"created" : "7160299"
}
}
}
} The difference is that 7.16.3 is missing the "lifecycle" : {
"name" : "kibana-event-log-policy",
"rollover_alias" : ".kibana-event-log-7.16.3",
"indexing_complete" : "true"
}, And the 7.16.3 settings have an extra "blocks" : {
"read_only_allow_delete" : "false"
}, Seems like that The lack of the lifecycle is significant, but that's in the template, so just more proof that the index got created without having the template applied to it. |
Did some searching to see if this was some kind of known thing, but this is the only relevant issue I could find: it's 4 years old from 6.8 - elastic/elasticsearch#30486 |
We also opened #128293 as a potential "solution" for cases where either there is some ES race condition or a human modified some event log resources manually. We closed it as "in favour of" this issue - but this issue doesn't actually contain any notes about that "solution". That "solution" is to create the initial index specifically with mappings, instead of depending on the mappings being in the template. We'd still have the mappings in the template, we'd just change to also create the first index with those same mappings. This only "solve" the problem for the initial index creation - if somehow the mappings got changed / removed from the template, further indices (created as part of the ILM process) would presumably pick up the mappings from the template (ILM creates those, not us), and could still be problematic. |
Kibana version: 7.16.3
Just saw a case where an event log index for 7.16.3
.kibana-event-log-7.16.3-000001
seems to have "auto" mappings set up, instead of using the mappings provided in the template.Looking in the es diagnostics package file
mappings.json
, you can see:But for a previous event log index, it looks like this:
I'm assuming the user didn't do this to themselves somehow, by doing some es-level surgery on the indices. Which I think then implies we have a race condition somewhere, where an event doc is written before the index resources are set up, so it uses the auto-mapping.
A quick look at the index template itself seemed to indicate it was fine. And the alias is set up ok - if there was a problem with that as well, you can have a situation where it would try to create an index with the name
.kibana-event-log-7.16.3
instead of using the alias, which causes other problems.The text was updated successfully, but these errors were encountered: