|
@@ -61,15 +61,11 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
private static final ParseField SUMMARY_COUNT_FIELD_NAME = new ParseField("summary_count_field_name");
|
|
|
private static final ParseField DETECTORS = new ParseField("detectors");
|
|
|
private static final ParseField INFLUENCERS = new ParseField("influencers");
|
|
|
- private static final ParseField OVERLAPPING_BUCKETS = new ParseField("overlapping_buckets");
|
|
|
- private static final ParseField RESULT_FINALIZATION_WINDOW = new ParseField("result_finalization_window");
|
|
|
private static final ParseField MULTIVARIATE_BY_FIELDS = new ParseField("multivariate_by_fields");
|
|
|
|
|
|
public static final String ML_CATEGORY_FIELD = "mlcategory";
|
|
|
public static final Set<String> AUTO_CREATED_FIELDS = new HashSet<>(Collections.singletonList(ML_CATEGORY_FIELD));
|
|
|
|
|
|
- public static final long DEFAULT_RESULT_FINALIZATION_WINDOW = 2L;
|
|
|
-
|
|
|
// These parsers follow the pattern that metadata is parsed leniently (to allow for enhancements), whilst config is parsed strictly
|
|
|
public static final ConstructingObjectParser<AnalysisConfig.Builder, Void> LENIENT_PARSER = createParser(true);
|
|
|
public static final ConstructingObjectParser<AnalysisConfig.Builder, Void> STRICT_PARSER = createParser(false);
|
|
@@ -94,8 +90,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
builder.setLatency(TimeValue.parseTimeValue(val, LATENCY.getPreferredName())), LATENCY);
|
|
|
parser.declareString(Builder::setSummaryCountFieldName, SUMMARY_COUNT_FIELD_NAME);
|
|
|
parser.declareStringArray(Builder::setInfluencers, INFLUENCERS);
|
|
|
- parser.declareBoolean(Builder::setOverlappingBuckets, OVERLAPPING_BUCKETS);
|
|
|
- parser.declareLong(Builder::setResultFinalizationWindow, RESULT_FINALIZATION_WINDOW);
|
|
|
parser.declareBoolean(Builder::setMultivariateByFields, MULTIVARIATE_BY_FIELDS);
|
|
|
|
|
|
return parser;
|
|
@@ -112,14 +106,11 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
private final String summaryCountFieldName;
|
|
|
private final List<Detector> detectors;
|
|
|
private final List<String> influencers;
|
|
|
- private final Boolean overlappingBuckets;
|
|
|
- private final Long resultFinalizationWindow;
|
|
|
private final Boolean multivariateByFields;
|
|
|
|
|
|
private AnalysisConfig(TimeValue bucketSpan, String categorizationFieldName, List<String> categorizationFilters,
|
|
|
CategorizationAnalyzerConfig categorizationAnalyzerConfig, TimeValue latency, String summaryCountFieldName,
|
|
|
- List<Detector> detectors, List<String> influencers, Boolean overlappingBuckets, Long resultFinalizationWindow,
|
|
|
- Boolean multivariateByFields) {
|
|
|
+ List<Detector> detectors, List<String> influencers, Boolean multivariateByFields) {
|
|
|
this.detectors = detectors;
|
|
|
this.bucketSpan = bucketSpan;
|
|
|
this.latency = latency;
|
|
@@ -128,8 +119,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
this.categorizationFilters = categorizationFilters == null ? null : Collections.unmodifiableList(categorizationFilters);
|
|
|
this.summaryCountFieldName = summaryCountFieldName;
|
|
|
this.influencers = Collections.unmodifiableList(influencers);
|
|
|
- this.overlappingBuckets = overlappingBuckets;
|
|
|
- this.resultFinalizationWindow = resultFinalizationWindow;
|
|
|
this.multivariateByFields = multivariateByFields;
|
|
|
}
|
|
|
|
|
@@ -146,8 +135,13 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
summaryCountFieldName = in.readOptionalString();
|
|
|
detectors = Collections.unmodifiableList(in.readList(Detector::new));
|
|
|
influencers = Collections.unmodifiableList(in.readList(StreamInput::readString));
|
|
|
- overlappingBuckets = in.readOptionalBoolean();
|
|
|
- resultFinalizationWindow = in.readOptionalLong();
|
|
|
+
|
|
|
+ // BWC for result_finalization_window and overlapping_buckets
|
|
|
+ // TODO Remove in 7.0.0
|
|
|
+ if (in.getVersion().before(Version.CURRENT)) {//setting to current before backport
|
|
|
+ in.readOptionalBoolean();
|
|
|
+ in.readOptionalLong();
|
|
|
+ }
|
|
|
multivariateByFields = in.readOptionalBoolean();
|
|
|
|
|
|
// BWC for removed multiple_bucket_spans
|
|
@@ -185,8 +179,13 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
out.writeOptionalString(summaryCountFieldName);
|
|
|
out.writeList(detectors);
|
|
|
out.writeStringList(influencers);
|
|
|
- out.writeOptionalBoolean(overlappingBuckets);
|
|
|
- out.writeOptionalLong(resultFinalizationWindow);
|
|
|
+
|
|
|
+ // BWC for result_finalization_window and overlapping_buckets
|
|
|
+ // TODO Remove in 7.0.0
|
|
|
+ if (out.getVersion().before(Version.CURRENT)) { //setting to current before backport
|
|
|
+ out.writeOptionalBoolean(null);
|
|
|
+ out.writeOptionalLong(null);
|
|
|
+ }
|
|
|
out.writeOptionalBoolean(multivariateByFields);
|
|
|
|
|
|
// BWC for removed multiple_bucket_spans
|
|
@@ -291,14 +290,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
.flatMap(Set::stream).collect(Collectors.toSet());
|
|
|
}
|
|
|
|
|
|
- public Boolean getOverlappingBuckets() {
|
|
|
- return overlappingBuckets;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getResultFinalizationWindow() {
|
|
|
- return resultFinalizationWindow;
|
|
|
- }
|
|
|
-
|
|
|
public Boolean getMultivariateByFields() {
|
|
|
return multivariateByFields;
|
|
|
}
|
|
@@ -394,12 +385,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
}
|
|
|
builder.endArray();
|
|
|
builder.field(INFLUENCERS.getPreferredName(), influencers);
|
|
|
- if (overlappingBuckets != null) {
|
|
|
- builder.field(OVERLAPPING_BUCKETS.getPreferredName(), overlappingBuckets);
|
|
|
- }
|
|
|
- if (resultFinalizationWindow != null) {
|
|
|
- builder.field(RESULT_FINALIZATION_WINDOW.getPreferredName(), resultFinalizationWindow);
|
|
|
- }
|
|
|
if (multivariateByFields != null) {
|
|
|
builder.field(MULTIVARIATE_BY_FIELDS.getPreferredName(), multivariateByFields);
|
|
|
}
|
|
@@ -420,8 +405,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
Objects.equals(summaryCountFieldName, that.summaryCountFieldName) &&
|
|
|
Objects.equals(detectors, that.detectors) &&
|
|
|
Objects.equals(influencers, that.influencers) &&
|
|
|
- Objects.equals(overlappingBuckets, that.overlappingBuckets) &&
|
|
|
- Objects.equals(resultFinalizationWindow, that.resultFinalizationWindow) &&
|
|
|
Objects.equals(multivariateByFields, that.multivariateByFields);
|
|
|
}
|
|
|
|
|
@@ -429,9 +412,7 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
public int hashCode() {
|
|
|
return Objects.hash(
|
|
|
bucketSpan, categorizationFieldName, categorizationFilters, categorizationAnalyzerConfig, latency,
|
|
|
- summaryCountFieldName, detectors, influencers, overlappingBuckets, resultFinalizationWindow,
|
|
|
- multivariateByFields
|
|
|
- );
|
|
|
+ summaryCountFieldName, detectors, influencers, multivariateByFields);
|
|
|
}
|
|
|
|
|
|
public static class Builder {
|
|
@@ -446,8 +427,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
private CategorizationAnalyzerConfig categorizationAnalyzerConfig;
|
|
|
private String summaryCountFieldName;
|
|
|
private List<String> influencers = new ArrayList<>();
|
|
|
- private Boolean overlappingBuckets;
|
|
|
- private Long resultFinalizationWindow;
|
|
|
private Boolean multivariateByFields;
|
|
|
|
|
|
public Builder(List<Detector> detectors) {
|
|
@@ -464,8 +443,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
this.categorizationAnalyzerConfig = analysisConfig.categorizationAnalyzerConfig;
|
|
|
this.summaryCountFieldName = analysisConfig.summaryCountFieldName;
|
|
|
this.influencers = new ArrayList<>(analysisConfig.influencers);
|
|
|
- this.overlappingBuckets = analysisConfig.overlappingBuckets;
|
|
|
- this.resultFinalizationWindow = analysisConfig.resultFinalizationWindow;
|
|
|
this.multivariateByFields = analysisConfig.multivariateByFields;
|
|
|
}
|
|
|
|
|
@@ -517,14 +494,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
this.influencers = ExceptionsHelper.requireNonNull(influencers, INFLUENCERS.getPreferredName());
|
|
|
}
|
|
|
|
|
|
- public void setOverlappingBuckets(Boolean overlappingBuckets) {
|
|
|
- this.overlappingBuckets = overlappingBuckets;
|
|
|
- }
|
|
|
-
|
|
|
- public void setResultFinalizationWindow(Long resultFinalizationWindow) {
|
|
|
- this.resultFinalizationWindow = resultFinalizationWindow;
|
|
|
- }
|
|
|
-
|
|
|
public void setMultivariateByFields(Boolean multivariateByFields) {
|
|
|
this.multivariateByFields = multivariateByFields;
|
|
|
}
|
|
@@ -536,7 +505,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
* <li>Check that if non-null Latency is <= MAX_LATENCY</li>
|
|
|
* <li>Check there is at least one detector configured</li>
|
|
|
* <li>Check all the detectors are configured correctly</li>
|
|
|
- * <li>Check that OVERLAPPING_BUCKETS is set appropriately</li>
|
|
|
* <li>Check that MULTIPLE_BUCKETSPANS are set appropriately</li>
|
|
|
* <li>If Per Partition normalization is configured at least one detector
|
|
|
* must have a partition field and no influences can be used</li>
|
|
@@ -555,17 +523,13 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
verifyMlCategoryIsUsedWhenCategorizationFieldNameIsSet();
|
|
|
verifyCategorizationAnalyzer();
|
|
|
verifyCategorizationFilters();
|
|
|
- checkFieldIsNotNegativeIfSpecified(RESULT_FINALIZATION_WINDOW.getPreferredName(), resultFinalizationWindow);
|
|
|
|
|
|
verifyNoMetricFunctionsWhenSummaryCountFieldNameIsSet();
|
|
|
|
|
|
- overlappingBuckets = verifyOverlappingBucketsConfig(overlappingBuckets, detectors);
|
|
|
-
|
|
|
verifyNoInconsistentNestedFieldNames();
|
|
|
|
|
|
return new AnalysisConfig(bucketSpan, categorizationFieldName, categorizationFilters, categorizationAnalyzerConfig,
|
|
|
- latency, summaryCountFieldName, detectors, influencers, overlappingBuckets,
|
|
|
- resultFinalizationWindow, multivariateByFields);
|
|
|
+ latency, summaryCountFieldName, detectors, influencers, multivariateByFields);
|
|
|
}
|
|
|
|
|
|
private void verifyNoMetricFunctionsWhenSummaryCountFieldNameIsSet() {
|
|
@@ -576,13 +540,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void checkFieldIsNotNegativeIfSpecified(String fieldName, Long value) {
|
|
|
- if (value != null && value < 0) {
|
|
|
- String msg = Messages.getMessage(Messages.JOB_CONFIG_FIELD_VALUE_TOO_LOW, fieldName, 0, value);
|
|
|
- throw ExceptionsHelper.badRequestException(msg);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void verifyDetectorAreDefined() {
|
|
|
if (detectors == null || detectors.isEmpty()) {
|
|
|
throw ExceptionsHelper.badRequestException(Messages.getMessage(Messages.JOB_CONFIG_NO_DETECTORS));
|
|
@@ -697,25 +654,5 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private static Boolean verifyOverlappingBucketsConfig(Boolean overlappingBuckets, List<Detector> detectors) {
|
|
|
- // If any detector function is rare/freq_rare, mustn't use overlapping buckets
|
|
|
- boolean mustNotUse = false;
|
|
|
-
|
|
|
- List<DetectorFunction> illegalFunctions = new ArrayList<>();
|
|
|
- for (Detector d : detectors) {
|
|
|
- if (Detector.NO_OVERLAPPING_BUCKETS_FUNCTIONS.contains(d.getFunction())) {
|
|
|
- illegalFunctions.add(d.getFunction());
|
|
|
- mustNotUse = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (Boolean.TRUE.equals(overlappingBuckets) && mustNotUse) {
|
|
|
- throw ExceptionsHelper.badRequestException(
|
|
|
- Messages.getMessage(Messages.JOB_CONFIG_OVERLAPPING_BUCKETS_INCOMPATIBLE_FUNCTION, illegalFunctions.toString()));
|
|
|
- }
|
|
|
-
|
|
|
- return overlappingBuckets;
|
|
|
- }
|
|
|
}
|
|
|
}
|