Skip to content

Commit

Permalink
fix: ensure ES index names are lowercase for ILM
Browse files Browse the repository at this point in the history
Ensure ILM custom index suffixes are also lowercased.

fixes elastic#4294
  • Loading branch information
simitt committed Oct 15, 2020
1 parent 650f454 commit 42fef4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion idxmgmt/ilm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package ilm

import (
"fmt"
"strings"
"time"

libcommon "github.com/elastic/beats/v7/libbeat/common"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (m *Mappings) Unpack(cfg *libcommon.Config) error {
mapping.Index = existing.Index
}
if mapping.IndexSuffix != "" {
mapping.Index = fmt.Sprintf("%s-%s", mapping.Index, mapping.IndexSuffix)
mapping.Index = fmt.Sprintf("%s-%s", mapping.Index, strings.ToLower(mapping.IndexSuffix))
}
(*m)[mapping.EventType] = mapping
}
Expand Down
4 changes: 2 additions & 2 deletions idxmgmt/ilm/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestConfig_Valid(t *testing.T) {
expected Config
}{
{name: "new policy and index suffix",
cfg: `{"setup":{"mapping":[{"event_type":"span","policy_name":"spanPolicy"},{"event_type":"metric","index_suffix":"production"},{"event_type":"error","index_suffix":"%{[observer.name]}"}],"policies":[{"name":"spanPolicy","policy":{"phases":{"foo":{}}}}]}}`,
cfg: `{"setup":{"mapping":[{"event_type":"span","policy_name":"spanPolicy"},{"event_type":"metric","index_suffix":"ProdUCtion"},{"event_type":"error","index_suffix":"%{[observer.name]}"}],"policies":[{"name":"spanPolicy","policy":{"phases":{"foo":{}}}}]}}`,
expected: Config{Mode: libilm.ModeAuto,
Setup: Setup{Enabled: true, Overwrite: false, RequirePolicy: true,
Mappings: map[string]Mapping{
Expand All @@ -129,7 +129,7 @@ func TestConfig_Valid(t *testing.T) {
"transaction": {EventType: "transaction", PolicyName: defaultPolicyName,
Index: "apm-9.9.9-transaction"},
"metric": {EventType: "metric", PolicyName: defaultPolicyName,
Index: "apm-9.9.9-metric-production", IndexSuffix: "production"},
Index: "apm-9.9.9-metric-production", IndexSuffix: "ProdUCtion"},
"profile": {EventType: "profile", PolicyName: defaultPolicyName,
Index: "apm-9.9.9-profile"},
},
Expand Down

0 comments on commit 42fef4d

Please sign in to comment.