mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Infrastructure UI] Fix time range filter in alerts query (#153863)
## 📓 Summary Closes #153741 This PR fixes the time range filter by using the `kibana.alert.time_range` field instead of `@timestamp`. ## 🧪 Testing - Navigate to Hosts View - Create an Inventory Alert that will trigger immediately - Refresh the search until some alerts are triggered - Play with relative time range (eg. 15 min ago -> 2 min ago) to verify alerts appears correctly --------- Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
This commit is contained in:
parent
a1fccfd880
commit
77ce676518
3 changed files with 14 additions and 2 deletions
|
@ -7,7 +7,7 @@
|
|||
import { useCallback, useMemo, useState } from 'react';
|
||||
import createContainer from 'constate';
|
||||
import { getTime } from '@kbn/data-plugin/common';
|
||||
import { TIMESTAMP } from '@kbn/rule-data-utils';
|
||||
import { ALERT_TIME_RANGE } from '@kbn/rule-data-utils';
|
||||
import { BoolQuery, buildEsQuery, Filter } from '@kbn/es-query';
|
||||
import { SnapshotNode } from '../../../../../common/http_api';
|
||||
import { useUnifiedSearchContext } from './use_unified_search';
|
||||
|
@ -77,7 +77,7 @@ const createAlertsEsQuery = ({
|
|||
};
|
||||
|
||||
const createDateFilter = (date: HostsState['dateRange']) =>
|
||||
getTime(undefined, date, { fieldName: TIMESTAMP });
|
||||
getTime(undefined, date, { fieldName: ALERT_TIME_RANGE });
|
||||
|
||||
const createAlertStatusFilter = (status: AlertStatus = 'all'): Filter | null =>
|
||||
ALERT_STATUS_QUERY[status] ? { query: ALERT_STATUS_QUERY[status], meta: {} } : null;
|
||||
|
|
Binary file not shown.
|
@ -209,6 +209,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
@ -484,6 +488,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
@ -735,6 +743,10 @@
|
|||
"system_status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"time_range": {
|
||||
"type": "date_range",
|
||||
"format": "epoch_millis||strict_date_optional_time"
|
||||
},
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue