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

support historical analysis for HC detector #104

Conversation

ylwu-amzn
Copy link
Collaborator

Signed-off-by: Yaliang Wu ylwu@amazon.com

Description

Support historical analysis for HC detector. For single entity detector, we just need to create one AD task as it has only one ML model. For HC detector, AD will run separate ML model for each entity. So we will create individual task for each entity. And we will have one detector level task to track overall state like progress. Will save detector level task id as parent task id in entity task.

The main steps for HC detector historical analysis:

  1. Get top entities
  2. Calculate how many entities can run concurrently based on settings and cluster resources. Then start N task lanes to run entities. Each lane will run 1 entity. For every entity task will get all data node's state and dispatch entity task to the node with least node.
  3. If one entity task finished, worker node will send entity task done message to coordinating node to poll next entity task.
  4. If entity task failed, will handle exception. Check java doc of ADTaskManager#getAdEntityTaskAction for details.
  5. Once all entities done. Will mark the HC detector level task as done.

Check List

  • 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.

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
@ylwu-amzn ylwu-amzn marked this pull request as draft June 24, 2021 17:50
@codecov-commenter
Copy link

Codecov Report

Merging #104 (e3c4299) into single-flow-development-rc1 (d5e5084) will decrease coverage by 9.05%.
The diff coverage is 18.75%.

Impacted file tree graph

@@                        Coverage Diff                        @@
##             single-flow-development-rc1     #104      +/-   ##
=================================================================
- Coverage                          79.12%   70.07%   -9.06%     
+ Complexity                          2700     2523     -177     
=================================================================
  Files                                243      244       +1     
  Lines                              11244    11895     +651     
  Branches                            1033     1089      +56     
=================================================================
- Hits                                8897     8335     -562     
- Misses                              1917     3137    +1220     
+ Partials                             430      423       -7     
Flag Coverage Δ
plugin 70.07% <18.75%> (-9.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rg/opensearch/ad/AnomalyDetectorProfileRunner.java 76.47% <ø> (-0.79%) ⬇️
...java/org/opensearch/ad/feature/FeatureManager.java 93.96% <ø> (-2.27%) ⬇️
...ensearch/ad/rest/RestAnomalyDetectorJobAction.java 41.37% <0.00%> (-15.77%) ⬇️
...arch/ad/rest/RestExecuteAnomalyDetectorAction.java 26.19% <0.00%> (ø)
...est/handler/IndexAnomalyDetectorActionHandler.java 43.08% <0.00%> (-6.31%) ⬇️
...ava/org/opensearch/ad/task/ADHCBatchTaskCache.java 0.00% <0.00%> (ø)
...d/transport/GetAnomalyDetectorTransportAction.java 53.95% <ø> (-3.60%) ⬇️
...rch/ad/transport/ForwardADTaskTransportAction.java 10.16% <4.34%> (-75.55%) ⬇️
...ava/org/opensearch/ad/task/ADTaskCacheManager.java 42.77% <7.46%> (-50.81%) ⬇️
...ain/java/org/opensearch/ad/task/ADTaskManager.java 21.09% <10.03%> (-52.13%) ⬇️
... and 57 more

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
@ylwu-amzn ylwu-amzn marked this pull request as ready for review June 25, 2021 23:06
Copy link
Collaborator

@kaituo kaituo left a comment

Choose a reason for hiding this comment

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

New comments based on our discussions on Friday.

@ylwu-amzn ylwu-amzn requested a review from zhanghg08 June 28, 2021 23:18
Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
@ylwu-amzn ylwu-amzn force-pushed the single-flow-development-rc1-run-hc branch from 4f2c24f to fd028d6 Compare June 29, 2021 08:15
build.gradle Outdated Show resolved Hide resolved
src/main/java/org/opensearch/ad/model/ADTaskAction.java Outdated Show resolved Hide resolved
src/main/java/org/opensearch/ad/task/ADBatchTaskCache.java Outdated Show resolved Hide resolved
@kaituo
Copy link
Collaborator

kaituo commented Jun 30, 2021

resolved all of open comments from me. Please address the left over comments from the old PR: #58

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
@ylwu-amzn ylwu-amzn force-pushed the single-flow-development-rc1-run-hc branch from c2911b6 to be452a4 Compare June 30, 2021 00:51
Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
@ylwu-amzn ylwu-amzn force-pushed the single-flow-development-rc1-run-hc branch from 30b7e8d to c4d568e Compare June 30, 2021 02:28
@ylwu-amzn
Copy link
Collaborator Author

resolved all of open comments from me. Please address the left over comments from the old PR: #58

Thanks Kaituo. To save some effort, I just replied most other comments on the old PR directly. You can check my replies on the old PR and comment more on this PR if have new questions.

Copy link

@zhanghg08 zhanghg08 left a comment

Choose a reason for hiding this comment

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

No concerns from my side. Thanks for the changes.

@ylwu-amzn ylwu-amzn merged commit 3d100b7 into opensearch-project:single-flow-development-rc1 Jul 1, 2021
@ylwu-amzn ylwu-amzn mentioned this pull request Jul 27, 2021
1 task
ylwu-amzn added a commit that referenced this pull request Jul 27, 2021
* tune data model for unified flow

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support unified flow for single entity detector

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add realtime task

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support preview with detector directly

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support historical analysis for HC detector (#104)

* support run historical analysis for HC detector

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more javadoc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments: rename method, remove comments etc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more comments for task action

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments from old CR: mainly renaming and add more comments

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* support HC task profiles in profile API;error handling (#123)

* support HC task profiles in profile API;error handling

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add init progress of realtime task (#130)

* add init progress of realtime task

* add realtime task cache

* remove DetectionStateHandler, will track error in realtime task

* add more comments

* add delete anomaly results API (#131)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain running historical task in hourly cron (#132)

* maintain running historical task in hourly cron

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain realtime tasks

* address comments

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
ohltyler pushed a commit to ohltyler/anomaly-detection-2 that referenced this pull request Sep 1, 2021
* tune data model for unified flow

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support unified flow for single entity detector

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add realtime task

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support preview with detector directly

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support historical analysis for HC detector (opensearch-project#104)

* support run historical analysis for HC detector

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more javadoc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments: rename method, remove comments etc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more comments for task action

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments from old CR: mainly renaming and add more comments

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* support HC task profiles in profile API;error handling (opensearch-project#123)

* support HC task profiles in profile API;error handling

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add init progress of realtime task (opensearch-project#130)

* add init progress of realtime task

* add realtime task cache

* remove DetectionStateHandler, will track error in realtime task

* add more comments

* add delete anomaly results API (opensearch-project#131)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain running historical task in hourly cron (opensearch-project#132)

* maintain running historical task in hourly cron

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain realtime tasks

* address comments

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
ohltyler pushed a commit to ohltyler/anomaly-detection-2 that referenced this pull request Sep 1, 2021
* tune data model for unified flow

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support unified flow for single entity detector

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add realtime task

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support preview with detector directly

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support historical analysis for HC detector (opensearch-project#104)

* support run historical analysis for HC detector

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more javadoc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments: rename method, remove comments etc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more comments for task action

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments from old CR: mainly renaming and add more comments

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* support HC task profiles in profile API;error handling (opensearch-project#123)

* support HC task profiles in profile API;error handling

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add init progress of realtime task (opensearch-project#130)

* add init progress of realtime task

* add realtime task cache

* remove DetectionStateHandler, will track error in realtime task

* add more comments

* add delete anomaly results API (opensearch-project#131)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain running historical task in hourly cron (opensearch-project#132)

* maintain running historical task in hourly cron

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain realtime tasks

* address comments

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
ohltyler pushed a commit that referenced this pull request Sep 1, 2021
* tune data model for unified flow

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support unified flow for single entity detector

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add realtime task

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support preview with detector directly

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* support historical analysis for HC detector (#104)

* support run historical analysis for HC detector

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more javadoc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments: rename method, remove comments etc

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* add more comments for task action

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* address comments from old CR: mainly renaming and add more comments

Signed-off-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>

* support HC task profiles in profile API;error handling (#123)

* support HC task profiles in profile API;error handling

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add init progress of realtime task (#130)

* add init progress of realtime task

* add realtime task cache

* remove DetectionStateHandler, will track error in realtime task

* add more comments

* add delete anomaly results API (#131)

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain running historical task in hourly cron (#132)

* maintain running historical task in hourly cron

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* maintain realtime tasks

* address comments

Co-authored-by: Yaliang Wu <ylwu@dev-dsk-ylwu-2c-e500d1cf.us-west-2.amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants