Slide 1

Slide 1 text

Structured Logs embrace the power of machine-readable logs HELIO MEDEIROS @helmedeiros

Slide 2

Slide 2 text

Logging: The process of recording events during a computer program execution “

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

web.app { logs
 stream past present

Slide 6

Slide 6 text

22:55:40 INFO Initializing hub 22:55:40 INFO Starting web server 22:55:42 INFO Incoming connection from 127.0.0.1:37843 22:55:42 DEBUG Connection upgraded 22:55:42 DEBUG Receive message: “ping”

Slide 7

Slide 7 text

>>> logging

Slide 8

Slide 8 text

log = logging.getLogger() log.info("Starting web server”) log.debug(“Actual memory: %s”, $mem)

Slide 9

Slide 9 text

Structured logging: Logging events with specific fields (key= value) “

Slide 10

Slide 10 text

INFO[06-06|22:55:40] Incoming connection component= websocket.serveWs remote= 127.0.0.1:37843 event= connection.new INFO[06-06|22:55:40] Connection upgraded component= websocket.serveWs remote= 127.0.0.1:37843 event= connection.upgraded DEBUG[06-06|22:55:42] Receive message component= websocket.connection remote= 127.0.0.1:37843 event= message.new message= ping

Slide 11

Slide 11 text

>>> logging structured

Slide 12

Slide 12 text

>>> log = logging.getLogger() >>> log = log.bind( … user=“helio” … remote=“127.0.0.1:36509” … )

Slide 13

Slide 13 text

>>> log.info(“message.new”, message=“ping”) 22:55:42 DEBUG user=“helio” remote=“127.0.0.1:37843” event=“message.new” message=“ping”

Slide 14

Slide 14 text

“Unstructured” logs suffer from two big problems

Slide 15

Slide 15 text

1 It is difficult to parse

Slide 16

Slide 16 text

2 Individual messages lack context

Slide 17

Slide 17 text

{ “timestamp”: “Jun 6 15:33:06 +0000”, “app”: “web”, “message”: “Receive Message”, “event”: “message.new”, “ip”: “127.0.0.1”, “Trace-Id”: “48e276bd-cb52-4e12- abaf-2f0fcf746786” }

Slide 18

Slide 18 text

correlation identifiers: Unique identifier that allow reference to particular transactions or event chains “

Slide 19

Slide 19 text

Structured Logs embrace the power of machine-readable logs HELIO MEDEIROS @helmedeiros