stern
stern copied to clipboard
Tailing logs with JSON output.
Do the current stern options support JSON log output from pods with traditional stern color?
A subset of our pods currently output JSON logs with additional fields. An example Stern output (Stern 1.10):
dsj-stat-builder-service-daemon-55444b74cb-zwtfx dsj-stat-builder-service-daemon {"@timestamp":"2019-01-08T03:13:41.573Z","source_host":"dsj-stat-builder-service-daemon-55444b74cb-zwtfx","file":"Bucket.java","method":"readMetadataFromFS","level":"INFO","line_number":"441","thread_name":"Step Runner for count-records-and-segments","@version":1,"logger_name":"com.rapleaf.formats.bucket.Bucket","message":"Metadata obtained at gs://liveramp-eng-dist-incoming-data/input_data/data/spruce/persistent/data_sync_requests_by_job_id/1610409_1546917039906/bucket.meta","class":"com.rapleaf.formats.bucket.Bucket","mdc":{"run_identifier":"2010629208","joblet_identifier":"1736402519276071327217165","application":"dsj-stat-builder","workflow_execution_id":"344533283","workflow_attempt_id":"355297393","source_host":"dsj-stat-builder-service-daemon-55444b74cb-zwtfx","team":"dev-dist"}}
I am able to parse these using JQ, but haven't been able to figure out how to preserve Stern's color coding while doing so. Is this currently supported/I need to read the docs better or is additional parsing of json log messages not yet a feature?