Skip to content

Commit

Permalink
fix(reporting): fix agent inventory data report
Browse files Browse the repository at this point in the history
  • Loading branch information
Desvelao committed Mar 11, 2024
1 parent 4a780b8 commit e39c128
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
25 changes: 17 additions & 8 deletions plugins/main/public/components/common/modules/main-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { AppState } from '../../../react-services/app-state';
import { ReportingService } from '../../../react-services/reporting';
import { WAZUH_MODULES } from '../../../../common/wazuh-modules';
import { AgentInfo } from '../../common/welcome/agents-info';
import { getAngularModule, getCore } from '../../../kibana-services';
import {
getAngularModule,
getCore,
getDataPlugin,
} from '../../../kibana-services';
import { compose } from 'redux';
import { withGlobalBreadcrumb } from '../hocs';
import { endpointSummary } from '../../../utils/applications';
Expand All @@ -46,7 +50,7 @@ export class MainModuleAgent extends Component {
constructor(props) {
super(props);
this.reportingService = new ReportingService();
this.filterHandler = new FilterHandler(AppState.getCurrentPattern());
this.filterHandler = new FilterHandler(AppState.getCurrentPattern()); //
this.state = {
selectView: false,
loadingReport: false,
Expand All @@ -70,14 +74,19 @@ export class MainModuleAgent extends Component {
{}
).id || false;
if (this.props.section === 'syscollector' && agent) {
syscollectorFilters.push(this.filterHandler.managerQuery(agent, true));
syscollectorFilters.push(this.filterHandler.managerQuery(agent, true)); // This could be adding a filter with a wrong index name when the selected index has different title and id. Currently the index property is not used in the report of the Inventory data.
syscollectorFilters.push(this.filterHandler.agentQuery(agent));
}
await this.reportingService.startVis2Png(
this.props.section,
agent,
syscollectorFilters.length ? syscollectorFilters : null,
);
await this.reportingService.startVis2Png(this.props.section, agent, {
filters: syscollectorFilters,
time: {
from: 'now-1d/d',
to: 'now',
},
indexPattern: await getDataPlugin().indexPatterns.get(
AppState.getCurrentPattern(),
),
});
this.setState({ loadingReport: false });
}

Expand Down
7 changes: 4 additions & 3 deletions plugins/main/public/react-services/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ export class ReportingService {
return store.getState().reportingReducers?.dataSourceSearchContext;
}

async startVis2Png(tab, agents = false, syscollectorFilters = null) {
async startVis2Png(tab, agents = false, searchContext = null) {
try {
this.$rootScope.reportBusy = true;
this.$rootScope.reportStatus = 'Generating report...0%';
this.$rootScope.$applyAsync();
const dataSourceContext = await this.getDataSourceSearchContext();
const dataSourceContext =
searchContext || (await this.getDataSourceSearchContext());
const visualizations = await this.getVisualizationsFromDOM();
const dataplugin = await getDataPlugin();
const serverSideQuery = dataplugin.query.getOpenSearchQuery();
Expand All @@ -99,7 +100,7 @@ export class ReportingService {
serverSideQuery, // Used for applying the same filters on the server side requests
filters: dataSourceContext.filters,
time: dataSourceContext.time,
searchBar: dataSourceContext.query?.query || '',
searchBar: dataSourceContext?.query?.query || '',
tables: [], // TODO: check is this is used
tab,
section: agents ? 'agents' : 'overview',
Expand Down

0 comments on commit e39c128

Please sign in to comment.