Giter VIP home page Giter VIP logo

stern-clef's Introduction

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

stern-clef's People

Contributors

antonygggg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.