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

[FIX] [HEALTH CHECK] Run template and fields checks depends on the app configuration #3783

Merged
merged 3 commits into from
Jan 11, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added new fields in Inventory table and Flyout Details [#3525](https://github.com/wazuh/wazuh-kibana-app/pull/3525)
- Added columns selector in agents table [#3691](https://github.com/wazuh/wazuh-kibana-app/pull/3691)
- Added a new workflow for create wazuh packages [#3742](https://github.com/wazuh/wazuh-kibana-app/pull/3742)
- Run `template` and `fields` checks in the health check depends on the app configuration [#3783](https://github.com/wazuh/wazuh-kibana-app/pull/3783)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ import { satisfyKibanaVersion } from '../../../../../common/semver';
export const checkIndexPatternService = (appConfig) => async (checkLogger: CheckLogger) => await checkPattern(appConfig, checkLogger);

const checkPattern = async (appConfig, checkLogger: CheckLogger) => {
if(appConfig.data['check.pattern'] === 'false'){
checkLogger.info('Index pattern check Disabled');
await checkIndexPatternObjectService(appConfig, checkLogger);
}else{
await checkIndexPatternObjectService(appConfig, checkLogger);
await checkTemplateService(appConfig, checkLogger);
if(satisfyKibanaVersion('<7.11')){
await checkFieldsService(appConfig, checkLogger);
if(!appConfig.data['checks.pattern']){
checkLogger.info('Check [pattern]: disabled. Some minimal tasks will be done.');
};
await checkIndexPatternObjectService(appConfig, checkLogger);
await checkTemplate(appConfig, checkLogger);
if(satisfyKibanaVersion('<7.11')){
await checkFields(appConfig, checkLogger);
};
};

const decoratorHealthCheckRunCheckEnabled = (checkKey, fn) => {
return async (appConfig: any, checkLogger: CheckLogger) => {
if(appConfig.data[`checks.${checkKey}`]){
await fn(appConfig, checkLogger);
}else{
checkLogger.info(`Check [${checkKey}]: disabled. Skipped.`);
};
}
return;
};

const checkTemplate = decoratorHealthCheckRunCheckEnabled('template', checkTemplateService);
const checkFields = decoratorHealthCheckRunCheckEnabled('fields', checkFieldsService);
2 changes: 1 addition & 1 deletion public/utils/config-equivalences.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const nameEquivalence = {
'checks.template': 'Index template',
'checks.api': 'API connection',
'checks.setup': 'API version',
'checks.fields': 'Know fields',
'checks.fields': 'Known fields',
'checks.metaFields': 'Remove meta fields',
'checks.timeFilter': 'Set time filter to 24h',
'checks.maxBuckets': 'Set max buckets to 200000',
Expand Down
1 change: 1 addition & 0 deletions server/lib/initial-wazuh-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const initialWazuhConfig: string = `---
# step once the Wazuh app starts. Values must to be true or false.
#checks.pattern : true
#checks.template: true
#checks.fields : true
#checks.api : true
#checks.setup : true
#checks.metaFields: true
Expand Down