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 statistics visualizations when cluster mode is disabled #6352

Merged
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 @@ -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
Loading