diff --git a/docs/containers.conf.5.md b/docs/containers.conf.5.md index cee1354c1..7f6fe4dd0 100644 --- a/docs/containers.conf.5.md +++ b/docs/containers.conf.5.md @@ -186,6 +186,10 @@ that no size limit is imposed. If it is positive, it must be >= 8192 to match/exceed conmon's read buffer. The file is truncated and re-opened so the limit is never exceeded. +**log_tag**="" + +Default format tag for container log messages. This is useful for creating a specific tag for container log messages. Container log messages default to using the truncated container ID as a tag. + **netns**="private" Default way to to create a NET namespace for the container. diff --git a/pkg/config/config.go b/pkg/config/config.go index edd52f49d..056519e60 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -137,6 +137,11 @@ type ContainersConfig struct { // Negative values indicate that the log file won't be truncated. LogSizeMax int64 `toml:"log_size_max,omitempty"` + // Specifies default format tag for container log messages. + // This is useful for creating a specific tag for container log messages. + // container log, messages. Containers logs default to truncated container ID as a tag. + LogTag string `toml:"log_tag,omitempty"` + // NetNS indicates how to create a network namespace for the container NetNS string `toml:"netns,omitempty"` diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e482b03e8..531e125ac 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -329,6 +329,9 @@ var _ = Describe("Config", func() { gomega.Expect(err).To(gomega.BeNil()) gomega.Expect(config).ToNot(gomega.BeNil()) gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("overridden-default")) + gomega.Expect(config.Containers.LogDriver).To(gomega.Equal("journald")) + gomega.Expect(config.Containers.LogTag).To(gomega.Equal("{{.Name}}|{{.ID}}")) + gomega.Expect(config.Containers.LogSizeMax).To(gomega.Equal(int64(100000))) gomega.Expect(config.Engine.ImageParallelCopies).To(gomega.Equal(uint(10))) gomega.Expect(config.Engine.ImageDefaultFormat).To(gomega.Equal("v2s2")) }) diff --git a/pkg/config/containers.conf b/pkg/config/containers.conf index b9ac2c761..21415dca2 100644 --- a/pkg/config/containers.conf +++ b/pkg/config/containers.conf @@ -166,6 +166,12 @@ default_sysctls = [ # # log_size_max = -1 +# Specifies default format tag for container log messages. +# This is useful for creating a specific tag for container log messages. +# messages. Containers logs default to truncated container ID as a tag. +# +# log_tag = "" + # Default way to to create a Network namespace for the container # Options are: # `private` Create private Network Namespace for the container. diff --git a/pkg/config/testdata/containers_override.conf b/pkg/config/testdata/containers_override.conf index 39dfa9f40..4d4f7ae17 100644 --- a/pkg/config/testdata/containers_override.conf +++ b/pkg/config/testdata/containers_override.conf @@ -1,6 +1,9 @@ [containers] apparmor_profile = "overridden-default" +log_driver = "journald" +log_tag="{{.Name}}|{{.ID}}" +log_size_max = 100000 [engine] image_parallel_copies=10