wazuh-kibana-app/server/routes/wazuh-elastic.js

105 lines
2.5 KiB
JavaScript
Raw Normal View History

/*
* Wazuh app - Module for Wazuh-Elastic routes
* Copyright (C) 2018 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-03 09:46:55 +00:00
import { WazuhElasticCtrl } from '../controllers';
2018-09-03 09:46:55 +00:00
export function WazuhElasticRouter(server) {
2018-09-10 08:32:49 +00:00
const ctrl = new WazuhElasticCtrl(server);
2018-09-03 09:46:55 +00:00
2018-09-10 08:32:49 +00:00
// Get index patterns list
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/index-patterns',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.getlist(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Refresh known fields for specific index pattern
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/known-fields/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.refreshIndex(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Create visualizations specified in 'tab' parameter and applying to 'pattern'
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/visualizations/{tab}/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.createVis(req, res);
}
});
server.route({
method: 'POST',
2018-10-01 07:56:50 +00:00
path: '/elastic/visualizations/{tab}/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.createClusterVis(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Returns whether a correct template is being applied for the index-pattern
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/template/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.getTemplate(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Returns whether the pattern exists or not
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/index-patterns/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.checkPattern(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Returns the agent with most alerts
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/top/{mode}/{cluster}/{field}/{pattern}',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.getFieldTop(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Return Wazuh Appsetup info
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/setup',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.getSetupInfo(req, res);
}
});
2018-09-10 08:32:49 +00:00
// Useful to check cookie consistence
server.route({
method: 'GET',
2018-10-01 07:56:50 +00:00
path: '/elastic/timestamp',
2018-09-10 08:32:49 +00:00
handler(req, res) {
return ctrl.getTimeStamp(req, res);
}
});
2018-12-03 13:54:39 +00:00
// Fetch alerts directly from Elasticsearch
server.route({
method: 'POST',
path: '/elastic/alerts',
handler(req, res) {
return ctrl.alerts(req, res);
}
});
2018-09-10 08:32:49 +00:00
}