From c52ad34cfc581e5a246bb5a74e0b223e0d19db16 Mon Sep 17 00:00:00 2001 From: Kaituo Li Date: Wed, 14 Oct 2020 17:42:36 -0700 Subject: [PATCH] Add messages, attributes, names required for multi-entity detectors --- .../ad/constant/CommonErrorMessages.java | 3 +++ .../ad/constant/CommonMessageAttributes.java | 2 ++ .../ad/constant/CommonName.java | 5 +++++ .../ad/transport/AnomalyResultRequest.java | 10 +++------- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonErrorMessages.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonErrorMessages.java index 44361d17..c270d306 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonErrorMessages.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonErrorMessages.java @@ -26,4 +26,7 @@ public class CommonErrorMessages { public static final String MEMORY_CIRCUIT_BROKEN_ERR_MSG = "AD memory circuit is broken."; public static final String DISABLED_ERR_MSG = "AD plugin is disabled. To enable update opendistro.anomaly_detection.enabled to true"; public static final String INVALID_SEARCH_QUERY_MSG = "Invalid search query."; + public static final String ALL_FEATURES_DISABLED_ERR_MSG = + "Having trouble querying data because all of your features have been disabled."; + public static final String INVALID_TIMESTAMP_ERR_MSG = "timestamp is invalid"; } diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java index bd5ef67a..2f0cbaf9 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java @@ -27,4 +27,6 @@ public class CommonMessageAttributes { public static final String CONFIDENCE_JSON_KEY = "confidence"; public static final String ANOMALY_GRADE_JSON_KEY = "anomalyGrade"; public static final String QUEUE_JSON_KEY = "queue"; + public static final String START_JSON_KEY = "start"; + public static final String END_JSON_KEY = "end"; } diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java index 0e844d0e..0892dcb3 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java @@ -59,6 +59,9 @@ public class CommonName { public static final String MODELS = "models"; public static final String INIT_PROGRESS = "init_progress"; + public static final String TOTAL_ENTITIES = "total_entities"; + public static final String ACTIVE_ENTITIES = "active_entities"; + // Elastic mapping type public static final String MAPPING_TYPE = "_doc"; @@ -68,4 +71,6 @@ public class CommonName { public static final String KEYWORD_TYPE = "keyword"; public static final String IP_TYPE = "ip"; + + public static final String TOTAL_UPDATES = "total_updates"; } diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java index b3a19200..131f8ee0 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java @@ -36,10 +36,6 @@ import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; public class AnomalyResultRequest extends ActionRequest implements ToXContentObject { - static final String INVALID_TIMESTAMP_ERR_MSG = "timestamp is invalid"; - static final String START_JSON_KEY = "start"; - static final String END_JSON_KEY = "end"; - private String adID; // time range start and end. Unit: epoch milliseconds private long start; @@ -87,7 +83,7 @@ public ActionRequestValidationException validate() { } if (start <= 0 || end <= 0 || start > end) { validationException = addValidationError( - String.format(Locale.ROOT, "%s: start %d, end %d", INVALID_TIMESTAMP_ERR_MSG, start, end), + String.format(Locale.ROOT, "%s: start %d, end %d", CommonErrorMessages.INVALID_TIMESTAMP_ERR_MSG, start, end), validationException ); } @@ -98,8 +94,8 @@ public ActionRequestValidationException validate() { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(CommonMessageAttributes.ID_JSON_KEY, adID); - builder.field(START_JSON_KEY, start); - builder.field(END_JSON_KEY, end); + builder.field(CommonMessageAttributes.START_JSON_KEY, start); + builder.field(CommonMessageAttributes.END_JSON_KEY, end); builder.endObject(); return builder; }