forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark shard failures caused by unsupported aggregations or queries aga…
…inst rolled up data so Kibana can identify them (elastic#89252) When an unsupported aggregation is executed on a `aggregate_double_metric` field an error with a specific `type` field is generated. This allows clients like Kibana to identify these errors and handle them properly. Also we would like to fail on queries using a date histogram aggregation with `calendar_interval` on rollup indices. Date histogram aggregations are executed on rollup indices only if using `fixed_interval` and a `UTC` timezone.
- Loading branch information
1 parent
91d2db2
commit 4b92e1d
Showing
10 changed files
with
533 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../main/java/org/elasticsearch/search/aggregations/UnsupportedAggregationOnRollupIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.search.aggregations; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
|
||
// NOTE: the name of this class is part of a contract with Kibana which uses it to detect specific | ||
// errors while running aggregations on rollup indices. | ||
/** | ||
* Thrown when executing an aggregation on a time series index field whose type is not supported. | ||
* Downsampling uses specific types while aggregating some fields (like 'aggregate_metric_double'). | ||
* Such field types do not support some aggregations. | ||
*/ | ||
public class UnsupportedAggregationOnRollupIndex extends AggregationExecutionException { | ||
|
||
public UnsupportedAggregationOnRollupIndex(final String msg) { | ||
super(msg); | ||
} | ||
|
||
public UnsupportedAggregationOnRollupIndex(final StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
return RestStatus.BAD_REQUEST; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
...llup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/20_unsupported_aggs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
setup: | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
index: | ||
mode: time_series | ||
routing_path: [ uid ] | ||
time_series: | ||
start_time: 2021-04-28T00:00:00Z | ||
end_time: 2021-04-29T00:00:00Z | ||
mappings: | ||
properties: | ||
"@timestamp": | ||
type: date | ||
uid: | ||
type: keyword | ||
time_series_dimension: true | ||
total_memory_used: | ||
type: aggregate_metric_double | ||
metrics: [ min, max ] | ||
default_metric: min | ||
- do: | ||
bulk: | ||
refresh: true | ||
index: test | ||
body: | ||
- '{ "index": {} }' | ||
- '{ "@timestamp": "2021-04-28T18:50:00Z", "uid": "001", "total_memory_used": { "min": 99198, "max": 106780 } }' | ||
- '{ "index": {} }' | ||
- '{ "@timestamp": "2021-04-28T18:55:00Z", "uid": "002", "total_memory_used": { "min": 102334, "max": 110450 } }' | ||
- '{ "index": {} }' | ||
- '{ "@timestamp": "2021-04-28T18:50:00Z", "uid": "003", "total_memory_used": { "min": 98012, "max": 109009 } }' | ||
- '{ "index": {} }' | ||
- '{ "@timestamp": "2021-04-28T18:55:00Z", "uid": "004", "total_memory_used": { "min": 101990, "max": 120770 } }' | ||
|
||
--- | ||
"Histogram aggregation on aggregate_metric_double field": | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
total_memory_used_histogram: | ||
histogram: | ||
field: total_memory_used | ||
interval: 100000 | ||
|
||
|
||
- match: { status: 400 } | ||
# NOTE: the type of error is part of a contract with Kibana which uses it to detect specific | ||
# errors while running aggregations on rollup indices. | ||
- match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index } | ||
- match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [histogram]" } | ||
|
||
--- | ||
"Range aggregation on aggregate_metric_double field": | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
tx_range: | ||
range: | ||
field: total_memory_used | ||
ranges: | ||
- | ||
from: 0.0 | ||
to: 200.0 | ||
- | ||
from: 201.0 | ||
to: 400.0 | ||
- | ||
from: 401.0 | ||
|
||
- match: { status: 400 } | ||
# NOTE: the type of error is part of a contract with Kibana which uses it to detect specific | ||
# errors while running aggregations on rollup indices. | ||
- match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index } | ||
- match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [range]" } | ||
|
||
--- | ||
"Cardinality aggregation on aggregate_metric_double field": | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
tx_cardinality: | ||
cardinality: | ||
field: total_memory_used | ||
|
||
- match: { status: 400 } | ||
# NOTE: the type of error is part of a contract with Kibana which uses it to detect specific | ||
# errors while running aggregations on rollup indices. | ||
- match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index } | ||
- match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [cardinality]" } | ||
|
||
--- | ||
"Percentiles aggregation on aggregate_metric_double field": | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
tx_percentile: | ||
percentiles: | ||
field: total_memory_used | ||
percents: [90, 95, 99] | ||
|
||
- match: { status: 400 } | ||
# NOTE: the type of error is part of a contract with Kibana which uses it to detect specific | ||
# errors while running aggregations on rollup indices. | ||
- match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index } | ||
- match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [percentiles]" } | ||
|
||
--- | ||
"Top-metrics aggregation on aggregate_metric_double field": | ||
- skip: | ||
version: " - 8.4.99" | ||
reason: "rollup: unsupported aggregations errors added in 8.5.0" | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggs: | ||
top_total_memory_used: | ||
top_metrics: | ||
metrics: | ||
field: total_memory_used | ||
sort: | ||
uid: desc | ||
size: 2 | ||
|
||
|
||
- match: { status: 400 } | ||
# NOTE: the type of error is part of a contract with Kibana which uses it to detect specific | ||
# errors while running aggregations on rollup indices. | ||
- match: { error.root_cause.0.type: unsupported_aggregation_on_rollup_index } | ||
- match: { error.root_cause.0.reason: "Field [total_memory_used] of type [aggregate_metric_double] is not supported for aggregation [top_metrics]" } |
Oops, something went wrong.