-
Notifications
You must be signed in to change notification settings - Fork 73
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
Adding Model Type Validation to Validate API ("non-blocker") #384
Conversation
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
Have the responses been reviewed by the tech writer? The 2 examples you have seem a little confusing to me:
Who is "we"? Can this be written as more of a direct suggestion, like "Suggested interval: 5 minutes" or something?
This seems unclear on next steps for the user. Can there be some added text about removing or revising the data filter? |
src/main/java/org/opensearch/ad/common/exception/ADValidationException.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/constant/CommonErrorMessages.java
Outdated
Show resolved
Hide resolved
These responses have yet to be finalized by tech writers, will add that to top description. Currently planned on adding a little more text on the frontend such as "We suggest going back and changing the data filter" (this wording will need to be improved). Do you suggest I add this sort of direction to the API response itself |
I see, I'd discuss with UX on that. To me it seems that you could add all of the text as part of the API and just propagate it to the frontend for simplicity. Don't need to add UI-specific context like "go back to this page" but more like "change the data filter" And again, the 'We' wording I believe should be removed |
src/main/java/org/opensearch/ad/rest/AbstractAnomalyDetectorAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java
Outdated
Show resolved
Hide resolved
.subAggregation( | ||
PipelineAggregatorBuilders | ||
.bucketSort("bucketSort", Collections.singletonList(new FieldSortBuilder("_count").order(SortOrder.DESC))) | ||
.size(1) |
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.
It's understandable to only get the top entity combination to use when doing the sparsity checks. But just thinking, what if the data has one or two dominant/frequent entity combos, and many more that are less common, but still useful? For example, maybe an interval of 5 mins is above the threshold for the top 1 entity combo, but an interval of 10 mins is above the threshold for the top 20 entity combos, in which case a suggestion of 10 mins interval would be much more useful from the customer perspective. Is it easy enough to repeat this for the top x entity combos and try to derive a more general working interval suggestion? (this applies to single-category HCAD as well, just using multi-category as the example).
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.
I could implement this within the first check when all configurations are applied. It would mean running multiple intervals for each one of the top 10 entities and keeping track of the highest interval. The best case is when I find an interval for all top entities but I guess if there is only an interval found for 5 of them, maybe it means the category fields should be relooked at or it could be good enough? On the check where I am adding the category field to the configurations I could repeat this as well but first goal could be only to initially do it for the first run with all configurations.
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.
Yeah it's impossible to know for sure what would be the ideal number of running entities. Roughly, my idea would be
- get top x entities (if < y then just optimize for single entity)
- find a baseline interval that works for single top entity (what you're already doing)
- check if that works for top z entities - if not, increase it a few more times to see if it can go over the threshold for top z entities - if not, then stick with baseline found in step 2
where x = num top entities constant, y = num top entities threshold, z = num top entities working given the interval threshold
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.
^ Id consider this not a hard reqt for this release, just an idea.
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/rest/handler/ModelValidationActionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/transport/ValidateAnomalyDetectorTransportAction.java
Outdated
Show resolved
Hide resolved
...g/opensearch/action/admin/indices/mapping/get/ValidateAnomalyDetectorActionHandlerTests.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/ad/rest/AnomalyDetectorRestApiIT.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Amit Galitzky <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #384 +/- ##
============================================
- Coverage 79.25% 77.64% -1.62%
- Complexity 4095 4105 +10
============================================
Files 295 296 +1
Lines 17207 17640 +433
Branches 1826 1876 +50
============================================
+ Hits 13638 13697 +59
- Misses 2672 3038 +366
- Partials 897 905 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
// This case has been reached if no interval recommendation was found that leads to a bucket success rate of >= 0.75 | ||
// but no single configuration during the following checks reduced the bucket success rate below 0.25 | ||
// This means the rate with all configs applied was below 0.75 but the rate when checking each configuration at time | ||
// was always above 0.25 meaning the best suggestion is to simply ingest more data since we have no more insight | ||
// regarding the root cause of the lower density. |
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.
Does this comment need to be tuned after recent changes to the thresholds?
src/test/java/org/opensearch/ad/rest/AnomalyDetectorRestApiIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/ad/rest/AnomalyDetectorRestApiIT.java
Outdated
Show resolved
Hide resolved
AnomalyDetector detector = TestHelpers.randomAnomalyDetector(TIME_FIELD, "index-test", ImmutableList.of(nonNumericFeature)); | ||
TestHelpers.createIndexWithTimeField(client(), "index-test", TIME_FIELD); |
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.
I see several here that could use the helper method too, or at least a similar helper method
@@ -435,4 +423,47 @@ public void testValidateAnomalyDetectorWithDetectorNameTooLong() throws IOExcept | |||
assertEquals(ValidationAspect.DETECTOR, response.getIssue().getAspect()); | |||
assertTrue(response.getIssue().getMessage().contains("Name should be shortened. The maximum limit is")); | |||
} | |||
|
|||
@Test | |||
public void testValidateAnomalyDetectorWithNonExistentTimefield() throws IOException { |
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.
Are you working on any tests to run the validation API with sparse data to test out all of the different scenarios? I think it's ok to have as a TODO, but maybe open an issue to track and add for following release.
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.
Yes I am currently continuing to do it in terms of integration tests like what I added here: src/test/java/org/opensearch/ad/e2e/DetectionResultEvalutationIT.java
. Will cut an issue and work on adding more in separate PR.
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.
LGTM! Just a few small things in recent comments.
Signed-off-by: Amit Galitzky <[email protected]>
@@ -692,26 +697,33 @@ private void checkFeatureQuery(long latestTime) throws IOException { | |||
client.search(searchRequest, ActionListener.wrap(response -> processFeatureQuery(response, latestTime), listener::onFailure)); | |||
} | |||
|
|||
private void sendWindowDelayRec(long latestTime) { |
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.
nit: latestTimeInMillis
may be more informative
} | ||
|
||
private void sendWindowDelayRec(long latestTime) { | ||
long minutesSinceLastStamp = TimeUnit.MILLISECONDS.toMinutes(Instant.now().toEpochMilli() - latestTime); |
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.
How does rounding work in this case? For example, if the difference is 1400 ms -> 1.4 minutes, will it return 1 or 2? If regular rounding / if it returns 1, then the suggestion may return the same window delay they already have.
Example: user sets window delay of 1 (= 1000 ms) -> currentTime - lastDataTime = 1400 > 1000, convert 1400 to minutes -> 1 minute, send recommendation of 1 minute
Signed-off-by: Amit Galitzky <[email protected]>
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.
LGTM!
Signed-off-by: Amit Galitzky <[email protected]> (cherry picked from commit 875b03c)
Signed-off-by: Amit Galitzky <[email protected]> (cherry picked from commit 875b03c)
Description
This PR adds two new changes.
Non-Blocker validation steps:
Additional Info (Important):
API Request:
_plugins/_anomaly_detection/detectors/_validate/<aspect>
model
Examples
Example 1 (data ingested only every 5 mins, recommends 5 minutes interval of 1 minute) :
Response 1:
Example 2 request (filter query leads to not enough dense data)
Response 2:
Issues Resolved
resolves #265
Check List
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.