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

feat: support navigating to discover in alerting popover #316

Merged
merged 4 commits into from
Sep 20, 2024

Conversation

raintygao
Copy link
Collaborator

@raintygao raintygao commented Sep 19, 2024

Description

support navigating to discover in alerting popover

Screen shot

-.2024-09-14.6_33_33.mp4

image

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.

@raintygao raintygao changed the title feat: support navigate to discover in alerting popover feat: support navigating to discover in alerting popover Sep 19, 2024
@raintygao raintygao marked this pull request as ready for review September 20, 2024 02:59
@raintygao raintygao added the backport 2.x Trigger the backport flow to 2.x label Sep 20, 2024
Comment on lines +190 to +194
const timeDslIndex = filters?.findIndex((filter: Record<string, string>) => filter?.range);
const timeDsl = filters[timeDslIndex]?.range;
const timeFieldName = Object.keys(timeDsl)[0];
if (!timeFieldName) return;
filters?.splice(timeDslIndex, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

there could have multiple range filters in filters and date range is not the first one

{
    "size": 0,
    "query": {
        "bool": {
            "filter": [
                {
                    "range": {
                        "total_quantity": {
                            "from": 1,
                            "to": 5,
                            "include_lower": true,
                            "include_upper": true,
                            "boost": 1
                        }
                    }
                },
                {
                    "range": {
                        "order_date": {
                            "from": "{{period_end}}||-1h",
                            "to": "{{period_end}}",
                            "include_lower": true,
                            "include_upper": true,
                            "format": "epoch_millis",
                            "boost": 1
                        }
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1
        }
    }
}

Copy link
Collaborator Author

@raintygao raintygao Sep 20, 2024

Choose a reason for hiding this comment

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

In which case will this DSL exist? I was told offline there only be one range in DSL, if so, this could be a potential issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What does period_end mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In which case will this DSL exist? I was told offline there only be one range in DSL, if so, this could be a potential issue.

This is a manual input query DSL. From create monitor page, if i add more range filters they will not at the first. It will looks like below, and the code logic is find first range filter, work for most cases.

"query": {
   "size": 0,
   "aggregations": {},
   "query": {
      "bool": {
         "filter": [
            {
               "range": {
                  "order_date": {
                     "gte": "{{period_end}}||-1h",
                     "lte": "{{period_end}}",
                     "format": "epoch_millis"
                  }
               }
            },
            {
               "range": {
                  "products.price": {
                     "gte": 10,
                     "lte": 20
                  }
               }
            }
         ]
      }
   }
}

What does period_end mean?

this is placeholder to actual trigger time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There still have other edge cases, like customized query don't have range filter. For POC we can ignore it.

public/utils/alerting.ts Show resolved Hide resolved
@raintygao raintygao merged commit 93744fe into opensearch-project:main Sep 20, 2024
9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 20, 2024
* feat: support navigate to discover in alerting popover

Signed-off-by: tygao <[email protected]>

* feat: support MDS and fix test env error

Signed-off-by: tygao <[email protected]>

* doc: add changelog

Signed-off-by: tygao <[email protected]>

* add tests

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>
(cherry picked from commit 93744fe)
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 Sep 20, 2024
* feat: support navigate to discover in alerting popover

Signed-off-by: tygao <[email protected]>

* feat: support MDS and fix test env error

Signed-off-by: tygao <[email protected]>

* doc: add changelog

Signed-off-by: tygao <[email protected]>

* add tests

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>
(cherry picked from commit 93744fe)
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants