Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

anomaly detection changes. #123

Merged
merged 5 commits into from
Apr 28, 2020

Conversation

ylwu-amzn
Copy link
Contributor

Co-authored-by: mihirsoni [email protected]

Issue #, if available:

  • Create monitor with anomaly detector. It will create a monitor based on anomaly result index, sample monitor
{
        "_index" : ".opendistro-alerting-config",
        "_type" : "_doc",
        "_id" : "dnexZXEBemUf2kpaW2CK",
        "_score" : 1.0,
        "_source" : {
          "monitor" : {
            "type" : "monitor",
            "schema_version" : 1,
            "name" : "test1-Monitor",
            "enabled" : true,
            "enabled_time" : 1586549054337,
            "schedule" : {
              "period" : {
                "interval" : 4,
                "unit" : "MINUTES"
              }
            },
            "inputs" : [
              {
                "search" : {
                  "indices" : [
                    ".opendistro-anomaly-results*"
                  ],
                  "query" : {
                    "size" : 1,
                    "query" : {
                      "bool" : {
                        "filter" : [
                          {
                            "range" : {
                              "data_end_time" : {
                                "from" : "{{period_end}}||-4m",
                                "to" : "{{period_end}}",
                                "include_lower" : true,
                                "include_upper" : true,
                                "boost" : 1.0
                              }
                            }
                          },
                          {
                            "term" : {
                              "detector_id" : {
                                "value" : "cXevZXEBemUf2kpaDWBN",
                                "boost" : 1.0
                              }
                            }
                          }
                        ],
                        "adjust_pure_negative" : true,
                        "boost" : 1.0
                      }
                    },
                    "sort" : [
                      {
                        "anomaly_grade" : {
                          "order" : "desc"
                        }
                      },
                      {
                        "confidence" : {
                          "order" : "desc"
                        }
                      }
                    ],
                    "aggregations" : {
                      "max_anomaly_grade" : {
                        "max" : {
                          "field" : "anomaly_grade"
                        }
                      }
                    }
                  }
                }
              }
            ],
            "triggers" : [
              {
                "id" : "eXexZXEBemUf2kpa52A4",
                "name" : "ad-trigger",
                "severity" : "1",
                "condition" : {
                  "script" : {
                    "source" : "return ctx.results[0].aggregations.max_anomaly_grade.value != null && ctx.results[0].aggregations.max_anomaly_grade.value > 0.7 && ctx.results[0].hits.hits[0]._source.confidence > 0.7",
                    "lang" : "painless"
                  }
                },
                "actions" : [ ]
              }
            ],
            "last_update_time" : 1586549090104,
            "ui_metadata" : {
              "schedule" : {
                "cronExpression" : "0 */1 * * *",
                "period" : {
                  "unit" : "Minutes",
                  "interval" : 4
                },
                "timezone" : null,
                "daily" : 0,
                "monthly" : {
                  "type" : "day",
                  "day" : 1
                },
                "weekly" : {
                  "tue" : false,
                  "wed" : false,
                  "thur" : false,
                  "sat" : false,
                  "fri" : false,
                  "mon" : false,
                  "sun" : false
                },
                "frequency" : "interval"
              },
              "search" : {
                "aggregationType" : "count",
                "fieldName" : "",
                "overDocuments" : "all documents",
                "searchType" : "ad",
                "bucketValue" : 1,
                "timeField" : "",
                "groupedOverTop" : 5,
                "bucketUnitOfTime" : "h",
                "where" : {
                  "fieldName" : [ ],
                  "fieldRangeEnd" : 0,
                  "fieldRangeStart" : 0,
                  "fieldValue" : "",
                  "operator" : "is"
                },
                "groupedOverFieldName" : "bytes"
              },
              "triggers" : {
                "ad-trigger" : {
                  "adTriggerMetadata" : {
                    "anomalyConfidence" : {
                      "value" : 0.7,
                      "enum" : "ABOVE"
                    },
                    "triggerType" : "anomaly_detector_trigger",
                    "anomalyGrade" : {
                      "value" : 0.7,
                      "enum" : "ABOVE"
                    }
                  },
                  "value" : 10000,
                  "enum" : "ABOVE"
                }
              }
            }
          }
        }
      }

Create monitor

screencapture-localhost-5601-app-opendistro-alerting-2020-04-10-13_02_13

Create trigger

screencapture-localhost-5601-app-opendistro-alerting-2020-04-10-13_04_38

Monitor detail page

screencapture-localhost-5601-app-opendistro-alerting-2020-04-10-13_05_01

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ylwu-amzn ylwu-amzn requested review from dbbaughe and mihirsoni April 10, 2020 20:12
@ylwu-amzn
Copy link
Contributor Author

Paste my local test result here as the "Unit test workflow" of Github Checks failed.

Test Suites: 6 skipped, 76 passed, 76 of 82 total
Tests:       20 skipped, 362 passed, 382 total
Snapshots:   127 passed, 127 total
Time:        117.026s
Ran all test suites.
✨  Done in 119.75s.

mihirsoni
mihirsoni previously approved these changes Apr 23, 2020
Copy link
Contributor

@dbbaughe dbbaughe left a comment

Choose a reason for hiding this comment

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

Please have some folks from AD review this PR, there is too much business logic pertaining to AD in this PR with 69 file changes for me to fully review. Consider breaking apart PRs into reasonable lengths.

.lintstagedrc Outdated Show resolved Hide resolved
public/utils/validate.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
server/services/utils/helpers.js Show resolved Hide resolved
server/services/utils/adHelpers.js Show resolved Hide resolved
Copy link

@yizheliu-amazon yizheliu-amazon left a comment

Choose a reason for hiding this comment

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

some minor comments. feel free to check in after addressing them.

@ylwu-amzn
Copy link
Contributor Author

Post local yarn test:jest result here

Test Suites: 6 skipped, 78 passed, 78 of 84 total
Tests: 20 skipped, 366 passed, 386 total
Snapshots: 127 passed, 127 total
Time: 67.975s
Ran all test suites.
✨ Done in 71.26s.

Copy link
Contributor

@dbbaughe dbbaughe left a comment

Choose a reason for hiding this comment

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

Thanks for changes

@ylwu-amzn ylwu-amzn merged commit b35f110 into opendistro-for-elasticsearch:master Apr 28, 2020
ylwu-amzn added a commit to ylwu-amzn/alerting-kibana-plugin that referenced this pull request May 5, 2020
* anomaly detection changes.

Co-authored-by: mihirsoni <[email protected]>

* remove anomaly detector option when create monitor if AD plugin not installed

* address comments: copyright, remove unused code,etc

* remove extra showLoader

Co-authored-by: mihirsoni <[email protected]>
ylwu-amzn added a commit that referenced this pull request May 5, 2020
* validateUrl: Increasing valid TLD length to 63 (#115)

* Increasing valid TLD length to 63

According to RFC1035 (https://tools.ietf.org/html/rfc1035), the maximum size of a label is 63 octets.

We need this increased because we use a domain that is larger than 4 characters. We cannot setup alerts as a result.

* Add validateUrl test for TLD with >4 characters

* Adding validateUrl test for TLD with >63 characters

* anomaly detection changes. (#123)

* anomaly detection changes.

Co-authored-by: mihirsoni <[email protected]>

* remove anomaly detector option when create monitor if AD plugin not installed

* address comments: copyright, remove unused code,etc

* remove extra showLoader

Co-authored-by: mihirsoni <[email protected]>

* change words and padding according to ux review comments (#132)

* change words and padding according to ux review comments

* fix padding of monitor schedule

* rename monitor method description according to UX review comments (#133)

* fix snapshot test and validate unit test

Co-authored-by: mihirsoni <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants