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

Index pattern on the filters of home KPI links #6777

Merged
merged 2 commits into from
Jun 19, 2024
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
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)
asteriscos marked this conversation as resolved.
Show resolved Hide resolved

## 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
Loading