Skip to content

Commit

Permalink
Merge pull request #15 from StephanHCB/issue-14-mapping-defaults
Browse files Browse the repository at this point in the history
feat(#14): set ecs compatible field mapping default
  • Loading branch information
Roshick authored Jul 5, 2024
2 parents 47bcb41 + 8aaf19a commit 16f831e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
9 changes: 8 additions & 1 deletion pkg/logging/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func (c *Config) HandlerOptions() *slog.HandlerOptions {
}
}

const DefaultMapping = `{
"time": "@timestamp",
"level": "log.level",
"msg": "message",
"error": "error.message"
}`

func (c *Config) ConfigItems() []auconfigapi.ConfigItem {
return []auconfigapi.ConfigItem{
{
Expand All @@ -72,7 +79,7 @@ func (c *Config) ConfigItems() []auconfigapi.ConfigItem {
}, {
Key: DefaultConfigKeyAttributeKeyMappings,
EnvName: DefaultConfigKeyAttributeKeyMappings,
Default: "{}",
Default: DefaultMapping,
Description: "Mappings for attribute keys of all logs. \n" +
"Example: The entry [error: error.message] maps every attribute with key \"error\" to use the key \"error.message\" instead.",
Validate: auconfigapi.ConfigNeedsNoValidation,
Expand Down

0 comments on commit 16f831e

Please sign in to comment.