|
@@ -13,6 +13,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|
|
import org.elasticsearch.action.support.TransportAction;
|
|
import org.elasticsearch.action.support.TransportAction;
|
|
|
import org.elasticsearch.common.ParsingException;
|
|
import org.elasticsearch.common.ParsingException;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
|
|
+import org.elasticsearch.core.UpdateForV9;
|
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
import org.elasticsearch.index.query.QueryBuilder;
|
|
|
import org.elasticsearch.tasks.CancellableTask;
|
|
import org.elasticsearch.tasks.CancellableTask;
|
|
|
import org.elasticsearch.tasks.Task;
|
|
import org.elasticsearch.tasks.Task;
|
|
@@ -42,7 +43,9 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
public static final ParseField LIMIT_FIELD = new ParseField("limit");
|
|
public static final ParseField LIMIT_FIELD = new ParseField("limit");
|
|
|
public static final ParseField INDICES_FIELD = new ParseField("indices");
|
|
public static final ParseField INDICES_FIELD = new ParseField("indices");
|
|
|
public static final ParseField STACKTRACE_IDS_FIELD = new ParseField("stacktrace_ids_field");
|
|
public static final ParseField STACKTRACE_IDS_FIELD = new ParseField("stacktrace_ids_field");
|
|
|
|
|
+ @UpdateForV9 // Remove this BWC layer and allow only AGGREGATION_FIELDS
|
|
|
public static final ParseField AGGREGATION_FIELD = new ParseField("aggregation_field");
|
|
public static final ParseField AGGREGATION_FIELD = new ParseField("aggregation_field");
|
|
|
|
|
+ public static final ParseField AGGREGATION_FIELDS = new ParseField("aggregation_fields");
|
|
|
public static final ParseField REQUESTED_DURATION_FIELD = new ParseField("requested_duration");
|
|
public static final ParseField REQUESTED_DURATION_FIELD = new ParseField("requested_duration");
|
|
|
public static final ParseField AWS_COST_FACTOR_FIELD = new ParseField("aws_cost_factor");
|
|
public static final ParseField AWS_COST_FACTOR_FIELD = new ParseField("aws_cost_factor");
|
|
|
public static final ParseField AZURE_COST_FACTOR_FIELD = new ParseField("azure_cost_factor");
|
|
public static final ParseField AZURE_COST_FACTOR_FIELD = new ParseField("azure_cost_factor");
|
|
@@ -59,7 +62,9 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
private String[] indices;
|
|
private String[] indices;
|
|
|
private boolean userProvidedIndices;
|
|
private boolean userProvidedIndices;
|
|
|
private String stackTraceIdsField;
|
|
private String stackTraceIdsField;
|
|
|
|
|
+ @UpdateForV9 // Remove this BWC layer and allow only aggregationFields
|
|
|
private String aggregationField;
|
|
private String aggregationField;
|
|
|
|
|
+ private String[] aggregationFields;
|
|
|
private Double requestedDuration;
|
|
private Double requestedDuration;
|
|
|
private Double awsCostFactor;
|
|
private Double awsCostFactor;
|
|
|
private Double azureCostFactor;
|
|
private Double azureCostFactor;
|
|
@@ -78,7 +83,7 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
private Integer shardSeed;
|
|
private Integer shardSeed;
|
|
|
|
|
|
|
|
public GetStackTracesRequest() {
|
|
public GetStackTracesRequest() {
|
|
|
- this(null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
|
|
|
|
|
+ this(null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public GetStackTracesRequest(
|
|
public GetStackTracesRequest(
|
|
@@ -90,6 +95,7 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
String[] indices,
|
|
String[] indices,
|
|
|
String stackTraceIdsField,
|
|
String stackTraceIdsField,
|
|
|
String aggregationField,
|
|
String aggregationField,
|
|
|
|
|
+ String[] aggregationFields,
|
|
|
Double customCO2PerKWH,
|
|
Double customCO2PerKWH,
|
|
|
Double customDatacenterPUE,
|
|
Double customDatacenterPUE,
|
|
|
Double customPerCoreWattX86,
|
|
Double customPerCoreWattX86,
|
|
@@ -105,6 +111,7 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
this.userProvidedIndices = indices != null && indices.length > 0;
|
|
this.userProvidedIndices = indices != null && indices.length > 0;
|
|
|
this.stackTraceIdsField = stackTraceIdsField;
|
|
this.stackTraceIdsField = stackTraceIdsField;
|
|
|
this.aggregationField = aggregationField;
|
|
this.aggregationField = aggregationField;
|
|
|
|
|
+ this.aggregationFields = aggregationFields;
|
|
|
this.customCO2PerKWH = customCO2PerKWH;
|
|
this.customCO2PerKWH = customCO2PerKWH;
|
|
|
this.customDatacenterPUE = customDatacenterPUE;
|
|
this.customDatacenterPUE = customDatacenterPUE;
|
|
|
this.customPerCoreWattX86 = customPerCoreWattX86;
|
|
this.customPerCoreWattX86 = customPerCoreWattX86;
|
|
@@ -181,6 +188,19 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
return aggregationField;
|
|
return aggregationField;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String[] getAggregationFields() {
|
|
|
|
|
+ return aggregationField != null ? new String[] { aggregationField } : aggregationFields;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public boolean hasAggregationFields() {
|
|
|
|
|
+ String[] f = getAggregationFields();
|
|
|
|
|
+ return f != null && f.length > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public boolean isLegacyAggregationField() {
|
|
|
|
|
+ return aggregationField != null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public boolean isAdjustSampleCount() {
|
|
public boolean isAdjustSampleCount() {
|
|
|
return Boolean.TRUE.equals(adjustSampleCount);
|
|
return Boolean.TRUE.equals(adjustSampleCount);
|
|
|
}
|
|
}
|
|
@@ -244,8 +264,10 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
}
|
|
}
|
|
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
|
|
if (INDICES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
if (INDICES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
|
- this.indices = parseIndices(parser);
|
|
|
|
|
|
|
+ this.indices = parseToStringArray(parser, INDICES_FIELD);
|
|
|
this.userProvidedIndices = true;
|
|
this.userProvidedIndices = true;
|
|
|
|
|
+ } else if (AGGREGATION_FIELDS.match(currentFieldName, parser.getDeprecationHandler())) {
|
|
|
|
|
+ this.aggregationFields = parseToStringArray(parser, AGGREGATION_FIELDS);
|
|
|
} else {
|
|
} else {
|
|
|
throw new ParsingException(parser.getTokenLocation(), "Unexpected token " + token + " in [" + currentFieldName + "].");
|
|
throw new ParsingException(parser.getTokenLocation(), "Unexpected token " + token + " in [" + currentFieldName + "].");
|
|
|
}
|
|
}
|
|
@@ -260,12 +282,12 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String[] parseIndices(XContentParser parser) throws IOException {
|
|
|
|
|
|
|
+ private String[] parseToStringArray(XContentParser parser, ParseField parseField) throws IOException {
|
|
|
XContentParser.Token token;
|
|
XContentParser.Token token;
|
|
|
- List<String> indices = new ArrayList<>();
|
|
|
|
|
|
|
+ List<String> values = new ArrayList<>();
|
|
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
|
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
|
|
|
if (token == XContentParser.Token.VALUE_STRING) {
|
|
if (token == XContentParser.Token.VALUE_STRING) {
|
|
|
- indices.add(parser.text());
|
|
|
|
|
|
|
+ values.add(parser.text());
|
|
|
} else {
|
|
} else {
|
|
|
throw new ParsingException(
|
|
throw new ParsingException(
|
|
|
parser.getTokenLocation(),
|
|
parser.getTokenLocation(),
|
|
@@ -274,12 +296,12 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
+ "] but found ["
|
|
+ "] but found ["
|
|
|
+ token
|
|
+ token
|
|
|
+ "] in ["
|
|
+ "] in ["
|
|
|
- + INDICES_FIELD.getPreferredName()
|
|
|
|
|
|
|
+ + parseField.getPreferredName()
|
|
|
+ "]."
|
|
+ "]."
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return indices.toArray(new String[0]);
|
|
|
|
|
|
|
+ return values.toArray(new String[0]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -300,6 +322,32 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (aggregationField != null && aggregationFields != null) {
|
|
|
|
|
+ validationException = addValidationError(
|
|
|
|
|
+ "["
|
|
|
|
|
+ + AGGREGATION_FIELD.getPreferredName()
|
|
|
|
|
+ + "] must not be set when ["
|
|
|
|
|
+ + AGGREGATION_FIELDS.getPreferredName()
|
|
|
|
|
+ + "] is also set",
|
|
|
|
|
+ validationException
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if (aggregationFields != null) {
|
|
|
|
|
+ // limit so we avoid an explosion of buckets
|
|
|
|
|
+ if (aggregationFields.length < 1 || aggregationFields.length > 2) {
|
|
|
|
|
+ validationException = addValidationError(
|
|
|
|
|
+ "["
|
|
|
|
|
+ + AGGREGATION_FIELDS.getPreferredName()
|
|
|
|
|
+ + "] must contain either one or two elements but contains ["
|
|
|
|
|
+ + aggregationFields.length
|
|
|
|
|
+ + "] elements.",
|
|
|
|
|
+ validationException
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (aggregationField != null && aggregationField.isBlank()) {
|
|
if (aggregationField != null && aggregationField.isBlank()) {
|
|
|
validationException = addValidationError(
|
|
validationException = addValidationError(
|
|
|
"[" + AGGREGATION_FIELD.getPreferredName() + "] must be non-empty",
|
|
"[" + AGGREGATION_FIELD.getPreferredName() + "] must be non-empty",
|
|
@@ -339,6 +387,7 @@ public class GetStackTracesRequest extends ActionRequest implements IndicesReque
|
|
|
appendField(sb, "indices", indices);
|
|
appendField(sb, "indices", indices);
|
|
|
appendField(sb, "stacktrace_ids_field", stackTraceIdsField);
|
|
appendField(sb, "stacktrace_ids_field", stackTraceIdsField);
|
|
|
appendField(sb, "aggregation_field", aggregationField);
|
|
appendField(sb, "aggregation_field", aggregationField);
|
|
|
|
|
+ appendField(sb, "aggregation_fields", aggregationFields);
|
|
|
appendField(sb, "sample_size", sampleSize);
|
|
appendField(sb, "sample_size", sampleSize);
|
|
|
appendField(sb, "limit", limit);
|
|
appendField(sb, "limit", limit);
|
|
|
appendField(sb, "requested_duration", requestedDuration);
|
|
appendField(sb, "requested_duration", requestedDuration);
|