Last active
September 20, 2017 17:23
-
-
Save megastef/a7fae73a7ca65def1950ac2eef947931 to your computer and use it in GitHub Desktop.
Convert Kibana Dashboard objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: node change-kibana-index.js 'objects_file.json' 'wazuh-alerts-*' TOKEN_wazuh_alerts | |
var fs = require('fs') | |
var kibanaObjects = JSON.parse(fs.readFileSync(process.argv[2])) | |
var newKibanaObjects = kibanaObjects.map(function (o) { | |
if (o._source && o._source.kibanaSavedObjectMeta && o._source.kibanaSavedObjectMeta.searchSourceJSON) { | |
var source = JSON.parse(o._source.kibanaSavedObjectMeta.searchSourceJSON) | |
if (source.index === process.argv[3]) { | |
source.index = process.argv[4] | |
} | |
o._source.kibanaSavedObjectMeta.searchSourceJSON = JSON.stringify (source) | |
return o | |
} | |
}) | |
console.log(JSON.stringify(newKibanaObjects, null, '\t')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for input data: https://raw.githubusercontent.com/wazuh/wazuh-kibana-app/bf237f0363ed76a51eac08a3a5582578ef0c2aa1/server/startup/integration_files/objects_file.json