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

View File

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