The Wazuh App brings together a new and useful web interface for managing and monitoring your Wazuh infrastructure. You can check agent status, alert evolution, most recent events, popular alerts, top alert groups, etc. You can also display configuration and logs of the manager.
In addition, make use of any or all of these extensions:
@@ -45,7 +45,7 @@
- Wazuh App: API configuration
+ Wazuh App: API configuration
Manager
@@ -106,7 +106,7 @@
- Wazuh App: Extensions
+ Wazuh App: Extensions
Enable or disable extensions according to your needs. The extension includes: Panels, discover and dashboards, for agents / overview.
@@ -154,7 +154,7 @@
- About
+ About
The Wazuh App brings together a new and useful web interface for managing and monitoring your Wazuh infrastructure. You can check agent status, alert evolution, most recent events, popular alerts, top alert groups, etc. You can also display configuration and logs of the manager.
In addition, make use of any or all of these extensions:
@@ -172,7 +172,7 @@
- Version
+ Version
App version
{{appInfo["app-version"]}}
diff --git a/server/api/wazuh-api.js b/server/api/wazuh-api.js
index 229a5f193..447914327 100644
--- a/server/api/wazuh-api.js
+++ b/server/api/wazuh-api.js
@@ -39,7 +39,7 @@ module.exports = function (server, options) {
//Handlers - Generic
var getConfig = function (callback) {
- elasticRequest.callWithInternalUser('search', { index: '.kibana', type: 'wazuh-configuration', q: 'active:true'}).then(
+ elasticRequest.callWithInternalUser('search', { index: '.wazuh', type: 'wazuh-configuration', q: 'active:true'}).then(
function (data) {
if (data.hits.total == 1) {
callback({ 'user': data.hits.hits[0]._source.api_user, 'password': new Buffer(data.hits.hits[0]._source.api_password, 'base64').toString("ascii"), 'url': data.hits.hits[0]._source.url, 'port': data.hits.hits[0]._source.api_port, 'insecure': data.hits.hits[0]._source.insecure, 'manager': data.hits.hits[0]._source.manager, 'extensions': data.hits.hits[0]._source.extensions });
@@ -52,7 +52,7 @@ module.exports = function (server, options) {
};
var getAPI_entries = function (req,reply) {
- elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration'}).then(
+ elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration'}).then(
function (data) {
reply(data.hits.hits);
}, function (data, error) {
@@ -61,7 +61,7 @@ module.exports = function (server, options) {
};
var deleteAPI_entries = function (req,reply) {
- elasticRequest.callWithRequest(req, 'delete', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id}).then(
+ elasticRequest.callWithRequest(req, 'delete', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id}).then(
function (data) {
reply(data);
}, function (data, error) {
@@ -71,15 +71,15 @@ module.exports = function (server, options) {
var setAPI_entry_default = function (req,reply) {
// Searching for previous default
- elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration', q: 'active:true'}).then(
+ elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration', q: 'active:true'}).then(
function (data) {
if (data.hits.total == 1) {
// Setting off previous default
var idPreviousActive = data.hits.hits[0]._id;
- elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: idPreviousActive, body: {doc: {"active": "false"}} }).then(
+ elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: idPreviousActive, body: {doc: {"active": "false"}} }).then(
function () {
// Set new default
- elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then(
+ elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then(
function () {
reply({ 'statusCode': 200, 'message': 'ok' });
}, function (error) {
@@ -90,7 +90,7 @@ module.exports = function (server, options) {
});
}else{
// Set new default
- elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then(
+ elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then(
function () {
reply({ 'statusCode': 200, 'message': 'ok' });
}, function (error) {
@@ -129,7 +129,7 @@ module.exports = function (server, options) {
};
var getExtensions = function (req,reply) {
- elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration'}).then(
+ elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration'}).then(
function (data) {
reply(data.hits.hits);
}, function (data, error) {
@@ -142,7 +142,7 @@ module.exports = function (server, options) {
var extension = {};
extension[req.params.extensionName] = (req.params.extensionValue == "true") ? true : false;
- elasticRequest.callWithRequest(req, 'update',{ index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"extensions" : extension}} }).then(
+ elasticRequest.callWithRequest(req, 'update',{ index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"extensions" : extension}} }).then(
function () {
reply({ 'statusCode': 200, 'message': 'ok' });
}, function (error) {
@@ -344,7 +344,7 @@ module.exports = function (server, options) {
var settings = { 'api_user': req.payload.user, 'api_password': req.payload.password, 'url': req.payload.url, 'api_port': req.payload.port , 'insecure': req.payload.insecure, 'component' : 'API', 'active' : req.payload.active, 'manager' : req.payload.manager, 'extensions' : req.payload.extensions};
- elasticRequest.callWithRequest(req, 'index', { index: '.kibana', type: 'wazuh-configuration', body: settings, refresh: true })
+ elasticRequest.callWithRequest(req, 'index', { index: '.wazuh', type: 'wazuh-configuration', body: settings, refresh: true })
.then(function (response) {
reply({ 'statusCode': 200, 'message': 'ok', 'response' : response });
}, function (error) {
diff --git a/server/api/wazuh-elastic.js b/server/api/wazuh-elastic.js
index 04e721072..028a30c07 100644
--- a/server/api/wazuh-elastic.js
+++ b/server/api/wazuh-elastic.js
@@ -120,6 +120,21 @@ module.exports = function (server, options) {
});
};
+ var getSetupInfo = function (req, reply) {
+ elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-setup' })
+ .then(function (data) {
+ if (data.hits.total == 0) {
+ reply({ 'statusCode': 200, 'data': '' });
+ }
+ else {
+ reply({ 'statusCode': 200, 'data': data.hits.hits[0]._source });
+ }
+ }, function (error) {
+ console.log(error);
+ reply({ 'statusCode': 500, 'error': 9, 'message': 'Could not get data from elasticsearch' }).code(500);
+ });
+ };
+
var putWazuhAlertsPattern = function (req, reply) {
try {
@@ -313,6 +328,17 @@ module.exports = function (server, options) {
handler: getLastField
});
+ /*
+ * GET /api/wazuh-elastic/setup
+ * Return Wazuh Appsetup info
+ *
+ **/
+ server.route({
+ method: 'GET',
+ path: '/api/wazuh-elastic/setup',
+ handler: getSetupInfo
+ });
+
/*
* PUT /api/wazuh-elastic/wazuh-pattern
* Set wazuh index pattern
diff --git a/server/startup/initialize.js b/server/startup/initialize.js
index f642c8c96..8151f6c55 100644
--- a/server/startup/initialize.js
+++ b/server/startup/initialize.js
@@ -47,7 +47,7 @@ module.exports = function (server, options) {
var setup_info = {"name" : "Wazuh App", "app-version": packageJSON.version, "revision": packageJSON.revision, "installationDate": new Date().toISOString() };
if(type == "install"){
- elasticRequest.callWithInternalUser('create', { index: ".kibana", type: 'wazuh-setup', id: 1, body: setup_info }).then(
+ elasticRequest.callWithInternalUser('create', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: setup_info }).then(
function () {
server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info inserted');
}, function () {
@@ -56,13 +56,23 @@ module.exports = function (server, options) {
}
if(type == "upgrade"){
- elasticRequest.callWithInternalUser('update', { index: ".kibana", type: 'wazuh-setup', id: 1, body: {doc: setup_info}}).then(
+ elasticRequest.callWithInternalUser('update', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: {doc: setup_info}}).then(
function () {
server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info updated');
}, function () {
server.log([blueWazuh, 'initialize', 'error'], 'Could not upgrade Wazuh set up info');
});
}
+
+ if(type == "migration"){
+ elasticRequest.callWithInternalUser('create', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: setup_info }).then(
+ function () {
+ server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info inserted');
+ }, function (error) {
+ server.log([blueWazuh, 'initialize', 'error'], 'Could not insert Wazuh set up info');
+ });
+
+ }
};
@@ -122,7 +132,7 @@ module.exports = function (server, options) {
var setDefaultKibanaSettings = function () {
server.log([blueWazuh, 'initialize', 'info'], 'Setting Kibana default values: Index pattern, time picker and metaFields...');
- uiSettings.setMany(req,{'defaultIndex':'wazuh-alerts-*', 'timepicker:timeDefaults':'{ \"from\": \"now-24h\", \"to\": \"now\", \"mode\": \"quick\"}','metaFields':[]})
+ uiSettings.setMany(req,{'defaultIndex':'wazuh-alerts-*', 'timepicker:timeDefaults':'{ \"from\": \"now-24h\", \"to\": \"now\", \"mode\": \"quick\"}','metaFields':['_source']})
.then(function (data) {
server.log([blueWazuh, 'initialize', 'info'], 'Kibana default values set');
}).catch(function (data) {
@@ -131,6 +141,32 @@ module.exports = function (server, options) {
});
};
+ var importConfigurationFromKibana = function () {
+ elasticRequest.callWithInternalUser('search',{ index: '.kibana', type: 'wazuh-configuration'})
+ .then(function (data) {
+ if (data.hits.total > 0) {
+ var body = '';
+ data.hits.hits.forEach(function (element) {
+ body += '{ "index": { "_index": ".wazuh", "_type": "wazuh-configuration", "_id": "'+element._id+'" } }\n';
+ body += JSON.stringify(element._source) + "\n";
+ });
+ elasticRequest.callWithInternalUser('bulk',{
+ index: '.wazuh',
+ body: body
+ }).then(function () {
+ elasticRequest.callWithInternalUser('indices.refresh',{ index: '.wazuh' });
+ server.log([blueWazuh, 'initialize', 'info'], 'wazuh-configuration documents were successfully imported.');
+ }, function (err) {
+ server.log([blueWazuh, 'initialize', 'error'], 'Error importing wazuh-configuration documents into .wazuh index. Bulk request failed.');
+ });
+ }
+ else{
+ server.log([blueWazuh, 'initialize', 'info'], 'No wazuh-configuration documents were found in .kibana index.');
+ }
+ }, function () {
+ server.log([blueWazuh, 'initialize', 'error'], 'wazuh-configuration documents could not be imported from .kibana index to .wazuh index.');
+ });
+ }
// Configure Kibana status: Index pattern, default index pattern, default time, import dashboards.
var configureKibana = function (type) {
@@ -144,6 +180,10 @@ module.exports = function (server, options) {
importObjects();
}
+ if(type == "migration"){
+ importConfigurationFromKibana();
+ importObjects();
+ }
// Save Setup Info
saveSetupInfo(type);
@@ -152,13 +192,19 @@ module.exports = function (server, options) {
// Init function. Check for "wazuh-setup" document existance.
var init = function () {
- elasticRequest.callWithInternalUser('get', { index: ".kibana", type: "wazuh-setup", id: "1" }).then(
+ elasticRequest.callWithInternalUser('get', { index: ".wazuh", type: "wazuh-setup", id: "1" }).then(
function (data) {
server.log([blueWazuh, 'initialize', 'info'], 'Wazuh-setup document already exists. Proceed to upgrade.');
configure("upgrade");
}, function (data) {
server.log([blueWazuh, 'initialize', 'info'], 'Wazuh-setup document does not exist. Initializating configuration...');
- configure("install");
+ elasticRequest.callWithInternalUser('get', { index: ".kibana", type: "wazuh-setup", id: "1" }).then(
+ function (result) {
+ configure("migration");
+ }, function () {
+ configure("install");
+ }
+ );
}
);
};
diff --git a/server/wazuh-monitoring.js b/server/wazuh-monitoring.js
index 322b44049..342178391 100644
--- a/server/wazuh-monitoring.js
+++ b/server/wazuh-monitoring.js
@@ -207,7 +207,7 @@ module.exports = function (server, options) {
// Get API configuration from elastic and callback to loadCredentials
var getConfig = function (callback) {
- elasticRequest.callWithInternalUser('search',{ index: '.kibana', type: 'wazuh-configuration'})
+ elasticRequest.callWithInternalUser('search',{ index: '.wazuh', type: 'wazuh-configuration'})
.then(function (data) {
if (data.hits.total > 0) {
callback(data.hits);