Proper index-pattern ids

This commit is contained in:
havidarou 2017-12-26 12:50:18 -05:00 committed by Javier Castro
parent 6b9f21686a
commit daa917d500
2 changed files with 11 additions and 8 deletions

View File

@ -146,10 +146,11 @@ module.exports = (server, options) => {
const createIndexPattern = () => {
server.log([blueWazuh, 'initialize', 'info'], `Creating index pattern: ${index_pattern}`);
let patternId = 'index-pattern:' + index_pattern;
elasticRequest.callWithInternalUser('create', {
index: '.kibana',
type: 'doc',
id: 'index-pattern:f1175040-d5c5-11e7-8ef5-a5944cf52264',
id: patternId,
body: {
"type": 'index-pattern',
"index-pattern": {
@ -161,11 +162,11 @@ module.exports = (server, options) => {
.then((resp) => {
server.log([blueWazuh, 'initialize', 'info'], 'Created index pattern: ' + index_pattern);
// Import objects (dashboards and visualizations)
importObjects('f1175040-d5c5-11e7-8ef5-a5944cf52264');
importAppObjects('f1175040-d5c5-11e7-8ef5-a5944cf52264');
importObjects(index_pattern);
importAppObjects(index_pattern);
// Save Setup Info
saveConfiguration('f1175040-d5c5-11e7-8ef5-a5944cf52264');
saveConfiguration(index_pattern);
})
.catch((err) => {
server.log([blueWazuh, 'initialize', 'error'], 'Error creating index-pattern.');

View File

@ -194,10 +194,11 @@ module.exports = (server, options) => {
const configureKibana = () => {
server.log([blueWazuh, 'monitoring', 'info'], `Creating index pattern: ${index_pattern}`);
elasticRequest.callWithInternalUser('create', {
let patternId = 'index-pattern:' + index_pattern;
elasticRequest.callWithInternalUser('create', {
index: '.kibana',
type: 'doc',
id: 'index-pattern:f1185040-d5c5-11e7-8ef5-a5944cf52264',
id: patternId,
body: {
"type": 'index-pattern',
"index-pattern": {
@ -208,7 +209,7 @@ module.exports = (server, options) => {
})
.then((resp) => {
server.log([blueWazuh, 'monitoring', 'info'], 'Created index pattern: ' + index_pattern);
importAppObjects('f1185040-d5c5-11e7-8ef5-a5944cf52264');
importAppObjects(index_pattern);
})
.catch((error) => {
server.log([blueWazuh, 'monitoring', 'error'], 'Error creating index-pattern due to ' + error);
@ -275,10 +276,11 @@ module.exports = (server, options) => {
server.log([blueWazuh, 'monitoring', 'info'], 'Creating today index...');
saveStatus();
let patternId = 'index-pattern:' + index_pattern;
elasticRequest.callWithInternalUser('get', {
index: '.kibana',
type: 'doc',
id: 'index-pattern:f1185040-d5c5-11e7-8ef5-a5944cf52264'
id: patternId
})
.then((data) => {
server.log([blueWazuh, 'monitoring', 'info'], 'Skipping index-pattern creation. Already exists.');