diff --git a/public/controllers/overview.js b/public/controllers/overview.js index 2b6cda10e..cd2a5fa29 100644 --- a/public/controllers/overview.js +++ b/public/controllers/overview.js @@ -3,8 +3,8 @@ import $ from 'jquery'; app.controller('overviewController', function ($scope, $location, $rootScope, appState, genericReq, errorHandler, metricService) { + // Timestamp for visualizations at controller's startup if(!$rootScope.visTimestamp) $rootScope.visTimestamp = new Date().getTime(); - $rootScope.backFinished = false; if(!$rootScope.$$phase) $rootScope.$digest $rootScope.page = 'overview'; @@ -63,7 +63,7 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap awsRevoked :'[vis-id="\'Wazuh-App-Overview-AWS-Metric-Revoke-security\'"]' } - // Check the url hash and retrieve the tabView information + // Check the url hash and retrieve tabView information if ($location.search().tabView) { $scope.tabView = $location.search().tabView; } else { // If tabView doesn't exist, default it to 'panels' @@ -71,7 +71,7 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap $location.search('tabView', 'panels'); } - // Check the url hash and retrivew the tab information + // Check the url hash and retrieve tab information if ($location.search().tab) { $scope.tab = $location.search().tab; } else { // If tab doesn't exist, default it to 'general' @@ -140,8 +140,6 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap if(!$rootScope.$$phase) $rootScope.$digest(); } - checkMetrics($scope.tab, $scope.tabView); - // Switch subtab $scope.switchSubtab = subtab => { if ($scope.tabView === subtab) return; @@ -153,54 +151,39 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap $scope.switchTab = tab => { if ($scope.tab === tab) return; - - // call backend to create visualizations - $rootScope.backFinished = false; - genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) - .then(() => genericReq.request('GET',`/api/wazuh-elastic/create-vis/overview-${$scope.tab}/${$rootScope.visTimestamp}/${appState.getCurrentPattern()}`)) + // Create current tab visualizations + genericReq.request('GET',`/api/wazuh-elastic/create-vis/overview-${$scope.tab}/${$rootScope.visTimestamp}/${appState.getCurrentPattern()}`) .then(() => { + + // Render visualizations + $rootScope.$broadcast('updateVis'); + checkMetrics(tab, 'panels'); // Deleting app state traces in the url $location.search('_a', null); - $rootScope.backFinished = true; - if(!$rootScope.$$phase) $rootScope.$digest(); - }) - .catch(console.error) + }) + .catch(error => { + errorHandler.handle(error, 'Overview'); + }); }; + // Watch tabView $scope.$watch('tabView', () => { - $rootScope.backFinished = false; - $location.search('tabView', $scope.tabView); - if($scope.tabView === 'panels'){ - // Update the implicit filter - genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) - .then(() => genericReq.request('GET',`/api/wazuh-elastic/create-vis/overview-${$scope.tab}/${$rootScope.visTimestamp}/${appState.getCurrentPattern()}`)) - .then(() => { - $rootScope.backFinished = true; - if(!$rootScope.$$phase) $rootScope.$digest(); - }) - .catch(console.error) - } else { - genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) - .then(() => { - if ($rootScope.ownHandlers) { - for (let h of $rootScope.ownHandlers) { - h._scope.$destroy(); - } - } - $rootScope.ownHandlers = []; - - $rootScope.loadedVisualizations = []; - $rootScope.backFinished = true; - if(!$rootScope.$$phase) $rootScope.$digest(); - }) - .catch(console.error) - } + $location.search('tabView', $scope.tabView); + if ($rootScope.ownHandlers) { + for (let h of $rootScope.ownHandlers) { + h._scope.$destroy(); + } + } + $rootScope.ownHandlers = []; + + $rootScope.loadedVisualizations = []; }); + // Watch tab $scope.$watch('tab', () => { $location.search('tab', $scope.tab); @@ -222,10 +205,7 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap }); $scope.$on('$destroy', () => { - $rootScope.backFinished = false; - genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) - .then(() => $rootScope.backFinished = true) - .catch(console.error) + if ($rootScope.ownHandlers) { for (let h of $rootScope.ownHandlers) { h._scope.$destroy(); @@ -237,16 +217,18 @@ app.controller('overviewController', function ($scope, $location, $rootScope, ap $rootScope.ownHandlers = []; }); - - // call backend to create visualizations at controller's initialization - - genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) - .then(() => genericReq.request('GET',`/api/wazuh-elastic/create-vis/overview-${$scope.tab}/${$rootScope.visTimestamp}/${appState.getCurrentPattern()}`)) + // Create visualizations for controller's first execution + genericReq.request('GET',`/api/wazuh-elastic/create-vis/overview-${$scope.tab}/${$rootScope.visTimestamp}/${appState.getCurrentPattern()}`) .then(() => { - $rootScope.backFinished = true; - if(!$rootScope.$$phase) $rootScope.$digest(); + + // Render visualizations + $rootScope.$broadcast('updateVis'); + + checkMetrics($scope.tab, $scope.tabView); }) - .catch(console.error) + .catch(error => { + errorHandler.handle(error, 'Overview'); + }); //PCI tab let tabs = []; diff --git a/public/kibana-integrations/kibana-visualization.js b/public/kibana-integrations/kibana-visualization.js index e20ddd7e7..c4957d63f 100644 --- a/public/kibana-integrations/kibana-visualization.js +++ b/public/kibana-integrations/kibana-visualization.js @@ -1,6 +1,6 @@ import $ from 'jquery'; const ownLoader = require('./loader/loader-import'); -let accumulate = {},stopLoop = false; + var app = require('ui/modules').get('apps/webinar_app', []) .directive('kbnVis', [function () { return { @@ -9,8 +9,7 @@ var app = require('ui/modules').get('apps/webinar_app', []) visID: '=visId', specificTimeRange: '=specificTimeRange' }, - controller: function VisController($scope, $rootScope, $location, savedVisualizations, $window,genericReq) { - + controller: function VisController($scope, $rootScope, $location, savedVisualizations, genericReq) { if(!$rootScope.ownHandlers) $rootScope.ownHandlers = []; let originalImplicitFilter = ''; let implicitFilter = ''; @@ -22,15 +21,13 @@ var app = require('ui/modules').get('apps/webinar_app', []) let renderInProgress = false; const myRender = function() { - if(typeof accumulate[$scope.visID] === 'undefined') accumulate[$scope.visID] = 'pending' - if ($rootScope.visTimestamp) { // Only render if we already have the timestamp for it - if (($rootScope.discoverPendingUpdates && $rootScope.discoverPendingUpdates.length != 0) || $scope.visID.includes('Ruleset') ){ // There are pending updates from the discover (which is the one who owns the true app state) + if (($rootScope.discoverPendingUpdates && $rootScope.discoverPendingUpdates.length != 0) || $scope.visID.includes('Ruleset') ) { // There are pending updates from the discover (which is the one who owns the true app state) - if(!visualization && !rendered && !renderInProgress) { // There's no visualization object -> create it with proper filters - renderInProgress = true; - - savedVisualizations.get(!$scope.visID.includes('Agents-status') ? $scope.visID + "-" + $rootScope.visTimestamp : $scope.visID) - .then(savedObj => { + if(!visualization && !rendered && !renderInProgress) { // There's no visualization object -> create it with proper filters + renderInProgress = true; + + if ($rootScope.visTimestamp) { + savedVisualizations.get($scope.visID + "-" + $rootScope.visTimestamp).then(savedObj => { originalImplicitFilter = savedObj.searchSource.get('query')['query']; visTitle = savedObj.vis.title; visualization = savedObj; @@ -74,28 +71,27 @@ var app = require('ui/modules').get('apps/webinar_app', []) $rootScope.ownHandlers.push(visHandler); visHandler.addRenderCompleteListener(renderComplete); }); + } + } else if (rendered) { // There's a visualization object -> just update its filters - } else if (rendered) { // There's a visualization object -> just update its filters - - // There's an original filter - if (originalImplicitFilter.length > 0 ) { - // And also a pending one -> concatenate them - if ($rootScope.discoverPendingUpdates && typeof $rootScope.discoverPendingUpdates[0].query === 'string' && $rootScope.discoverPendingUpdates[0].query.length > 0) { - implicitFilter = originalImplicitFilter + ' AND ' + $rootScope.discoverPendingUpdates[0].query; - } else { - // Only the original filter - implicitFilter = originalImplicitFilter; - } + // There's an original filter + if (originalImplicitFilter.length > 0 ) { + // And also a pending one -> concatenate them + if ($rootScope.discoverPendingUpdates && typeof $rootScope.discoverPendingUpdates[0].query === 'string' && $rootScope.discoverPendingUpdates[0].query.length > 0) { + implicitFilter = originalImplicitFilter + ' AND ' + $rootScope.discoverPendingUpdates[0].query; } else { - // Other case, use the pending one, if it is empty, it won't matter - implicitFilter = $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[0].query : ''; - } - - if (visTitle !== 'Wazuh App Overview General Agents status') { // We don't want to filter that visualization as it uses another index-pattern - visualization.searchSource - .query({ language: 'lucene', query: implicitFilter }) - .set('filter', $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[1] : {}); + // Only the original filter + implicitFilter = originalImplicitFilter; } + } else { + // Other case, use the pending one, if it is empty, it won't matter + implicitFilter = $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[0].query : ''; + } + + if (visTitle !== 'Wazuh App Overview General Agents status') { // We don't want to filter that visualization as it uses another index-pattern + visualization.searchSource + .query({ language: 'lucene', query: implicitFilter }) + .set('filter', $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[1] : {}); } } } @@ -106,46 +102,32 @@ var app = require('ui/modules').get('apps/webinar_app', []) myRender(); }); - const renderComplete = () => { - if(accumulate[$scope.visID] === 'pending'){ - accumulate[$scope.visID] = 'complete' - } + var renderComplete = function() { rendered = true; if(typeof $rootScope.loadedVisualizations === 'undefined') $rootScope.loadedVisualizations = []; $rootScope.loadedVisualizations.push(true); let currentCompleted = Math.round(($rootScope.loadedVisualizations.length / $rootScope.tabVisualizations[$location.search().tab]) * 100); $rootScope.loadingStatus = `Rendering visualizations... ${currentCompleted > 100 ? 100 : currentCompleted} %`; - let completed = true; - for(let key in accumulate){ - if(accumulate[key] === 'pending') completed = false; - break; - } - if (completed && currentCompleted >= 100) { - if(!stopLoop){ - stopLoop =true; + + if (currentCompleted >= 100) { + + if ($rootScope.visTimestamp) { genericReq.request('GET',`/api/wazuh-elastic/delete-vis/${$rootScope.visTimestamp}`) .then(() => { - if (!visTitle !== 'Wazuh App Overview General Agents status') $rootScope.rendered = true; - // Forcing a digest cycle - if(!$rootScope.$$phase) $rootScope.$digest(); - }) - .catch(error => console.error(error.message || error)) - } else { - if (!visTitle !== 'Wazuh App Overview General Agents status') $rootScope.rendered = true; - // Forcing a digest cycle - if(!$rootScope.$$phase) $rootScope.$digest(); + $rootScope.visTimestamp = null; + }); } - } else if (!visTitle !== 'Wazuh App Overview General Agents status') { - - $rootScope.rendered = false; + + if (!visTitle !== 'Wazuh App Overview General Agents status') $rootScope.rendered = true; + // Forcing a digest cycle if(!$rootScope.$$phase) $rootScope.$digest(); } + else if (!visTitle !== 'Wazuh App Overview General Agents status') $rootScope.rendered = false; }; // Initializing the visualization const loader = ownLoader.getVisualizeLoader(); - myRender(); } } }]); \ No newline at end of file diff --git a/public/templates/overview/overview-audit.html b/public/templates/overview/overview-audit.html index 28b0e47f8..6496e1883 100644 --- a/public/templates/overview/overview-audit.html +++ b/public/templates/overview/overview-audit.html @@ -1,121 +1,118 @@ - + - - +
+ + +
New files: {{auditNewFiles}}
+
Read files: {{auditReadFiles}}
+
Modified files: {{auditModifiedFiles}}
+
Removed files: {{auditRemovedFiles}}
+
+
+
-
- - -
New files: {{auditNewFiles}}
-
Read files: {{auditReadFiles}}
-
Modified files: {{auditModifiedFiles}}
-
Removed files: {{auditRemovedFiles}}
+
+ + + + +
+ +
+ + + Groups + + + + + + + Agents + + + + + + + Directories + + + + + + + Files + + + + +
+ +
+ + + Alerts over time + + + + +
+ +
+
+ + + File read access + + + + + + + File write access + +
-
- - - - -
- -
- - - Groups - - - - - - - Agents - - - - - - - Directories - - - - - - - Files - - - - -
- -
+
- Alerts over time + Commands - +
-
-
- - - File read access - - - - - - - File write access - - - - -
- -
- - - Commands - - - - -
- -
- - - Created files - - - - - - - Removed files - - - - -
-
- -
- +
+ - Alerts summary + Created files - + + + + + + Removed files + +
- +
+ +
+ + + Alerts summary + + + + +
+ diff --git a/public/templates/overview/overview-aws.html b/public/templates/overview/overview-aws.html index 47948412e..412feccab 100644 --- a/public/templates/overview/overview-aws.html +++ b/public/templates/overview/overview-aws.html @@ -1,87 +1,82 @@ - + - - +
+ + +
Successful logins: {{awsLogins}}
+
Most active user: {{awsMostActiveUser}}
+
Authorized security groups: {{awsAuthorized}}
+
Revoked security groups: {{awsRevoked}}
+
+
+
-
- - -
Successful logins: {{awsLogins}}
-
Most active user: {{awsMostActiveUser}}
-
Authorized security groups: {{awsAuthorized}}
-
Revoked security groups: {{awsRevoked}}
-
-
-
+
+ + + + +
-
- - - - -
- -
-
- - - Instances - - - - -
-
- -
-
- - - Security groups over time - - - - -
-
- -
+
+
- Events over time + Instances - +
+
-
- - - Event sources over time - - - - - - - Success login - Top 5 countries - - - - -
- -
+
+
- Alerts summary + Security groups over time - +
+
- +
+ + + Events over time + + + + +
+ +
+ + + Event sources over time + + + + + + + Success login - Top 5 countries + + + + +
+ +
+ + + Alerts summary + + + + +
diff --git a/public/templates/overview/overview-fim.html b/public/templates/overview/overview-fim.html index bca616867..661e2e3b2 100644 --- a/public/templates/overview/overview-fim.html +++ b/public/templates/overview/overview-fim.html @@ -1,86 +1,84 @@ - + -
- - -
Files added: {{fimAdded}}
-
Files modified: {{fimModified}}
-
Files deleted: {{fimDeleted}}
+
+ + +
Files added: {{fimAdded}}
+
Files modified: {{fimModified}}
+
Files deleted: {{fimDeleted}}
+
+
+
+ +
+ + + +
+ +
+ +
+ + + Events over time + +
-
- - - -
- -
- -
- - - Events over time - - - - -
- -
- - - Top user owners - - - - - - - Top group owners - - - - -
- -
- -
+
- Top file changes + Top user owners - + - Root user file changes + Top group owners - - - - - - World writable modified files - - +
-
- - - Events summary - - - - -
+
- +
+ + + Top file changes + + + + + + + Root user file changes + + + + + + + World writable modified files + + + + +
+ +
+ + + Events summary + + + + +
diff --git a/public/templates/overview/overview-general.html b/public/templates/overview/overview-general.html index 702ea91f2..ffeaa771f 100644 --- a/public/templates/overview/overview-general.html +++ b/public/templates/overview/overview-general.html @@ -1,4 +1,4 @@ - +
diff --git a/public/templates/overview/overview-oscap.html b/public/templates/overview/overview-oscap.html index da48b7207..7b164a2e8 100644 --- a/public/templates/overview/overview-oscap.html +++ b/public/templates/overview/overview-oscap.html @@ -1,91 +1,88 @@ - + - - +
+ + +
Last score: {{scapLastScore}}
+
Highest score: {{scapHighestScore}}
+
Lowest score: {{scapLowestScore}}
+
+
+
-
- - -
Last score: {{scapLastScore}}
-
Highest score: {{scapHighestScore}}
-
Lowest score: {{scapLowestScore}}
-
-
-
+
+ + + +
-
- - - -
+
+ + + Agents + + + + + + + Profiles + + + + + + + Content + + + + + + + Severity + + + + +
-
- - - Agents - - - - - - - Profiles - - - - - - - Content - - - - - - - Severity - - - - -
+
+ + + Top 5 Agents - Severity high + + + + +
-
- - - Top 5 Agents - Severity high - - - - -
+
+ + + Top 10 - Alerts + + + + -
- - - Top 10 - Alerts - - - - + + + Top 10 - High risk alerts + + + + +
- - - Top 10 - High risk alerts - - - - -
- -
- - - Alerts summary - - - - -
+
+ + + Alerts summary + + + + +
diff --git a/public/templates/overview/overview-pci.html b/public/templates/overview/overview-pci.html index c4b766396..4cc90cdc4 100644 --- a/public/templates/overview/overview-pci.html +++ b/public/templates/overview/overview-pci.html @@ -1,76 +1,73 @@ - + - - - -
- - - -
- PCI DSS Requirement: {{tab.title}} - -
-
-
+
+ + + +
+ PCI DSS Requirement: {{tab.title}} + +
+
- - - -
+
+ + + +
-
- - - Last alerts - - - - -
+
+ + + Last alerts + + + + +
-
- - - Requirements - - - - - - - Groups - - - - -
+
+ + + Requirements + + + + + + + Groups + + + + +
-
- - - Agents - - - - - - - Requirements by agent - - - - -
+
+ + + Agents + + + + + + + Requirements by agent + + + + +
-
- - - Alerts summary - - - - -
+
+ + + Alerts summary + + + + +
diff --git a/public/templates/overview/overview-pm.html b/public/templates/overview/overview-pm.html index a4181c715..e27421285 100644 --- a/public/templates/overview/overview-pm.html +++ b/public/templates/overview/overview-pm.html @@ -1,52 +1,49 @@ - + - - +
+ + + Events over time + + + + -
- - - Events over time - - - - + + + Top 5 CIS Requirements + + + + - - - Top 5 CIS Requirements - - - - + + + Top 5 PCI DSS Requirements + + + + +
- - - Top 5 PCI DSS Requirements - - - - -
+
+ + + Events per agent evolution + + + + +
-
- - - Events per agent evolution - - - - -
- -
- - - Alerts summary - - - - -
+
+ + + Alerts summary + + + + +
diff --git a/public/templates/overview/overview-virustotal.html b/public/templates/overview/overview-virustotal.html index c9fa11c81..13d6d3733 100644 --- a/public/templates/overview/overview-virustotal.html +++ b/public/templates/overview/overview-virustotal.html @@ -1,72 +1,71 @@ - + -
- - -
Total malicious: {{virusMalicious}}
-
Total positives: {{virusPositives}}
-
Total: {{virusTotal}}
-
-
-
+
+ + +
Total malicious: {{virusMalicious}}
+
Total positives: {{virusPositives}}
+
Total: {{virusTotal}}
+
+
+
-
- - - -
+
+ + + +
-
-
-
- - - Unique malicious files per agent - - - - -
-
-
-
- - - Last scanned files - - - - -
+
+
+
+ + + Unique malicious files per agent + + + +
-
- - - Top 10 agents with positive scans - - - - -
-
- - - Malicious files alerts evolution - - - - -
-
- - - Last files - - - - +
+
+ + + Last scanned files + + + + +
+
+
+ + + Top 10 agents with positive scans + + + + +
+
+ + + Malicious files alerts evolution + + + + +
+
+ + + Last files + + + + +
- diff --git a/public/templates/overview/overview-vuls.html b/public/templates/overview/overview-vuls.html index 24fff80a2..25522aed0 100644 --- a/public/templates/overview/overview-vuls.html +++ b/public/templates/overview/overview-vuls.html @@ -1,63 +1,58 @@ - + - +
+ + +
Critical severity alerts: {{vulnCritical}}
+
High severity alerts: {{vulnHigh}}
+
Medium severity alerts: {{vulnMedium}}
+
Low severity alerts: {{vulnLow}}
+
+
+
+
+ + + + +
-
- - -
Critical severity alerts: {{vulnCritical}}
-
High severity alerts: {{vulnHigh}}
-
Medium severity alerts: {{vulnMedium}}
-
Low severity alerts: {{vulnLow}}
-
-
-
+
+ + + Alerts severity over time + + + + +
-
- - - - -
+
+ + + Top Agents severity + + + + + + + Affected packages - Top 5 + + + + +
-
- - - Alerts severity over time - - - - -
- -
- - - Top Agents severity - - - - - - - Affected packages - Top 5 - - - - -
- -
- - - Alerts summary - - - - -
- - +
+ + + Alerts summary + + + + +
diff --git a/public/templates/overview/overview.head b/public/templates/overview/overview.head index f5c6f3e82..f75cb269f 100644 --- a/public/templates/overview/overview.head +++ b/public/templates/overview/overview.head @@ -34,7 +34,7 @@ -
+
{{loadingStatus}}
diff --git a/server/api/wazuh-elastic.js b/server/api/wazuh-elastic.js index 3cbf2c97c..9294ed14c 100644 --- a/server/api/wazuh-elastic.js +++ b/server/api/wazuh-elastic.js @@ -343,7 +343,7 @@ module.exports = (server, options) => { } } - const deleteVis = async (req,res) => { + const deleteVis = async (req, res) => { try { const tmp = await elasticRequest.callWithInternalUser('deleteByQuery', { index: '.kibana', @@ -354,49 +354,47 @@ module.exports = (server, options) => { }) await elasticRequest.callWithInternalUser('indices.refresh', { index: ['.kibana']}) - return res({aknowledge: true , output: tmp}); + return res({acknowledge: true , output: tmp}); } catch(error){ - console.log(error.message || error) return res({error:error.message || error}).code(500); } } /** - * Replaces our visualizations main fields to fit our pattern needs. - * @param {*} app_objects Object with the visualizations raw content. - * @param {*} id Eg: 'wazuh-alerts' + * Replaces visualizations main fields to fit a certain pattern. + * @param {*} app_objects Object containing raw visualizations. + * @param {*} id Index-pattern id to use in the visualizations. Eg: 'wazuh-alerts' + * @param {*} timestamp Milliseconds timestamp used to identify visualizations batch. */ - const buildVisualizationsBulk = (app_objects,id,timestamp) => { + const buildVisualizationsBulk = (app_objects, id, timestamp) => { try{ let body = ''; for (let element of app_objects) { - body += '{ "index": { "_index": ".kibana", "_type": "doc", ' + '"_id": "' + element._type + ':' + element._id + '-'+timestamp+'" } }\n'; - + // Bulk action (you define index, doc and id) + body += '{ "index": { "_index": ".kibana", "_type": "doc", ' + '"_id": "' + element._type + ':' + element._id + '-' + timestamp + '" } }\n'; - let temp = {}; - let aux = JSON.stringify(element._source); - aux = aux.replace("wazuh-alerts", id); - aux = JSON.parse(aux); - temp[element._type] = aux; - - if (temp[element._type].kibanaSavedObjectMeta.searchSourceJSON.index) { - temp[element._type].kibanaSavedObjectMeta.searchSourceJSON.index = id; - } + // Stringify and replace index-pattern for visualizations + let aux_source = JSON.stringify(element._source); + aux_source = aux_source.replace("wazuh-alerts", id); + aux_source = JSON.parse(aux_source); + + // Bulk source + let bulk_content = {}; + bulk_content[element._type] = aux_source; - temp["type"] = element._type; - temp.visualization.description = timestamp; + bulk_content["type"] = element._type; + bulk_content.visualization.description = timestamp; - body += JSON.stringify(temp) + "\n"; + body += JSON.stringify(bulk_content) + "\n"; } return body; } catch (error) { - console.log(error.message || error) + return (error.message || error); } - } - const createVis = async (req,res) => { + const createVis = async (req, res) => { try { if(!req.params.pattern || !req.params.tab || @@ -411,17 +409,13 @@ module.exports = (server, options) => { await elasticRequest.callWithInternalUser('bulk', { index: '.kibana', body: bulkBody }); await elasticRequest.callWithInternalUser('indices.refresh', { index: ['.kibana']}) - return res({aknowledge: true}); + return res({acknowledge: true}); } catch(error){ - console.log(error.message || error) return res({error:error.message || error}).code(500); } } - - - // Get index patterns list server.route({ method: 'GET',