Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure ES index names are lowercase for ILM #4322

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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