-
Notifications
You must be signed in to change notification settings - Fork 253
fix: alerting time range filtering bug #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
172bc4b
feat: support dateRangeEndInclusive flag (timeFilterExpr)
wrn14897 57711a3
style: move formatDate to common-utils
wrn14897 3394a12
style: move tests
wrn14897 50dfb4e
docs: add changeset
wrn14897 f094e7c
fix: tests
wrn14897 8048923
test: multi windows
wrn14897 aaad401
docs: add changeset
wrn14897 c39ffeb
Merge branch 'v2' into warren/fix-alert-select-time-range-bug
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
--- | ||
"@hyperdx/common-utils": patch | ||
"@hyperdx/api": patch | ||
"@hyperdx/app": patch | ||
--- | ||
|
||
fix: alerting time range filtering bug |
This file contains hidden or 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 @@ | ||
--- | ||
"@hyperdx/common-utils": patch | ||
--- | ||
|
||
feat: support 'dateRangeEndInclusive' in timeFilterExpr |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
ChartConfigWithOptDateRange, | ||
DisplayType, | ||
} from '@hyperdx/common-utils/dist/types'; | ||
import { formatDate } from '@hyperdx/common-utils/dist/utils'; | ||
import * as fns from 'date-fns'; | ||
import Handlebars, { HelperOptions } from 'handlebars'; | ||
import _ from 'lodash'; | ||
|
@@ -477,6 +478,11 @@ export const renderAlertTemplate = async ({ | |
); | ||
}; | ||
|
||
const timeRangeMessage = `Time Range (UTC): [${formatDate(view.startTime, { | ||
isUTC: true, | ||
})} - ${formatDate(view.endTime, { | ||
isUTC: true, | ||
})})`; | ||
let rawTemplateBody; | ||
|
||
// TODO: support advanced routing with template engine | ||
|
@@ -538,7 +544,7 @@ ${value} lines found, expected ${ | |
alert.thresholdType === AlertThresholdType.ABOVE | ||
? 'less than' | ||
: 'greater than' | ||
} ${alert.threshold} lines | ||
} ${alert.threshold} lines\n${timeRangeMessage} | ||
${targetTemplate} | ||
\`\`\` | ||
${truncatedResults} | ||
|
@@ -556,7 +562,7 @@ ${value} ${ | |
: alert.thresholdType === AlertThresholdType.ABOVE | ||
? 'falls below' | ||
: 'exceeds' | ||
} ${alert.threshold} | ||
} ${alert.threshold}\n${timeRangeMessage} | ||
${targetTemplate}`; | ||
} | ||
|
||
|
@@ -716,6 +722,8 @@ export const processAlert = async (now: Date, alert: EnhancedAlert) => { | |
connection: connectionId, | ||
displayType: DisplayType.Line, | ||
dateRange: [checkStartTime, checkEndTime], | ||
dateRangeStartInclusive: true, | ||
dateRangeEndInclusive: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for alerts, we don't want to include the end of date range |
||
from: source.from, | ||
granularity: `${windowSizeInMins} minute`, | ||
select: [ | ||
|
@@ -772,6 +780,8 @@ export const processAlert = async (now: Date, alert: EnhancedAlert) => { | |
chartConfig = { | ||
connection: connectionId, | ||
dateRange: [checkStartTime, checkEndTime], | ||
dateRangeStartInclusive: true, | ||
dateRangeEndInclusive: false, | ||
displayType: firstTile.config.displayType, | ||
from: source.from, | ||
granularity: `${windowSizeInMins} minute`, | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this new log line should test out the time boundary logic