Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
increase uptime/synthetics timespan filter from -5m to -20m (elastic#…
Browse files Browse the repository at this point in the history
…144769)

Co-authored-by: shahzad31 <[email protected]>
Resolves elastic#144097
  • Loading branch information
dominiqueclarke authored Nov 18, 2022
1 parent 7419826 commit 9b87a14
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -51,14 +53,7 @@ export const getInlineErrorFilters = () => [
],
},
},
{
range: {
'monitor.timespan': {
lte: moment().toISOString(),
gte: moment().subtract(5, 'minutes').toISOString(),
},
},
},
getTimeSpanFilter(),
EXCLUDE_RUN_ONCE_FILTER,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -51,14 +53,7 @@ export const getInlineErrorFilters = () => [
],
},
},
{
range: {
'monitor.timespan': {
lte: moment().toISOString(),
gte: moment().subtract(5, 'minutes').toISOString(),
},
},
},
getTimeSpanFilter(),
EXCLUDE_RUN_ONCE_FILTER,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -107,15 +107,15 @@ export class QueryContext {
return {
range: {
'monitor.timespan': {
gte: 'now-5m',
gte: 'now-20m',
lte: 'now',
},
},
};
}

const tsEnd = parseRelativeDate(this.dateRangeEnd, { roundUp: true })!;
const tsStart = moment(tsEnd).subtract(5, 'minutes');
const tsStart = moment(tsEnd).subtract(20, 'minutes');

return {
range: {
Expand Down

0 comments on commit 9b87a14

Please sign in to comment.