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

[ML] Automatically migrate saved objects created by data recognizer #29736

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -385,7 +385,11 @@ export class DataRecognizer {
let results = { saved_objects: [] };
const filteredSavedObjects = objectExistResults.filter(o => o.exists === false).map(o => o.savedObject);
if (filteredSavedObjects.length) {
results = await this.savedObjectsClient.bulkCreate(filteredSavedObjects);
results = await this.savedObjectsClient.bulkCreate(
// Add an empty migrationVersion attribute to each saved object to ensure
// it is automatically migrated to the 7.0+ format with a references attribute.
filteredSavedObjects.map(doc => ({ ...doc, migrationVersion: doc.migrationVersion || { } }))
);
}
return results.saved_objects;
}
Expand Down
Expand Up @@ -7,7 +7,6 @@
"panelsJSON": "[{\"size_x\":6,\"size_y\":3,\"panelIndex\":1,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Remote-IP-Timechart\",\"col\":1,\"row\":1},{\"size_x\":6,\"size_y\":3,\"panelIndex\":2,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Response-Code-Timechart\",\"col\":7,\"row\":1},{\"size_x\":6,\"size_y\":3,\"panelIndex\":3,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Top-Remote-IPs-Table\",\"col\":1,\"row\":4},{\"size_x\":6,\"size_y\":3,\"panelIndex\":4,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Map\",\"col\":7,\"row\":4},{\"size_x\":12,\"size_y\":9,\"panelIndex\":5,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Top-URLs-Table\",\"col\":1,\"row\":7}]",
"optionsJSON": "{}",
"version": 1,
"migrationVersion": {},
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}],\"highlightAll\":true,\"version\":true}"
}
Expand Down
Expand Up @@ -7,7 +7,6 @@
"panelsJSON": "[{\"col\":1,\"id\":\"ML-Apache2-Access-Unique-Count-URL-Timechart\",\"panelIndex\":1,\"row\":1,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":7,\"id\":\"ML-Apache2-Access-Response-Code-Timechart\",\"panelIndex\":2,\"row\":1,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":1,\"id\":\"ML-Apache2-Access-Top-Remote-IPs-Table\",\"panelIndex\":3,\"row\":4,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"col\":7,\"id\":\"ML-Apache2-Access-Map\",\"panelIndex\":4,\"row\":4,\"size_x\":6,\"size_y\":3,\"type\":\"visualization\"},{\"size_x\":12,\"size_y\":8,\"panelIndex\":5,\"type\":\"visualization\",\"id\":\"ML-Apache2-Access-Top-URLs-Table\",\"col\":1,\"row\":7}]",
"optionsJSON": "{}",
"version": 1,
"migrationVersion": {},
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}],\"highlightAll\":true,\"version\":true}"
}
Expand Down
Expand Up @@ -7,7 +7,6 @@
"description": "Filebeat Apache2 Access Data",
"title": "ML Apache2 Access Data",
"version": 1,
"migrationVersion": {},
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"INDEX_PATTERN_ID\",\"query\":{\"query_string\":{\"query\":\"_exists_:apache2.access\",\"analyze_wildcard\":true}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"
},
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Map",
"uiStateJSON": "{\n \"mapCenter\": [\n 12.039320557540572,\n -0.17578125\n ]\n}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[]}"
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Remote IP Timechart",
"uiStateJSON": "{\"vis\":{\"legendOpen\":false}}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{}"
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Response Code Timechart",
"uiStateJSON": "{\n \"vis\": {\n \"colors\": {\n \"200\": \"#7EB26D\",\n \"404\": \"#614D93\"\n }\n }\n}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[]}"
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Top Remote IPs Table",
"uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{}"
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Top URLs Table",
"uiStateJSON": "{\"vis\":{\"params\":{\"sort\":{\"columnIndex\":null,\"direction\":null}}}}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{}"
Expand Down
Expand Up @@ -4,7 +4,6 @@
"title": "ML Apache2 Access Unique Count URL Timechart",
"uiStateJSON": "{}",
"version": 1,
"migrationVersion": {},
"savedSearchId": "ML-Filebeat-Apache2-Access",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{}"
Expand Down