Skip to content

Commit

Permalink
Index pattern on the filters of home KPI links (#6777)
Browse files Browse the repository at this point in the history
* fix(home): index pattern on the filters of KPI links

* changelog: add pull request entry
  • Loading branch information
Desvelao authored Jun 19, 2024
1 parent 97a1825 commit 29c9758
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All notable changes to the Wazuh app project will be documented in this file.

- Support for Wazuh 4.8.1

### Fixed

- Fixed home KPI links with custom or index pattern whose title is different to the id [#6777](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6777)

## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 12

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Last24HoursAlerts {
field: string;
name: string;
};
indexPatternName: string;
indexPatternId: string;
}

/**
Expand Down Expand Up @@ -44,7 +44,7 @@ export const getLast24HoursAlerts = async (
field: isCluster ? 'cluster.name' : 'manager.name',
name: clusterValue,
},
indexPatternName: currentIndexPattern.title,
indexPatternId: currentIndexPattern.id,
};
} catch (error) {
return Promise.reject(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function LastAlertsStat({ severity }: { severity: string }) {
useEffect(() => {
const getCountLastAlerts = async () => {
try {
const { indexPatternName, cluster, count } = await getLast24HoursAlerts(
const { indexPatternId, cluster, count } = await getLast24HoursAlerts(
severityLabel[severity].ruleLevelRange,
);
setCountLastAlerts(count);
Expand All @@ -81,13 +81,13 @@ export function LastAlertsStat({ severity }: { severity: string }) {
const destURL = core.application.getUrlForApp(discoverLocation.app, {
path: `${
discoverLocation.basePath
}#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternName}',view:discover))&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternName}',key:${
}#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternId}',view:discover))&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternId}',key:${
cluster.field
},negate:!f,params:(query:${
cluster.name
}),type:phrase),query:(match_phrase:(${cluster.field}:${
cluster.name
}))),('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'wazuh-alerts-*',key:rule.level,negate:!f,params:(gte:${
}))),('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternId}',key:rule.level,negate:!f,params:(gte:${
severityLabel[severity].ruleLevelRange.minRuleLevel
},lte:${
severityLabel[severity].ruleLevelRange.maxRuleLevel || '!n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jest.mock(
}),
);

jest.mock('react-use/lib/useObservable', () => () => { });
jest.mock('react-use/lib/useObservable', () => () => {});
jest.mock('./last-alerts-stat/last-alerts-service', () => ({
getLast24HoursAlerts: jest.fn().mockReturnValue({
count: 100,
cluster: {
field: 'cluster.name',
name: 'master',
},
indexPatternName: 'wazuh-alerts-*',
indexPatternId: 'wazuh-alerts-*',
}),
}));

Expand All @@ -43,14 +43,14 @@ jest.mock('../../../kibana-services', () => ({
getUrlForApp: () => 'http://url',
},
uiSettings: {
get: () => true
}
get: () => true,
},
}),
}));

jest.mock('../../../react-services/common-services', () => ({
getErrorOrchestrator: () => ({
handleError: options => { },
handleError: options => {},
}),
}));

Expand Down

0 comments on commit 29c9758

Please sign in to comment.