Skip to content

Commit

Permalink
[8.8] [Synthetics] adjust alert timing (elastic#159511) (elastic#159515)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.8`:
- [[Synthetics] adjust alert timing
(elastic#159511)](elastic#159511)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dominique
Clarke","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-12T19:08:53Z","message":"[Synthetics]
adjust alert timing (elastic#159511)\n\n### Release note\r\n\r\nResolves
https://github.com/elastic/kibana/issues/158172\r\n\r\nFixes an issue
where alerting on Synthetics monitors could sometimes\r\nbecome
delayed.\r\n \r\n## Summary\r\nAdjust alerting timing to account for
alerting framework delays.\r\n\r\nAlert executors do not fire perfectly
on the specified interval (in our\r\ncase, every 1 minute). They are
typically delayed a few seconds, be can\r\nespecially delayed if the
customer does not have their alerting settings\r\nconfigured to scale
and there is no CPU available to take on the\r\nscheduled
task.\r\n\r\nThis PR accounts for small delays in the alerting
framework, by\r\nsubtracting an additional 1 minute from the `from`
value for our current\r\nstatus
query.","sha":"d549500d3433b67cd5ec1f7aa60e866d4fb699c1","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:uptime","v8.9.0","v8.8.2"],"number":159511,"url":"https://github.com/elastic/kibana/pull/159511","mergeCommit":{"message":"[Synthetics]
adjust alert timing (elastic#159511)\n\n### Release note\r\n\r\nResolves
https://github.com/elastic/kibana/issues/158172\r\n\r\nFixes an issue
where alerting on Synthetics monitors could sometimes\r\nbecome
delayed.\r\n \r\n## Summary\r\nAdjust alerting timing to account for
alerting framework delays.\r\n\r\nAlert executors do not fire perfectly
on the specified interval (in our\r\ncase, every 1 minute). They are
typically delayed a few seconds, be can\r\nespecially delayed if the
customer does not have their alerting settings\r\nconfigured to scale
and there is no CPU available to take on the\r\nscheduled
task.\r\n\r\nThis PR accounts for small delays in the alerting
framework, by\r\nsubtracting an additional 1 minute from the `from`
value for our current\r\nstatus
query.","sha":"d549500d3433b67cd5ec1f7aa60e866d4fb699c1"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159511","number":159511,"mergeCommit":{"message":"[Synthetics]
adjust alert timing (elastic#159511)\n\n### Release note\r\n\r\nResolves
https://github.com/elastic/kibana/issues/158172\r\n\r\nFixes an issue
where alerting on Synthetics monitors could sometimes\r\nbecome
delayed.\r\n \r\n## Summary\r\nAdjust alerting timing to account for
alerting framework delays.\r\n\r\nAlert executors do not fire perfectly
on the specified interval (in our\r\ncase, every 1 minute). They are
typically delayed a few seconds, be can\r\nespecially delayed if the
customer does not have their alerting settings\r\nconfigured to scale
and there is no CPU available to take on the\r\nscheduled
task.\r\n\r\nThis PR accounts for small delays in the alerting
framework, by\r\nsubtracting an additional 1 minute from the `from`
value for our current\r\nstatus
query.","sha":"d549500d3433b67cd5ec1f7aa60e866d4fb699c1"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dominique Clarke <[email protected]>
  • Loading branch information
kibanamachine and dominiqueclarke authored Jun 12, 2023
1 parent d185b71 commit d252e30
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import moment from 'moment';
import {
SavedObjectsClientContract,
SavedObjectsFindResult,
Expand Down Expand Up @@ -131,14 +131,17 @@ export class StatusRuleExecutor {
projectMonitorsCount,
monitorQueryIdToConfigIdMap,
} = await this.getMonitors();
const from = this.previousStartedAt
? moment(this.previousStartedAt).subtract(1, 'minute').toISOString()
: 'now-2m';

if (enabledMonitorQueryIds.length > 0) {
const currentStatus = await queryMonitorStatus(
this.esClient,
listOfLocations,
{
to: 'now',
from: this.previousStartedAt?.toISOString() ?? 'now-1m',
from,
},
enabledMonitorQueryIds,
monitorLocationMap,
Expand Down

0 comments on commit d252e30

Please sign in to comment.