validation api

This commit is contained in:
ashwinkumar12345 2021-11-08 11:41:49 -08:00
parent 4bf6f738be
commit 987bc7c4ab
4 changed files with 99 additions and 1 deletions

View File

@ -332,6 +332,97 @@ Options | Description | Type | Required
--- ---
## Validate detector
Introduced 1.2
{: .label .label-purple }
Returns whether the detector configuration has any issues that might prevent OpenSearch from creating the detector.
You can use the validate API to identify issues in your model configuration before creating the detector.
The request body consists of the detector configuration and follows the same format as the request body of the create detector API:
#### Request
```json
POST _plugins/_anomaly_detection/detectors/_validate
POST _plugins/_anomaly_detection/detectors/_validate/detector
{
"name": "test-detector",
"description": "Test detector",
"time_field": "timestamp",
"indices": [
"server_log*"
],
"feature_attributes": [
{
"feature_name": "test",
"feature_enabled": true,
"aggregation_query": {
"test": {
"sum": {
"field": "value"
}
}
}
}
],
"filter_query": {
"bool": {
"filter": [
{
"range": {
"value": {
"gt": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"detection_interval": {
"period": {
"interval": 1,
"unit": "Minutes"
}
},
"window_delay": {
"period": {
"interval": 1,
"unit": "Minutes"
}
}
}
```
If the validate API doesnt find any issue in the detector configuration, it returns an empty response:
#### Sample response
```json
{}
```
If the validate API finds an issue, it returns a message explaining what's wrong with the configuration. In this example, the feature query is aggregating over a field that doesnt exist in the data source:
#### Sample response
```json
{
"detector": {
"feature_attributes": {
"message": "Feature has invalid query returning empty aggregated data: average_total_rev",
"sub_issues": {
"average_total_rev": "Feature has invalid query returning empty aggregated data"
}
}
}
}
```
---
## Get detector ## Get detector
Introduced 1.0 Introduced 1.0
{: .label .label-purple } {: .label .label-purple }

View File

@ -110,7 +110,12 @@ We recommend experimenting with historical analysis with different feature sets
## Step 4: Review and create ## Step 4: Review and create
Review your model configuration and select **Create detector**. Review your detector settings and model configurations to make sure that they're valid and then proceed to select **Create detector**.
![Anomaly detection results]({{site.url}}{{site.baseurl}}/images/review_ad.png)
If you see any validation errors, edit the settings to fix the errors and then return back to this page.
{: .note }
## Step 5: Observe the results ## Step 5: Observe the results

View File

@ -80,8 +80,10 @@ These permissions are for the cluster and can't be applied granularly. For examp
- cluster:admin/opendistro/ad/detector/search - cluster:admin/opendistro/ad/detector/search
- cluster:admin/opendistro/ad/detector/stats - cluster:admin/opendistro/ad/detector/stats
- cluster:admin/opendistro/ad/detector/write - cluster:admin/opendistro/ad/detector/write
- cluster:admin/opendistro/ad/detector/validate
- cluster:admin/opendistro/ad/detectors/get - cluster:admin/opendistro/ad/detectors/get
- cluster:admin/opendistro/ad/result/search - cluster:admin/opendistro/ad/result/search
- cluster:admin/opendistro/ad/result/topAnomalies
- cluster:admin/opendistro/ad/tasks/search - cluster:admin/opendistro/ad/tasks/search
- cluster:admin/opendistro/alerting/alerts/ack (acknowledge) - cluster:admin/opendistro/alerting/alerts/ack (acknowledge)
- cluster:admin/opendistro/alerting/alerts/get - cluster:admin/opendistro/alerting/alerts/get

BIN
images/review_ad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB