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

[7.10] fix: ensure ES index names are lowercase (#4295) #4303

Merged
merged 1 commit into from
Oct 12, 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
11 changes: 11 additions & 0 deletions changelogs/7.9.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@

https://github.com/elastic/apm-server/compare/7.8\...7.9[View commits]

* <<release-notes-7.9.3>>
* <<release-notes-7.9.2>>
* <<release-notes-7.9.1>>
* <<release-notes-7.9.0>>

[float]
[[release-notes-7.9.3]]
=== APM Server version 7.9.3

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]

[float]
[[release-notes-7.9.2]]
=== APM Server version 7.9.2
Expand Down
6 changes: 4 additions & 2 deletions idxmgmt/supporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package idxmgmt

import (
"fmt"
"strings"

"github.com/pkg/errors"
"go.uber.org/atomic"
Expand Down Expand Up @@ -176,6 +177,7 @@ func (s *supporter) buildSelector(cfg *common.Config, err error) (outil.Selector
MultiKey: "indices",
EnableSingleOnly: true,
FailEmpty: true,
Case: outil.SelectorLowerCase,
}
return outil.BuildSelectorFromConfig(cfg, buildSettings)
}
Expand Down Expand Up @@ -236,7 +238,7 @@ func getEventCustomIndex(evt *beat.Event) string {
// returns index from alias
if tmp := evt.Meta["alias"]; tmp != nil {
if alias, ok := tmp.(string); ok {
return alias
return strings.ToLower(alias)
}
}

Expand All @@ -245,7 +247,7 @@ func getEventCustomIndex(evt *beat.Event) string {
if idx, ok := tmp.(string); ok {
ts := evt.Timestamp.UTC()
return fmt.Sprintf("%s-%d.%02d.%02d",
idx, ts.Year(), ts.Month(), ts.Day())
strings.ToLower(idx), ts.Year(), ts.Month(), ts.Day())
}
}

Expand Down
10 changes: 5 additions & 5 deletions idxmgmt/supporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,26 @@ func TestIndexSupport_BuildSelector(t *testing.T) {
withIlm: "apm-7.0.0-sourcemap",
fields: common.MapStr{"processor.event": "sourcemap"},
},
"MetaInformationAlias": {
"MetaInformationAlia-lowercased": {
noIlm: "apm-7.0.0-meta",
withIlm: "apm-7.0.0-meta", //meta overwrites ilm
fields: common.MapStr{"processor.event": "span"},
meta: common.MapStr{"alias": "apm-7.0.0-meta", "index": "test-123"},
meta: common.MapStr{"alias": "APM-7.0.0-meta", "index": "test-123"},
cfg: common.MapStr{"output.elasticsearch.index": "apm-customized"},
},
"MetaInformationIndex": {
noIlm: fmt.Sprintf("apm-7.0.0-%s", day),
withIlm: fmt.Sprintf("apm-7.0.0-%s", day), //meta overwrites ilm
fields: common.MapStr{"processor.event": "span"},
meta: common.MapStr{"index": "apm-7.0.0"},
meta: common.MapStr{"index": "APM-7.0.0"},
cfg: common.MapStr{"output.elasticsearch.index": "apm-customized"},
},
"CustomIndex": {
"CustomIndex-lowercased": {
noIlm: "apm-customized",
withIlm: "apm-7.0.0-metric", //custom index ignored when ilm enabled
ilmAuto: "apm-customized", //custom respected for ilm auto
fields: common.MapStr{"processor.event": "metric"},
cfg: common.MapStr{"output.elasticsearch.index": "apm-customized"},
cfg: common.MapStr{"output.elasticsearch.index": "APM-customized"},
},
"DifferentCustomIndices": {
noIlm: fmt.Sprintf("apm-7.0.0-%s", day),
Expand Down