Skip to content

Tail Kubernetes logs from multiple pods in CLEF json format

Notifications You must be signed in to change notification settings

antonygggg/stern-clef

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Stern for Compact Log Event Format logs


Tail Kubernetes logs from multiple pods in CLEF json format


For example this log (using Serilog)

Log.Logger.Information("Service started at {nowUtc}", DateTime.UtcNow);

Will produce this log entry

{"@t":"2022-10-06T09:37:52.7066801Z","@m":"Service started at 10/06/2022 09:37:52","@i":"c16672c4","nowUtc":"2022-10-06T09:37:52.6986562Z"}

Usage:

In order to use this you need to have Stern installed globally (build and tested with Stern 1.22.0)

stern_clef.sh pod-query [flags_without_template]

examples

stern_clef.sh backend
stern_clef.sh backend-859348d699 -s 5m

To use any other custom template pass the --template argument , for Stern default template pass an empty string value and don't pass -o, --output argument

stern_clef.sh pod-query [flags_without_template] --template='<TEMPLATE>'

examples

stern_clef.sh backend --template=''
stern_clef.sh backend -s 5m --template='{{.Message}} ({{.Namespace}}/{{.PodName}}/{{.ContainerName}})'



Use Serilog to write structured logs compact log event format

https://github.com/serilog/serilog-formatting-compact#getting-started

Stern go templates examples

https://github.com/wercker/stern#examples

ANSI escape sequences and color codes

https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#8-16-colors


Read more:

https://clef-json.org

https://github.com/stern/stern

https://github.com/serilog

Releases

No releases published

Packages

No packages published

Languages