mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: add frozen indices search support (#27472)
* Elasticsearch: Add frozen indices support for alerting
This commit is contained in:
@@ -308,12 +308,20 @@ func (c *baseClientImpl) createMultiSearchRequests(searchRequests []*SearchReque
|
||||
}
|
||||
|
||||
func (c *baseClientImpl) getMultiSearchQueryParameters() string {
|
||||
var qs []string
|
||||
|
||||
if c.version >= 70 {
|
||||
maxConcurrentShardRequests := c.getSettings().Get("maxConcurrentShardRequests").MustInt(5)
|
||||
return fmt.Sprintf("max_concurrent_shard_requests=%d", maxConcurrentShardRequests)
|
||||
qs = append(qs, fmt.Sprintf("max_concurrent_shard_requests=%d", maxConcurrentShardRequests))
|
||||
|
||||
includeFrozen := c.getSettings().Get("includeFrozen").MustBool(false)
|
||||
|
||||
if includeFrozen {
|
||||
qs = append(qs, "ignore_throttled=false")
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
return strings.Join(qs, "&")
|
||||
}
|
||||
|
||||
func (c *baseClientImpl) MultiSearch() *MultiSearchRequestBuilder {
|
||||
|
||||
@@ -250,6 +250,7 @@ func TestClient(t *testing.T) {
|
||||
"maxConcurrentShardRequests": 100,
|
||||
"timeField": "@timestamp",
|
||||
"interval": "Daily",
|
||||
"includeFrozen": true,
|
||||
}),
|
||||
}, func(sc *scenarioContext) {
|
||||
sc.responseBody = `{
|
||||
@@ -271,6 +272,7 @@ func TestClient(t *testing.T) {
|
||||
So(sc.request, ShouldNotBeNil)
|
||||
So(sc.request.Method, ShouldEqual, http.MethodPost)
|
||||
So(sc.request.URL.Path, ShouldEqual, "/_msearch")
|
||||
So(sc.request.URL.RawQuery, ShouldNotContainSubstring, "ignore_throttled=")
|
||||
|
||||
So(sc.requestBody, ShouldNotBeNil)
|
||||
|
||||
@@ -312,6 +314,7 @@ func TestClient(t *testing.T) {
|
||||
"maxConcurrentShardRequests": 6,
|
||||
"timeField": "@timestamp",
|
||||
"interval": "Daily",
|
||||
"includeFrozen": true,
|
||||
}),
|
||||
}, func(sc *scenarioContext) {
|
||||
sc.responseBody = `{
|
||||
@@ -333,7 +336,8 @@ func TestClient(t *testing.T) {
|
||||
So(sc.request, ShouldNotBeNil)
|
||||
So(sc.request.Method, ShouldEqual, http.MethodPost)
|
||||
So(sc.request.URL.Path, ShouldEqual, "/_msearch")
|
||||
So(sc.request.URL.RawQuery, ShouldEqual, "max_concurrent_shard_requests=6")
|
||||
So(sc.request.URL.RawQuery, ShouldContainSubstring, "max_concurrent_shard_requests=6")
|
||||
So(sc.request.URL.RawQuery, ShouldContainSubstring, "ignore_throttled=false")
|
||||
|
||||
So(sc.requestBody, ShouldNotBeNil)
|
||||
|
||||
@@ -350,6 +354,7 @@ func TestClient(t *testing.T) {
|
||||
So(jHeader.Get("index").MustString(), ShouldEqual, "metrics-2018.05.15")
|
||||
So(jHeader.Get("ignore_unavailable").MustBool(false), ShouldEqual, true)
|
||||
So(jHeader.Get("search_type").MustString(), ShouldEqual, "query_then_fetch")
|
||||
So(jHeader.Get("ignore_throttled").MustBool(), ShouldBeFalse)
|
||||
|
||||
Convey("and replace $__interval variable", func() {
|
||||
So(jBody.GetPath("aggs", "2", "aggs", "1", "avg", "script").MustString(), ShouldEqual, "15000*@hostname")
|
||||
|
||||
Reference in New Issue
Block a user