Skip to content
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

refactor: Update alerting DSL verify mechanism #359

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

raintygao
Copy link
Collaborator

Description

  1. Use UTC to verify 'to' value
  2. Support only one time range filter case

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test.
  • New functionality has user manual doc added.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -55,10 +56,19 @@ export const GeneratePopoverBody: React.FC<{
const getMonitorType = async () => {
const context = await incontextInsight.contextProvider?.();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, could you store this context in a variable so we don't need to invoke this provider multiple times?(It got 3 invoking for now.) contextProvider for alerting is a heavy operation, it will execute a dsl and a ppl each time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me see how to redesign this and do it in a separate PR in order not to have any influence on upcoming release.

Comment on lines 152 to 158
export const validateToTimeRange = (time: string) => {
// Alerting uses this format in to field of time range filter.
const TO_TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';
return moment.utc(time, TO_TIME_FORMAT, true).isValid();
};

export const extractTimeRangeDSL = (filters: NestedRecord[]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a unit test for these two functions?

setDisplayDiscoverButton(shoudDisplayDiscoverButton);
let hasTimeRangeFilter = false;
if (dsl) {
const dslObject = JSON.parse(dsl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add try catch for JSON.parse?

Signed-off-by: tygao <[email protected]>
@raintygao raintygao merged commit 0f4e48a into opensearch-project:main Oct 25, 2024
8 of 9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 25, 2024
(cherry picked from commit 0f4e48a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
raintygao pushed a commit that referenced this pull request Oct 25, 2024
(cherry picked from commit 0f4e48a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 25, 2024
(cherry picked from commit 0f4e48a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
raintygao pushed a commit that referenced this pull request Oct 25, 2024
(cherry picked from commit 0f4e48a)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Trigger the backport flow to 2.x backport 2.18 v2.18.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants