From 8aaf19a4e7be7f3117a61a9ffe950710051ee66f Mon Sep 17 00:00:00 2001 From: StephanHCB Date: Thu, 4 Jul 2024 21:32:21 +0200 Subject: [PATCH] feat(#14): set ecs compatible field mapping default --- go.sum | 2 -- pkg/logging/config.go | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.sum b/go.sum index 72edf4b..c2e89f9 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/logging/config.go b/pkg/logging/config.go index 346806b..b8c1d06 100644 --- a/pkg/logging/config.go +++ b/pkg/logging/config.go @@ -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{ { @@ -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,