Skip to content

Commit

Permalink
elastic: backend migration: fix no-index case
Browse files Browse the repository at this point in the history
  • Loading branch information
gabor committed May 16, 2023
1 parent 14fb4ff commit f9b7e3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/tsdb/elasticsearch/client/client_test.go
Expand Up @@ -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-*",
Expand Down
7 changes: 6 additions & 1 deletion pkg/tsdb/elasticsearch/client/index_pattern.go
Expand Up @@ -35,7 +35,12 @@ type staticIndexPattern struct {
}

func (ip *staticIndexPattern) GetIndices(timeRange backend.TimeRange) ([]string, error) {
return []string{ip.indexName}, nil
name := ip.indexName
if name != "" {
return []string{name}, nil
} else {
return []string{}, nil
}
}

type intervalGenerator interface {
Expand Down

0 comments on commit f9b7e3e

Please sign in to comment.