-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce time range on 'Show received messages' button (#5621)
* Reduce timerange for 'Show received messages' button The default for a search when clicking on that button was to search for all messages. Executing this search can put a significant load on ES/OS and also can lead to OOM situations. Instead of searching all messages, we are searching only messages in the past 5 minutes and the next future hour. Fixes #5620 Fixes #4533 Fixes #10260 * Changelog * Use +-26 hours for the time range and fix linter hints * Use same timerange for Sidecars 'Show Messages' button * Update changelog * move recentMessagesTimeRange to util * Spelling * Update issue-5620.toml --------- Co-authored-by: Ousmane Samba <[email protected]>
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "c" | ||
message = "Shorten time range of show received messages buttons on inputs, forwarder profiles and sidecars." | ||
|
||
issues = ["5620"] | ||
pulls = ["5621"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
|
||
import type { AbsoluteRangeQueryParameter } from 'views/logic/TimeRange'; | ||
|
||
/** | ||
* Creates an absolute time range that can be used to look up recently received messages. | ||
* It accommodates for the eventuality that messages can have timestamps from the future | ||
* due to wrong timezone parsing or wrong system clocks. | ||
*/ | ||
const recentMessagesTimeRange = (): AbsoluteRangeQueryParameter => { | ||
const now = Date.now(); | ||
// The biggest possible time difference on earth is 26 hours. | ||
// It's between Kiribati (UTC+14) and the Howland Islands (UTC-12) | ||
// So we are going to create an absolute range | ||
// from 26 hours in the past to 26 hours into the future. | ||
const fromDate = new Date(now - 26 * 60 * 60000).toISOString(); | ||
const toDate = new Date(now + 26 * 60 * 60000).toISOString(); | ||
|
||
return { rangetype: 'absolute', from: fromDate, to: toDate }; | ||
}; | ||
|
||
export default recentMessagesTimeRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters