Skip to content

Commit

Permalink
Fix statistics visualizations when cluster mode is disabled (#6352)
Browse files Browse the repository at this point in the history
* Fix statistics visualizations when cluster mode is disabled

* Update CHANGELOG

* Fix incorrect uppercase

---------

Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
  • Loading branch information
lucianogorza and asteriscos authored Jan 24, 2024
1 parent e02df5b commit bcb7853
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 339 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed script to install agents on macOS when you have password to deploy [#6305](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6305)
- Fixed a problem with the address validation on Deploy New Agent [#6327](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6327)
- Fixed a typo in an abbreviation for Fully Qualified Domain Name [#6333](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6333)
- Fixed server statistics when cluster mode is disabled [#6352](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6352)
- Fixed unnecessary scrolling in Vulnerability Inventory table [#6345](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6345)
- Fixed wrong value at server stat Archives queue usage [#6342](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6342)
- Fixed the inventory data table when maximized and the docked menu [#6344](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6344)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui';
import { useBuildStatisticsVisualizations } from './hooks';

export function WzStatisticsAnalysisd({
isClusterMode,
clusterNodeSelected,
refreshVisualizations,
}) {
Expand All @@ -35,7 +36,11 @@ export function WzStatisticsAnalysisd({
<div style={{ height: '343px' }}>
<WzReduxProvider>
<KibanaVis
visID={'Wazuh-App-Statistics-Analysisd-Events-By-Node'}
visID={
isClusterMode
? 'Wazuh-App-Statistics-Analysisd-Events-By-Node'
: 'Wazuh-App-Statistics-Analysisd-Events'
}
tab={'statistics'}
></KibanaVis>
</WzReduxProvider>
Expand All @@ -47,15 +52,17 @@ export function WzStatisticsAnalysisd({
<EuiFlexItem>
<EuiPanel style={{ height: '400px' }}>
<EuiFlexGroup>
<EuiFlexItem>Events Dropped</EuiFlexItem>
<EuiFlexItem>Events dropped</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup>
<EuiFlexItem>
<div style={{ height: '343px' }}>
<WzReduxProvider>
<KibanaVis
visID={
'Wazuh-App-Statistics-Analysisd-Events-Dropped-By-Node'
isClusterMode
? 'Wazuh-App-Statistics-Analysisd-Events-Dropped-By-Node'
: 'Wazuh-App-Statistics-Analysisd-Events-Dropped'
}
tab={'statistics'}
></KibanaVis>
Expand Down Expand Up @@ -93,7 +100,7 @@ export function WzStatisticsAnalysisd({
<EuiFlexItem>
<EuiPanel style={{ height: '400px' }}>
<EuiFlexGroup>
<EuiFlexItem>Events Decoded summary</EuiFlexItem>
<EuiFlexItem>Events decoded summary</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ import {
EuiProgress,
} from '@elastic/eui';

import { clusterNodes } from '../configuration/utils/wz-fetch';
import { clusterReq, clusterNodes } from '../configuration/utils/wz-fetch';
import { WzStatisticsRemoted } from './statistics-dashboard-remoted';
import { WzStatisticsAnalysisd } from './statistics-dashboard-analysisd';
import { WzDatePicker } from '../../../../../components/wz-date-picker/wz-date-picker';
import { AppNavigate } from '../../../../../react-services/app-navigate';
import { compose } from 'redux';
import {
withGuard,
Expand Down Expand Up @@ -85,17 +84,32 @@ export class WzStatisticsOverview extends Component {
async componentDidMount() {
this._isMounted = true;
try {
const data = await clusterNodes();
const nodes = data.data.data.affected_items.map(item => {
return { value: item.name, text: `${item.name} (${item.type})` };
});
nodes.unshift({ value: 'all', text: 'All' });
this.setState({
clusterNodes: nodes,
clusterNodeSelected: nodes[0].value,
});
// try if it is a cluster
const clusterStatus = await clusterReq();
const isClusterMode =
clusterStatus.data.data.enabled === 'yes' &&
clusterStatus.data.data.running === 'yes';
if (isClusterMode) {
const data = await clusterNodes();
const nodes = data.data.data.affected_items.map(item => {
return { value: item.name, text: `${item.name} (${item.type})` };
});
nodes.unshift({ value: 'all', text: 'All' });
this.setState({
isClusterMode,
clusterNodes: nodes,
clusterNodeSelected: nodes[0].value,
});
} else {
this.setState({
isClusterMode,
clusterNodes: [],
clusterNodeSelected: 'all',
});
}
} catch (error) {
this.setState({
isClusterMode: undefined,
clusterNodes: [],
clusterNodeSelected: 'all',
});
Expand Down Expand Up @@ -253,6 +267,7 @@ export class WzStatisticsOverview extends Component {
/>
<EuiSpacer size={'m'} />
<WzStatisticsAnalysisd
isClusterMode={this.state.isClusterMode}
clusterNodeSelected={this.state.clusterNodeSelected}
refreshVisualizations={this.state.refreshVisualizations}
/>
Expand Down
6 changes: 5 additions & 1 deletion plugins/main/server/controllers/wazuh-elastic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,11 @@ export class WazuhElasticCtrl {
const filter =
bulk_content.visualization.kibanaSavedObjectMeta.searchSourceJSON.replace(
'"filter":[]',
'"filter":[{"match_phrase":{"apiName":"' + master_node + '"}}]',
`"filter":[{"bool":{"must":[{"match":{"apiName":"'${master_node}'"}}${
name && name !== 'all'
? `,{"match":{"nodeName":"'${name}'"}}`
: ''
}]}}]`,
);

bulk_content.visualization.kibanaSavedObjectMeta.searchSourceJSON =
Expand Down
Loading

0 comments on commit bcb7853

Please sign in to comment.