[v10.0.x] Elasticsearch: Handle no-index case in backend mode (#68629)

Elasticsearch: Handle no-index case in backend mode (#68534)

* elastic: backend migration: fix no-index case

* improved code

(cherry picked from commit fcef387151)

Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-05-17 13:39:07 +00:00
committed by GitHub
co-authored by Gábor Farkas
parent 3c1b5dda40
commit 21e2ac6d8a
2 changed files with 11 additions and 1 deletions
@@ -118,6 +118,12 @@ func TestClient_Index(t *testing.T) {
patternInDatasource string
indexInRequest []string
}{
{
name: "empty string",
indexInDatasource: "",
patternInDatasource: "",
indexInRequest: []string{},
},
{
name: "single string",
indexInDatasource: "logs-*",
@@ -35,7 +35,11 @@ type staticIndexPattern struct {
}
func (ip *staticIndexPattern) GetIndices(timeRange backend.TimeRange) ([]string, error) {
return []string{ip.indexName}, nil
if ip.indexName != "" {
return []string{ip.indexName}, nil
} else {
return []string{}, nil
}
}
type intervalGenerator interface {