dskit icon indicating copy to clipboard operation
dskit copied to clipboard

How to configure Logger in yaml

Open icemanDD opened this issue 1 year ago • 5 comments
trafficstars

We are getting this error when try exporter logs from Tempo as json format: {"index"=>{"status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [ts] of type [float] in document with id 'wsMnW5AB6IW1ExbRjrjx'. Preview of field's value: '2024-06-27T19:23:52.997740845Z'", "caused_by"=>{"type"=>"number_format_exception", "reason"=>"For input string: \"2024-06-27T19:23:52.997740845Z\""}}}}

and i notice this in dskit server config

Log                          gokit_log.Logger `yaml:"-"`

Is it possible to configure the logger in yaml to remove ts or rename ts to timestamp to match our logging system schema?

icemanDD avatar Jun 27 '24 20:06 icemanDD

You can set Log field in the code before creating Server, then configuration options for setting up logger will be ignored, and supplied logger will be used instead.

pstibrany avatar Jul 01 '24 08:07 pstibrany

You can set Log field in the code before creating Server

We are directly using Tempo image, can you help provide some example to set the Log field?

icemanDD avatar Jul 01 '24 17:07 icemanDD

Tempo log level can be configured with the following.

server:
  log_level: debug

It doesn't look like we currently expose log_format on the server as a config option.

zalegrala avatar Jul 01 '24 17:07 zalegrala

log_format is configurable to json, and this is the configurable list: https://github.com/grafana/dskit/blob/main/server/server.go#L135-L144

However, they are not helpful to tune the logger field ts or rename ts to timestamp to match our logging system schema

icemanDD avatar Jul 01 '24 17:07 icemanDD

I am thinking adding some config like log_fields which will accept a list of key value pairs to override what is already configured in the logger

icemanDD avatar Jul 01 '24 17:07 icemanDD