wazuh-kibana-app/server/initialize.js

750 lines
21 KiB
JavaScript
Raw Normal View History

/*
* Wazuh app - Module for app initialization
2019-01-14 16:36:47 +00:00
* Copyright (C) 2015-2019 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/
2018-09-10 08:32:49 +00:00
import needle from 'needle';
import colors from 'ansicolors';
import { log } from './logger';
import { ElasticWrapper } from './lib/elastic-wrapper';
import packageJSON from '../package.json';
2018-09-11 09:52:54 +00:00
import { kibanaTemplate } from './integration-files/kibana-template';
2018-09-10 08:32:49 +00:00
import { getConfiguration } from './lib/get-configuration';
import { defaultExt } from './lib/default-ext';
2018-09-10 08:32:49 +00:00
import { BuildBody } from './lib/replicas-shards-helper';
2019-01-03 10:37:06 +00:00
import { checkKnownFields } from './lib/refresh-known-fields';
2018-09-03 09:46:55 +00:00
export function Initialize(server) {
2018-09-10 08:32:49 +00:00
const blueWazuh = colors.blue('wazuh');
// Elastic JS Client
const wzWrapper = new ElasticWrapper(server);
2019-04-15 10:47:45 +00:00
log('initialize', `Kibana index: ${wzWrapper.WZ_KIBANA_INDEX}`, 'info');
log('initialize', `App revision: ${packageJSON.revision}`, 'info');
2018-09-10 08:32:49 +00:00
let configurationFile = {};
let pattern = null;
// Read config from package.json and config.yml
try {
configurationFile = getConfiguration();
pattern =
configurationFile && typeof configurationFile.pattern !== 'undefined'
? configurationFile.pattern
: 'wazuh-alerts-3.x-*';
global.XPACK_RBAC_ENABLED =
configurationFile &&
typeof configurationFile['xpack.rbac.enabled'] !== 'undefined'
? configurationFile['xpack.rbac.enabled']
: true;
} catch (e) {
2019-04-15 10:47:45 +00:00
log('initialize', e.message || e);
2018-09-10 08:32:49 +00:00
server.log(
[blueWazuh, 'initialize', 'error'],
'Something went wrong while reading the configuration.' + e.message
);
}
const defaultIndexPattern = pattern || 'wazuh-alerts-3.x-*';
// Save Wazuh App setup
const saveConfiguration = async () => {
try {
const shardConfiguration = BuildBody(configurationFile, 'wazuh-version');
2018-09-10 08:32:49 +00:00
await wzWrapper.createWazuhVersionIndex(shardConfiguration);
const commonDate = new Date().toISOString();
const configuration = {
name: 'Wazuh App',
'app-version': packageJSON.version,
revision: packageJSON.revision,
installationDate: commonDate,
lastRestart: commonDate
};
try {
await wzWrapper.insertWazuhVersionConfiguration(configuration);
log(
2019-04-15 10:47:45 +00:00
'initialize:saveConfiguration',
2018-09-10 08:32:49 +00:00
'Wazuh configuration inserted',
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:saveConfiguration', error.message || error);
2018-09-10 08:32:49 +00:00
server.log(
[blueWazuh, 'initialize', 'error'],
'Could not insert Wazuh configuration'
);
}
return;
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:saveConfiguration', error.message || error);
2018-09-10 08:32:49 +00:00
server.log(
[blueWazuh, 'initialize', 'error'],
'Error creating index .wazuh-version.'
);
}
};
/**
* Checks for new extensions added to the config.yml,
* useful whenever a new extension is added and it's enabled by default.
* An old app package needs to update its stored API entries, this way we have consistency
* with the new extensions.
*/
const checkAPIEntriesExtensions = async () => {
try {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkAPIEntriesExtensions',
`Checking extensions consistency for all API entries`,
2019-04-15 10:47:45 +00:00
'debug'
);
const apiEntries = await wzWrapper.getWazuhAPIEntries();
const configFile = await getConfiguration();
2018-12-18 15:19:05 +00:00
if (((apiEntries || {}).hits || {}).total > 0) {
const currentExtensions = !configFile ? defaultExt : {};
if (configFile) {
for (const key in defaultExt) {
currentExtensions[key] =
typeof configFile['extensions.' + key] !== 'undefined'
? configFile['extensions.' + key]
: defaultExt[key];
}
}
for (const item of apiEntries.hits.hits) {
for (const key in currentExtensions) {
2018-12-19 11:04:57 +00:00
if ((((item || {})._source || {}).extensions || {})[key]) {
continue;
} else {
2018-12-19 11:04:57 +00:00
if (((item || {})._source || {}).extensions) {
item._source.extensions[key] = currentExtensions[key];
}
}
}
try {
await wzWrapper.updateWazuhIndexDocument(null, item._id, {
doc: { extensions: item._source.extensions }
});
log(
2019-04-15 10:47:45 +00:00
'initialize:checkAPIEntriesExtensions',
`Successfully updated API entry extensions with ID: ${item._id}`,
2019-04-15 10:47:45 +00:00
'debug'
);
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkAPIEntriesExtensions',
`Error updating API entry extensions with ID: ${
item._id
} due to ${error.message || error}`
);
server.log(
2019-04-15 10:47:45 +00:00
[blueWazuh, 'initialize:checkAPIEntriesExtensions', 'error'],
`Error updating API entry extensions with ID: ${
item._id
} due to ${error.message || error}`
);
}
}
} else {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkAPIEntriesExtensions',
'There are no API entries, skipping extensions check',
2019-04-15 10:47:45 +00:00
'debug'
);
}
return;
} catch (error) {
return Promise.reject(error);
}
};
2018-09-10 08:32:49 +00:00
const checkWazuhIndex = async () => {
try {
2019-04-15 10:47:45 +00:00
log('initialize:checkWazuhIndex', 'Checking .wazuh index.', 'debug');
2018-09-10 08:32:49 +00:00
const result = await wzWrapper.checkIfIndexExists('.wazuh');
const shardConfiguration = BuildBody(configurationFile, 'wazuh');
2018-09-10 08:32:49 +00:00
if (!result) {
try {
2018-09-10 08:32:49 +00:00
await wzWrapper.createWazuhIndex(shardConfiguration);
2019-04-15 10:47:45 +00:00
log('initialize:checkWazuhIndex', 'Index .wazuh created.', 'debug');
} catch (error) {
2018-09-10 08:32:49 +00:00
throw new Error('Error creating index .wazuh.');
}
2018-09-10 08:32:49 +00:00
} else {
await wzWrapper.updateIndexSettings('.wazuh', shardConfiguration);
await checkAPIEntriesExtensions();
2018-09-10 08:32:49 +00:00
// The .wazuh index exists, we now proceed to check whether it's from an older version
try {
2018-09-10 08:32:49 +00:00
await wzWrapper.getOldWazuhSetup();
2017-10-27 09:07:38 +00:00
2018-09-10 08:32:49 +00:00
// Reindex!
return reindexOldVersion();
2018-03-12 11:57:14 +00:00
} catch (error) {
2018-09-10 08:32:49 +00:00
if (error.message && error.message !== 'Not Found') {
throw new Error(error.message || error);
}
}
2018-09-10 08:32:49 +00:00
}
} catch (error) {
return Promise.reject(error);
}
};
2018-09-10 08:32:49 +00:00
const checkWazuhVersionIndex = async () => {
try {
log(
2019-04-15 10:47:45 +00:00
'initialize[checkWazuhVersionIndex]',
2018-09-10 08:32:49 +00:00
'Checking .wazuh-version index.',
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
try {
await wzWrapper.getWazuhVersionIndex();
const shardConfiguration = BuildBody(
configurationFile,
'wazuh-version'
2018-09-10 08:32:49 +00:00
);
await wzWrapper.updateIndexSettings(
'.wazuh-version',
shardConfiguration
);
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize[checkWazuhVersionIndex]',
2018-09-10 08:32:49 +00:00
'.wazuh-version document does not exist. Initializating configuration...',
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
// Save Setup Info
await saveConfiguration(defaultIndexPattern);
}
await wzWrapper.updateWazuhVersionIndexLastRestart(
packageJSON.version,
packageJSON.revision
);
} catch (error) {
return Promise.reject(error);
}
};
2017-12-14 12:24:51 +00:00
2018-09-10 08:32:49 +00:00
// Init function. Check for "wazuh-version" document existance.
const init = async () => {
try {
await Promise.all([
checkWazuhIndex(),
checkWazuhVersionIndex(),
2019-01-03 10:37:06 +00:00
checkKnownFields(wzWrapper, log, server, defaultIndexPattern)
2018-09-10 08:32:49 +00:00
]);
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:init', error.message || error);
2018-09-10 08:32:49 +00:00
server.log(
2019-04-15 10:47:45 +00:00
[blueWazuh, 'initialize:init', 'error'],
2018-09-10 08:32:49 +00:00
error.message || error
);
return Promise.reject(error);
}
};
const createKibanaTemplate = () => {
log(
2019-04-15 10:47:45 +00:00
'initialize:createKibanaTemplate',
2018-09-10 08:32:49 +00:00
`Creating template for ${wzWrapper.WZ_KIBANA_INDEX}`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
2018-09-10 08:32:49 +00:00
try {
2018-09-11 09:52:54 +00:00
kibanaTemplate.template = wzWrapper.WZ_KIBANA_INDEX + '*';
2018-09-10 08:32:49 +00:00
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:createKibanaTemplate', error.message || error);
2018-09-10 08:32:49 +00:00
server.log(
[blueWazuh, 'initialize', 'error'],
'Exception: ' + error.message || error
);
}
2018-09-11 09:52:54 +00:00
return wzWrapper.putWazuhKibanaTemplate(kibanaTemplate);
2018-09-10 08:32:49 +00:00
};
const createEmptyKibanaIndex = async () => {
try {
await wzWrapper.createEmptyKibanaIndex();
log(
2019-04-15 10:47:45 +00:00
'initialize:checkKibanaStatus',
2018-09-10 08:32:49 +00:00
`Successfully created ${wzWrapper.WZ_KIBANA_INDEX} index.`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
await init();
return;
} catch (error) {
return Promise.reject(
new Error(
`Error creating ${
wzWrapper.WZ_KIBANA_INDEX
} index due to ${error.message || error}`
)
);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const fixKibanaTemplate = async () => {
try {
await createKibanaTemplate();
log(
2019-04-15 10:47:45 +00:00
'initialize:checkKibanaStatus',
2018-09-10 08:32:49 +00:00
`Successfully created ${wzWrapper.WZ_KIBANA_INDEX} template.`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
await createEmptyKibanaIndex();
return;
} catch (error) {
return Promise.reject(
new Error(
`Error creating template for ${
wzWrapper.WZ_KIBANA_INDEX
} due to ${error.message || error}`
)
);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const getTemplateByName = async () => {
try {
await wzWrapper.getTemplateByName('wazuh-kibana');
log(
2019-04-15 10:47:45 +00:00
'initialize:checkKibanaStatus',
2018-09-10 08:32:49 +00:00
`No need to create the ${
wzWrapper.WZ_KIBANA_INDEX
} template, already exists.`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
await createEmptyKibanaIndex();
return;
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:checkKibanaStatus', error.message || error);
2018-09-10 08:32:49 +00:00
return fixKibanaTemplate();
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
// Does Kibana index exist?
const checkKibanaStatus = async () => {
try {
const data = await wzWrapper.checkIfIndexExists(
wzWrapper.WZ_KIBANA_INDEX
);
if (data) {
// It exists, initialize!
await init();
} else {
// No Kibana index created...
log(
2019-04-15 10:47:45 +00:00
'initialize:checkKibanaStatus',
2018-09-10 08:32:49 +00:00
"Didn't find " + wzWrapper.WZ_KIBANA_INDEX + ' index...',
'info'
);
server.log(
[blueWazuh, 'initialize', 'info'],
"Didn't find " + wzWrapper.WZ_KIBANA_INDEX + ' index...'
);
await getTemplateByName();
}
} catch (error) {
2019-04-15 10:47:45 +00:00
log('initialize:checkKibanaStatus', error.message || error);
2018-09-10 08:32:49 +00:00
server.log(
[blueWazuh, 'initialize (checkKibanaStatus)', 'error'],
error.message || error
);
}
};
2017-10-27 09:07:38 +00:00
2018-09-10 08:32:49 +00:00
// Wait until Elasticsearch js is ready
const checkStatus = async () => {
try {
await server.plugins.elasticsearch.waitUntilReady();
return checkKibanaStatus();
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkStatus',
2018-09-10 08:32:49 +00:00
'Waiting for elasticsearch plugin to be ready...',
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
setTimeout(() => checkStatus(), 3000);
}
};
2018-09-10 08:32:49 +00:00
const updateClusterInformation = async config => {
try {
await wzWrapper.updateWazuhIndexDocument(null, config.id, {
2018-09-10 08:32:49 +00:00
doc: {
api_user: config.api_user,
api_password: config.api_password,
url: config.url,
api_port: config.api_port,
manager: config.manager,
cluster_info: {
manager: config.manager,
node: config.cluster_info.node,
cluster: config.cluster_info.cluster,
status: config.cluster_info.status
}
}
2018-09-10 08:32:49 +00:00
});
log(
2019-04-15 10:47:45 +00:00
'initialize:updateClusterInformation',
2018-09-10 08:32:49 +00:00
`Successfully updated proper cluster information for ${config.manager}`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
return;
} catch (error) {
return Promise.reject(
new Error(
`Could not update proper cluster information for ${
config.manager
} due to ${error.message || error}`
)
);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const updateSingleHostInformation = async config => {
try {
await wzWrapper.updateWazuhIndexDocument(null, config.id, {
2018-09-10 08:32:49 +00:00
doc: {
api_user: config.api_user,
api_password: config.api_password,
url: config.url,
api_port: config.api_port,
manager: config.manager,
cluster_info: {
manager: config.manager,
node: 'nodata',
cluster: 'nodata',
status: 'disabled'
}
}
2018-09-10 08:32:49 +00:00
});
log(
2019-04-15 10:47:45 +00:00
'initialize:updateSingleHostInformation',
2018-09-10 08:32:49 +00:00
`Successfully updated proper single host information for ${
config.manager
}`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
return;
} catch (error) {
return Promise.reject(
new Error(
`Could not update proper single host information for ${
config.manager
} due to ${error.message || error}`
)
);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const getNodeInformation = async config => {
try {
const response = await needle(
'get',
`${config.url}:${config.api_port}/cluster/node`,
{},
{
headers: {
'wazuh-app-version': packageJSON.version
},
username: config.api_user,
password: Buffer.from(config.api_password, 'base64').toString(
'ascii'
),
rejectUnauthorized: !config.insecure
}
2018-09-10 08:32:49 +00:00
);
if (!response.body.error) {
config.cluster_info = {};
config.cluster_info.status = 'enabled';
config.cluster_info.manager = config.manager;
config.cluster_info.node = response.body.data.node;
config.cluster_info.cluster = response.body.data.cluster;
} else if (response.body.error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:getNodeInformation',
2018-09-10 08:32:49 +00:00
`Could not get cluster/node information for ${
config.manager
} due to ${response.body.error || response.body}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`Could not get cluster/node information for ${config.manager}`
);
}
return;
} catch (error) {
return Promise.reject(error);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const getClusterStatus = async config => {
try {
const response = await needle(
'get',
`${config.url}:${config.api_port}/cluster/status`,
{},
{
// Checking the cluster status
headers: {
'wazuh-app-version': packageJSON.version
},
username: config.api_user,
password: Buffer.from(config.api_password, 'base64').toString(
'ascii'
),
rejectUnauthorized: !config.insecure
}
);
if (!response.body.error) {
if (response.body.data.enabled === 'yes') {
// If cluster mode is active
return getNodeInformation(config);
} else {
// Cluster mode is not active
config.cluster_info = {};
config.cluster_info.status = 'disabled';
config.cluster_info.cluster = 'Disabled';
config.cluster_info.manager = config.manager;
}
2018-09-10 08:32:49 +00:00
// We filled data for the API, let's insert it now
return updateClusterInformation(config);
} else {
log(
2019-04-15 10:47:45 +00:00
'initialize:getClusterStatus',
2018-09-10 08:32:49 +00:00
`Could not get cluster/status information for ${config.manager}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`Could not get cluster/status information for ${config.manager}`
);
return;
}
} catch (error) {
return Promise.reject(error);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const checkVersion = async config => {
try {
const response = await needle(
'get',
`${config.url}:${config.api_port}/version`,
{},
{
headers: {
'wazuh-app-version': packageJSON.version
},
username: config.api_user,
password: Buffer.from(config.api_password, 'base64').toString(
'ascii'
),
rejectUnauthorized: !config.insecure
}
2018-09-10 08:32:49 +00:00
);
log(
2019-04-15 10:47:45 +00:00
'initialize:checkVersion',
2018-09-10 08:32:49 +00:00
`API is reachable ${config.manager}`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
2019-04-15 10:47:45 +00:00
2018-09-10 08:32:49 +00:00
if (parseInt(response.body.error) === 0 && response.body.data) {
return getClusterStatus(config);
} else {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkVersion',
2018-09-10 08:32:49 +00:00
`The API responded with some kind of error for ${config.manager}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`The API responded with some kind of error for ${config.manager}`
);
return;
}
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:checkVersion',
2018-09-10 08:32:49 +00:00
`API is NOT reachable ${config.manager} due to ${error.message ||
error}`
);
server.log(
[blueWazuh, 'reindex', 'info'],
`API is NOT reachable ${config.manager}`
);
// We weren't able to reach the API, reorganize data and fill with sample node and cluster name information
return updateSingleHostInformation(config);
}
2018-09-10 08:32:49 +00:00
};
2018-09-10 08:32:49 +00:00
const reachAPI = async config => {
try {
const id = config._id;
config = config._source;
config.id = id;
2019-04-15 10:47:45 +00:00
log('initialize:reachAPI', `Reaching ${config.manager}`, 'debug');
2018-09-10 08:32:49 +00:00
server.log([blueWazuh, 'reindex', 'info'], `Reaching ${config.manager}`);
if (config.cluster_info === undefined) {
// No cluster_info in the API configuration data -> 2.x version
await checkVersion(config);
} else {
// 3.x version
// Nothing to be done, cluster_info is present
log(
2019-04-15 10:47:45 +00:00
'initialize:reachAPI',
2018-09-10 08:32:49 +00:00
`Nothing to be done for ${
config.manager
} as it is already a 3.x version.`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
}
return;
} catch (error) {
return Promise.reject(error);
}
};
2017-12-05 15:02:09 +00:00
2018-09-10 08:32:49 +00:00
// Reindex a .wazuh index from 2.x-5.x or 3.x-5.x to .wazuh and .wazuh-version in 3.x-6.x
const reindexOldVersion = async () => {
try {
log(
2019-04-15 10:47:45 +00:00
'initialize:reindexOldVersion',
2018-09-10 08:32:49 +00:00
`Old version detected. Proceeding to reindex.`,
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
const configuration = {
source: {
index: '.wazuh',
type: 'wazuh-configuration'
},
dest: {
index: '.old-wazuh'
2018-04-02 09:23:57 +00:00
}
2018-09-10 08:32:49 +00:00
};
// Backing up .wazuh index
await wzWrapper.reindexWithCustomConfiguration(configuration);
log(
2019-04-15 10:47:45 +00:00
'initialize:reindexOldVersion',
2018-09-10 08:32:49 +00:00
'Successfully backed up .wazuh index',
2019-04-15 10:47:45 +00:00
'debug'
2018-09-10 08:32:49 +00:00
);
2019-04-15 10:47:45 +00:00
2018-09-10 08:32:49 +00:00
// And...this response does not take into acount new index population so...let's wait for it
setTimeout(() => swapIndex(), 3000);
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:reindexOldVersion',
2018-09-10 08:32:49 +00:00
`Could not begin the reindex process due to ${error.message || error}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`Could not begin the reindex process due to ${error.message || error}`
);
}
};
2017-12-05 15:02:09 +00:00
2018-09-10 08:32:49 +00:00
const swapIndex = async () => {
try {
// Deleting old .wazuh index
2019-04-15 10:47:45 +00:00
log('initialize:swapIndex', 'Deleting old .wazuh index', 'debug');
2018-09-10 08:32:49 +00:00
await wzWrapper.deleteIndexByName('.wazuh');
const configuration = {
source: {
index: '.old-wazuh',
type: 'wazuh-configuration'
},
dest: {
index: '.wazuh'
},
script: {
source: 'ctx._id = new Date().getTime()',
lang: 'painless'
2018-04-02 09:23:57 +00:00
}
2018-09-10 08:32:49 +00:00
};
2019-04-15 10:47:45 +00:00
log('initialize:swapIndex', 'Reindexing into the new .wazuh', 'debug');
2018-09-10 08:32:49 +00:00
// Reindexing from .old-wazuh where the type of document is wazuh-configuration into the new index .wazuh
await wzWrapper.reindexWithCustomConfiguration(configuration);
// Now we need to properly replace the cluster_info into the configuration -> improvement: pagination?
// And...this response does not take into acount new index population so...let's wait for it
setTimeout(() => reachAPIs(), 3000);
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize:swapIndex',
2018-09-10 08:32:49 +00:00
`Could not reindex the new .wazuh due to ${error.message || error}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`Could not reindex the new .wazuh due to ${error.message || error}`
);
}
};
2017-12-05 15:02:09 +00:00
2018-09-10 08:32:49 +00:00
const reachAPIs = async () => {
try {
const data = await wzWrapper.searchIndexByName('.wazuh');
const promises = [];
for (let item of data.hits.hits) {
promises.push(reachAPI(item));
}
await Promise.all(promises);
} catch (error) {
log(
2019-04-15 10:47:45 +00:00
'initialize[reachAPIs]',
2018-09-10 08:32:49 +00:00
`Something happened while getting old API configuration data due to ${error.message ||
error}`
);
server.log(
[blueWazuh, 'reindex', 'error'],
`Something happened while getting old API configuration data due to ${error.message ||
error}`
);
}
};
2018-09-10 08:32:49 +00:00
// Check Kibana index and if it is prepared, start the initialization of Wazuh App.
checkStatus();
}