Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does stackdriver logging assert the severity of an entry?

I recently started using stackdriver logging on my Kubernetes cluster. The service are logging json payloads. In stackdriver logging I see the json payload parsed correctly, but everything has severity "ERROR". This is not intended. Most of these logs aren't errors. They also do not contain error fields or similar fields. Is there a way to tell stackdriver how to determine the severity of a log entry received from the log agent in kubernetes? Or do I need to modify my structured log output in some way to make stackdriver understand it better?

Thanks in advance.

like image 606
Till Klocke Avatar asked Apr 04 '17 13:04

Till Klocke


2 Answers

If you put a severity field into your JSON record, the Stackdriver logging agent should turn that into the entry severity. Otherwise it hard-codes ERROR for stderr and INFO for stdout (for Kubernetes logs).

like image 108
Igor Peshansky Avatar answered Nov 11 '22 10:11

Igor Peshansky


A simple example of payload: as of August 2018, if you log the string

{"msg" : "starting", "severity" : "INFO"}

Stackdriver will show

{
  ...
  jsonPayload: { msg:  "starting" },
  severity:  "INFO"   
}

and the resulting severity will be INFO (with the blue icon).

like image 38
ticofab Avatar answered Nov 11 '22 10:11

ticofab