Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new config to hide the manager's alerts #2102

Merged
merged 4 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion public/kibana-integrations/kibana-discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import { FilterStateManager } from 'plugins/data';
import { buildServices } from 'plugins/kibana/discover/build_services';
import { npStart } from 'ui/new_platform';
import { pluginInstance } from 'plugins/kibana/discover/index';
import { WazuhConfig } from '../react-services/wazuh-config';

const fetchStatuses = {
UNINITIALIZED: 'uninitialized',
Expand Down Expand Up @@ -129,6 +130,7 @@ function discoverController(
timefilter,
toastNotifications,
} = getServices();
const wazuhConfig = new WazuhConfig();
//////
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
Expand Down Expand Up @@ -434,13 +436,37 @@ function discoverController(
subscribeWithScope($scope, filterManager.getUpdates$(), {
next: () => {
$scope.filters = filterManager.filters;
// Wazuh. Hides the alerts of the '000' agent if it is in the configuration
const buildFilters = () => {
const { hideManagerAlerts } = wazuhConfig.getConfig();
if (hideManagerAlerts){
return [{
"meta": {
"alias":null,
"disabled":false,
"key":"agent.id",
"negate":true,
"params":{"query":"000"},
"type":"phrase",
"index":"wazuh-alerts-3.x-*"
},
"query":{"match_phrase":{"agent.id":"000"}},
"$state": {"store":"appState"}
}];
}
return [];
}

$scope.updateDataSource().then(function () {
/////////////////////////////// WAZUH ///////////////////////////////////
if (!filtersAreReady()) return;
discoverPendingUpdates.removeAll();
discoverPendingUpdates.addItem(
$state.query,
$scope.filters
[
...$scope.filters,
...buildFilters() // Hide '000' agent
]
);
if ($location.search().tab != 'configuration') {
loadedVisualizations.removeAll();
Expand Down
29 changes: 13 additions & 16 deletions public/kibana-integrations/kibana-visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ app.directive('kbnVis', function () {
const timeFilterSeconds = calculateTimeFilterSeconds(
timefilter.getTime()
);
const timeRange = isAgentStatus && timeFilterSeconds < 900
? { from: 'now-15m', to: 'now', mode: 'quick' }
: timefilter.getTime();
const filters = isAgentStatus ? [] : discoverList[1] || [];
const query = !isAgentStatus ? discoverList[0] : {};

const visInput = {
timeRange,
filters,
query,
}

if (!factory) {
factory = embeddables.getEmbeddableFactory('visualization');
Expand All @@ -120,14 +131,7 @@ app.directive('kbnVis', function () {

visHandler = await factory.createFromObject(
visualization,
{
timeRange:
isAgentStatus && timeFilterSeconds < 900
? { from: 'now-15m', to: 'now', mode: 'quick' }
: timefilter.getTime(),
filters: isAgentStatus ? [] : discoverList[1] || [],
query: !isAgentStatus ? discoverList[0] : {}
}
visInput
);
visHandler.render($(`[vis-id="'${$scope.visID}'"]`)[0]).then(renderComplete);
visHandlers.addItem(visHandler);
Expand All @@ -136,14 +140,7 @@ app.directive('kbnVis', function () {
} else if (rendered && !deadField) {
// There's a visualization object -> just update its filters
$rootScope.rendered = true;
visHandler.updateInput({
timeRange:
isAgentStatus && timeFilterSeconds < 900
? { from: 'now-15m', to: 'now', mode: 'quick' }
: timefilter.getTime(),
filters: isAgentStatus ? [] : discoverList[1] || [],
query: !isAgentStatus ? discoverList[0] : {}
});
visHandler.updateInput(visInput);
setSearchSource(discoverList);
}
}
Expand Down
1 change: 1 addition & 0 deletions public/services/resolves/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function getWzConfig($q, genericReq, wazuhConfig) {
'wazuh.monitoring.creation': 'd',
'wazuh.monitoring.pattern': 'wazuh-monitoring-3.x-*',
admin: true,
'hideManagerAlerts': false,
'logs.level': 'info'
};

Expand Down
2 changes: 2 additions & 0 deletions public/utils/config-equivalences.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const configEquivalences = {
'Default index pattern to use on the app for Wazuh monitoring.',
admin:
'Enable or disable administrator requests to the Wazuh API when using the app.',
hideManagerAlerts:
'Hide the alerts of the manager in all dashboards and discover',
'logs.level':
'Set the app logging level, allowed values are info and debug. Default is info.'
};
4 changes: 4 additions & 0 deletions wazuh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
# ------------------------------- App privileges --------------------------------
#admin: true
#
# ---------------------------- Hide manager alerts ------------------------------
# Hide the alerts of the manager in all dashboards and discover
#hideManagerAlerts: false
#
# ------------------------------- App logging level -----------------------------
# Set the logging level for the Wazuh App log files.
# Default value: info
Expand Down