mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.7`: - [[AO] Fix time range filter in alerts table (#153648)](https://github.com/elastic/kibana/pull/153648) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Maryam Saeidi","email":"maryam.saeidi@elastic.co"},"sourceCommit":{"committedDate":"2023-03-25T10:31:51Z","message":"[AO] Fix time range filter in alerts table (#153648)\n\nFixes #153284\r\n\r\n## Summary\r\n\r\nThis PR fixes the time range filter by using the `ALERT_TIME_RANGE`\r\ninstead of `TIMESTAMP`\r\ncc @tonyghiani \r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/12370520/227532946-087c85c5-1390-47eb-bf0a-bd7319a000a7.mov","sha":"62827b1aabb7db6d5f8b7987b492c768169d291e","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team: Actionable Observability","backport:prev-minor","v8.8.0"],"number":153648,"url":"https://github.com/elastic/kibana/pull/153648","mergeCommit":{"message":"[AO] Fix time range filter in alerts table (#153648)\n\nFixes #153284\r\n\r\n## Summary\r\n\r\nThis PR fixes the time range filter by using the `ALERT_TIME_RANGE`\r\ninstead of `TIMESTAMP`\r\ncc @tonyghiani \r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/12370520/227532946-087c85c5-1390-47eb-bf0a-bd7319a000a7.mov","sha":"62827b1aabb7db6d5f8b7987b492c768169d291e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/153648","number":153648,"mergeCommit":{"message":"[AO] Fix time range filter in alerts table (#153648)\n\nFixes #153284\r\n\r\n## Summary\r\n\r\nThis PR fixes the time range filter by using the `ALERT_TIME_RANGE`\r\ninstead of `TIMESTAMP`\r\ncc @tonyghiani \r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/12370520/227532946-087c85c5-1390-47eb-bf0a-bd7319a000a7.mov","sha":"62827b1aabb7db6d5f8b7987b492c768169d291e"}}]}] BACKPORT-->
This commit is contained in:
parent
1dce8b278a
commit
e7fd103354
10 changed files with 47 additions and 18 deletions
|
@ -91,7 +91,7 @@ describe('ObservabilityAlertSearchBar', () => {
|
|||
},
|
||||
{
|
||||
range: {
|
||||
'@timestamp': expect.objectContaining({
|
||||
'kibana.alert.time_range': expect.objectContaining({
|
||||
format: 'strict_date_optional_time',
|
||||
gte: mockedFrom,
|
||||
lte: mockedTo,
|
||||
|
@ -138,7 +138,7 @@ describe('ObservabilityAlertSearchBar', () => {
|
|||
},
|
||||
{
|
||||
range: {
|
||||
'@timestamp': expect.objectContaining({
|
||||
'kibana.alert.time_range': expect.objectContaining({
|
||||
format: 'strict_date_optional_time',
|
||||
gte: mockedFrom,
|
||||
lte: mockedTo,
|
||||
|
|
|
@ -6,7 +6,7 @@ Object {
|
|||
"filter": Array [
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
"kibana.alert.time_range": Object {
|
||||
"format": "strict_date_optional_time",
|
||||
"gte": "2022-08-30T15:23:23.721Z",
|
||||
"lte": "2022-08-30T15:38:28.171Z",
|
||||
|
@ -39,7 +39,7 @@ Object {
|
|||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
"kibana.alert.time_range": Object {
|
||||
"format": "strict_date_optional_time",
|
||||
"gte": "2022-08-30T15:23:23.721Z",
|
||||
"lte": "2022-08-30T15:38:28.171Z",
|
||||
|
@ -92,7 +92,7 @@ Object {
|
|||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
"kibana.alert.time_range": Object {
|
||||
"format": "strict_date_optional_time",
|
||||
"gte": "2022-08-30T15:23:23.721Z",
|
||||
"lte": "2022-08-30T15:38:28.171Z",
|
||||
|
@ -131,7 +131,7 @@ Object {
|
|||
},
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
"kibana.alert.time_range": Object {
|
||||
"format": "strict_date_optional_time",
|
||||
"gte": "2022-08-30T15:23:23.721Z",
|
||||
"lte": "2022-08-30T15:38:28.171Z",
|
||||
|
@ -152,7 +152,7 @@ Object {
|
|||
"filter": Array [
|
||||
Object {
|
||||
"range": Object {
|
||||
"@timestamp": Object {
|
||||
"kibana.alert.time_range": Object {
|
||||
"format": "strict_date_optional_time",
|
||||
"gte": "2022-08-30T15:23:23.721Z",
|
||||
"lte": "2022-08-30T15:38:28.171Z",
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
|
||||
import { buildEsQuery as kbnBuildEsQuery, TimeRange, Query } from '@kbn/es-query';
|
||||
import { TIMESTAMP } from '@kbn/rule-data-utils';
|
||||
import { ALERT_TIME_RANGE } from '@kbn/rule-data-utils';
|
||||
import { getTime } from '@kbn/data-plugin/common';
|
||||
|
||||
export function buildEsQuery(timeRange: TimeRange, kuery?: string, queries: Query[] = []) {
|
||||
const timeFilter =
|
||||
timeRange &&
|
||||
getTime(undefined, timeRange, {
|
||||
fieldName: TIMESTAMP,
|
||||
fieldName: ALERT_TIME_RANGE,
|
||||
});
|
||||
const filtersToUse = timeFilter ? [timeFilter] : [];
|
||||
const kueryFilter = kuery ? [{ query: kuery, language: 'kuery' }] : [];
|
||||
|
|
Binary file not shown.
|
@ -202,6 +202,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
@ -470,6 +474,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
@ -714,6 +722,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
@ -752,4 +764,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,11 @@ const DATE_WITH_DATA = {
|
|||
rangeTo: '2021-10-20T13:36:22.109Z',
|
||||
};
|
||||
|
||||
const DATE_WITHOUT_DATA = {
|
||||
rangeFrom: '2021-09-18T13:36:22.109Z',
|
||||
rangeTo: '2021-09-20T13:36:22.109Z',
|
||||
};
|
||||
|
||||
const ALERTS_TITLE = 'Alerts';
|
||||
const ALERTS_ACCORDION_SELECTOR = `accordion-${ALERTS_TITLE}`;
|
||||
const ALERTS_SECTION_BUTTON_CSS_SELECTOR = `[data-test-subj=${ALERTS_ACCORDION_SELECTOR}] button.euiAccordion__button`;
|
||||
|
@ -38,6 +43,15 @@ export function ObservabilityOverviewCommonProvider({
|
|||
);
|
||||
};
|
||||
|
||||
const navigateToOverviewPageWithoutAlerts = async () => {
|
||||
return await pageObjects.common.navigateToUrlWithBrowserHistory(
|
||||
'observability',
|
||||
'/overview',
|
||||
`?rangeFrom=${DATE_WITHOUT_DATA.rangeFrom}&rangeTo=${DATE_WITHOUT_DATA.rangeTo}`,
|
||||
{ ensureCurrentUrl: false }
|
||||
);
|
||||
};
|
||||
|
||||
const navigateToOverviewPage = async () => {
|
||||
await pageObjects.common.navigateToUrlWithBrowserHistory(
|
||||
'observability',
|
||||
|
@ -81,6 +95,7 @@ export function ObservabilityOverviewCommonProvider({
|
|||
return {
|
||||
getAlertsTableNoDataOrFail,
|
||||
navigateToOverviewPageWithAlerts,
|
||||
navigateToOverviewPageWithoutAlerts,
|
||||
navigateToOverviewPage,
|
||||
openAlertsSectionAndWaitToAppear,
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
|
|||
const observability = getService('observability');
|
||||
const retry = getService('retry');
|
||||
|
||||
describe('Observability alerts / Add to case', function () {
|
||||
describe('Observability alerts / Add to case >', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
||||
before(async () => {
|
||||
|
|
|
@ -16,7 +16,7 @@ const RECOVERED_ALERTS = 30;
|
|||
export default ({ getService }: FtrProviderContext) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
|
||||
describe('alert status filter', function () {
|
||||
describe('Alert status filter >', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
||||
const observability = getService('observability');
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import { ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils';
|
||||
import { FtrProviderContext } from '../../../../ftr_provider_context';
|
||||
import { asyncForEach } from '../../helpers';
|
||||
|
||||
|
@ -20,7 +21,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
const esArchiver = getService('esArchiver');
|
||||
const find = getService('find');
|
||||
|
||||
describe('Observability alerts', function () {
|
||||
describe('Observability alerts >', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
||||
const testSubjects = getService('testSubjects');
|
||||
|
@ -49,12 +50,12 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
|
||||
describe('Alerts table', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs');
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/infra/simple_logs');
|
||||
await observability.alerts.common.navigateToTimeWithData();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs');
|
||||
await esArchiver.unload('x-pack/test/functional/es_archives/infra/simple_logs');
|
||||
});
|
||||
|
||||
it('Renders the table', async () => {
|
||||
|
@ -113,8 +114,9 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
|
||||
it('Correctly applies date picker selections', async () => {
|
||||
await retry.try(async () => {
|
||||
await observability.alerts.common.setAlertStatusFilter(ALERT_STATUS_RECOVERED);
|
||||
await (await testSubjects.find('superDatePickerToggleQuickMenuButton')).click();
|
||||
// We shouldn't expect any data for the last 15 minutes
|
||||
// We shouldn't expect any recovered alert for the last 15 minutes
|
||||
await (await testSubjects.find('superDatePickerCommonlyUsed_Last_15 minutes')).click();
|
||||
await observability.alerts.common.getNoDataStateOrFail();
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ const ALL_ALERTS = 10;
|
|||
export default ({ getService }: FtrProviderContext) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
|
||||
describe('Observability overview', function () {
|
||||
describe('Observability overview >', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
||||
const observability = getService('observability');
|
||||
|
@ -29,7 +29,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
|
||||
describe('Without alerts', function () {
|
||||
it('navigate and open alerts section', async () => {
|
||||
await observability.overview.common.navigateToOverviewPage();
|
||||
await observability.overview.common.navigateToOverviewPageWithoutAlerts();
|
||||
await observability.overview.common.openAlertsSectionAndWaitToAppear();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue