Skip to content

Commit

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

fixes elastic#4321
  • Loading branch information
simitt committed Oct 15, 2020
1 parent aee52bf commit 3445551
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion changelogs/7.9.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ https://github.com/elastic/apm-server/compare/v7.9.2\...v7.9.3[View commits]

[float]
==== Bug fixes
* Ensure custom index names are lowercased {pull}4295[4295]
* Ensure custom index names are lowercased {pull}4295[4295],{pull}4322[4322]

[float]
[[release-notes-7.9.2]]
Expand Down
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
2 changes: 1 addition & 1 deletion tests/system/config/apm-server.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ apm-server:
{% if ilm_custom_suffix %}
ilm.setup.mapping:
- event_type: "error"
index_suffix: "custom"
index_suffix: "CUSTOM"
- event_type: "transaction"
index_suffix: "foo"
{% endif %}
Expand Down

0 comments on commit 3445551

Please sign in to comment.