mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ElasticSearch: Improve ES error handling message (#61471)
Look for 'caused_by.reason' in ES error response When the ES response does not contain `reason` or `root_cause[0].reason` is empty, there is no information for the user to know what is going wrong. An example of the error message after this change: ``` Failed to evaluate queries and expressions: failed to execute query A: Trying to create too many buckets. Must be less than or equal to: [65536] but this number of buckets was exceeded. This limit can be set by changing the [search.max_buckets] cluster level setting. ``` Related to https://github.com/grafana/grafana/issues/61246
This commit is contained in:
parent
3e86a1b3d9
commit
b44df6c8d1
@ -711,12 +711,15 @@ func getErrorFromElasticResponse(response *es.SearchResponse) string {
|
|||||||
json := simplejson.NewFromAny(response.Error)
|
json := simplejson.NewFromAny(response.Error)
|
||||||
reason := json.Get("reason").MustString()
|
reason := json.Get("reason").MustString()
|
||||||
rootCauseReason := json.Get("root_cause").GetIndex(0).Get("reason").MustString()
|
rootCauseReason := json.Get("root_cause").GetIndex(0).Get("reason").MustString()
|
||||||
|
causedByReason := json.Get("caused_by").Get("reason").MustString()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case rootCauseReason != "":
|
case rootCauseReason != "":
|
||||||
errorString = rootCauseReason
|
errorString = rootCauseReason
|
||||||
case reason != "":
|
case reason != "":
|
||||||
errorString = reason
|
errorString = reason
|
||||||
|
case causedByReason != "":
|
||||||
|
errorString = causedByReason
|
||||||
default:
|
default:
|
||||||
errorString = "Unknown elasticsearch error response"
|
errorString = "Unknown elasticsearch error response"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user