diff --git a/x-pack/plugins/synthetics/common/constants/client_defaults.ts b/x-pack/plugins/synthetics/common/constants/client_defaults.ts index 161ce5fb3635d..41a5f7c64abed 100644 --- a/x-pack/plugins/synthetics/common/constants/client_defaults.ts +++ b/x-pack/plugins/synthetics/common/constants/client_defaults.ts @@ -77,7 +77,7 @@ export const getTimeSpanFilter = () => ({ range: { 'monitor.timespan': { lte: moment().toISOString(), - gte: moment().subtract(5, 'minutes').toISOString(), + gte: moment().subtract(20, 'minutes').toISOString(), }, }, }); diff --git a/x-pack/plugins/synthetics/common/requests/get_certs_request_body.ts b/x-pack/plugins/synthetics/common/requests/get_certs_request_body.ts index b7e7006cc1b05..e6adc1cde8e23 100644 --- a/x-pack/plugins/synthetics/common/requests/get_certs_request_body.ts +++ b/x-pack/plugins/synthetics/common/requests/get_certs_request_body.ts @@ -21,7 +21,7 @@ enum SortFields { export const DEFAULT_SORT = 'not_after'; export const DEFAULT_DIRECTION = 'asc'; export const DEFAULT_SIZE = 20; -export const DEFAULT_FROM = 'now-5m'; +export const DEFAULT_FROM = 'now-20m'; export const DEFAULT_TO = 'now'; export const getCertsRequestBody = ({ diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts index 800692d284726..6a955c746c101 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts @@ -6,12 +6,14 @@ */ import { useSelector } from 'react-redux'; -import moment from 'moment'; import { useMemo } from 'react'; import { useEsSearch } from '@kbn/observability-plugin/public'; import { selectEncryptedSyntheticsSavedMonitors } from '../../../state'; import { Ping } from '../../../../../../common/runtime_types'; -import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../../../common/constants/client_defaults'; +import { + EXCLUDE_RUN_ONCE_FILTER, + getTimeSpanFilter, +} from '../../../../../../common/constants/client_defaults'; import { useSyntheticsRefreshContext } from '../../../contexts/synthetics_refresh_context'; import { useInlineErrorsCount } from './use_inline_errors_count'; import { SYNTHETICS_INDEX_PATTERN } from '../../../../../../common/constants'; @@ -51,14 +53,7 @@ export const getInlineErrorFilters = () => [ ], }, }, - { - range: { - 'monitor.timespan': { - lte: moment().toISOString(), - gte: moment().subtract(5, 'minutes').toISOString(), - }, - }, - }, + getTimeSpanFilter(), EXCLUDE_RUN_ONCE_FILTER, ]; diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx index 5d5aad7a37a87..efa1147b5e50f 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx @@ -51,7 +51,7 @@ describe('useInlineErrors', function () { { range: { 'monitor.timespan': { - gte: '2022-01-01T23:55:00.000Z', + gte: '2022-01-01T23:40:00.000Z', lte: '2022-01-02T00:00:00.000Z', }, }, diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts index 9086ce641870d..1bdd7e287461c 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts @@ -6,12 +6,14 @@ */ import { useSelector } from 'react-redux'; -import moment from 'moment'; import { useMemo } from 'react'; import { useEsSearch } from '@kbn/observability-plugin/public'; import { monitorManagementListSelector } from '../../../state/selectors'; import { Ping } from '../../../../../common/runtime_types'; -import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../../common/constants/client_defaults'; +import { + EXCLUDE_RUN_ONCE_FILTER, + getTimeSpanFilter, +} from '../../../../../common/constants/client_defaults'; import { useUptimeRefreshContext } from '../../../contexts/uptime_refresh_context'; import { useInlineErrorsCount } from './use_inline_errors_count'; import { SYNTHETICS_INDEX_PATTERN } from '../../../../../common/constants'; @@ -51,14 +53,7 @@ export const getInlineErrorFilters = () => [ ], }, }, - { - range: { - 'monitor.timespan': { - lte: moment().toISOString(), - gte: moment().subtract(5, 'minutes').toISOString(), - }, - }, - }, + getTimeSpanFilter(), EXCLUDE_RUN_ONCE_FILTER, ]; diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx index 4c9d555a5cdec..468c63768442b 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx @@ -51,7 +51,7 @@ describe('useInlineErrorsCount', function () { { range: { 'monitor.timespan': { - gte: '2022-01-01T23:55:00.000Z', + gte: '2022-01-01T23:40:00.000Z', lte: '2022-01-02T00:00:00.000Z', }, }, diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.test.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.test.ts index 034f3dbd1f973..912e354910908 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.test.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.test.ts @@ -78,14 +78,14 @@ describe(QueryContext, () => { }); describe('timespanClause()', () => { - it('should always cover the last 5m', () => { + it('should always cover the last 20m', () => { // 5m expected range between GTE and LTE in the response - // since timespan is hardcoded to 5m + // since timespan is hardcoded to 20m expect(qc.timespanClause()).toEqual({ range: { 'monitor.timespan': { - // end date minus 5m - gte: new Date(Date.parse(rangeEnd) - 5 * 60 * 1000).toISOString(), + // end date minus 20 + gte: new Date(Date.parse(rangeEnd) - 20 * 60 * 1000).toISOString(), lte: rangeEnd, }, }, diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.ts index 345dd4a1e4dbe..0c88a2527aa4b 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/query_context.ts @@ -96,7 +96,7 @@ export class QueryContext { // which is a bit dicey since we may have data that predates this field existing, // or we may have data that has it, but a slow ingestion process. timespanClause() { - // We subtract 5m from the start to account for data that shows up late, + // We subtract 20m from the start to account for data that shows up late, // for instance, with a large value for the elasticsearch refresh interval // setting it lower can work very well on someone's laptop, but with real world // latencies and slowdowns that's dangerous. Making this value larger makes things @@ -107,7 +107,7 @@ export class QueryContext { return { range: { 'monitor.timespan': { - gte: 'now-5m', + gte: 'now-20m', lte: 'now', }, }, @@ -115,7 +115,7 @@ export class QueryContext { } const tsEnd = parseRelativeDate(this.dateRangeEnd, { roundUp: true })!; - const tsStart = moment(tsEnd).subtract(5, 'minutes'); + const tsStart = moment(tsEnd).subtract(20, 'minutes'); return { range: {