Closed posix4e closed 2 years ago
That would likely be better for elk or splunk ingestion. The logging is largely outside of my control at the moment (either dominated by glog'ing within-in kubernetes or logrus'ing with-in cloudflared). Both offer some ability to configure a JSON writer or formatter respectively; though, you'd likely only get something of the format:
{"level":"info","msg":"Tremendously sized cow enters the ocean.","time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
note: the entire log line would be in message as
cloudflared
does not use a field logger internally
These would all still be separate log lines
time="2019-01-03T15:01:01Z" level=debug msg="GET http://echo.default:80/ HTTP/1.1" CF-RAY=4936569ebc098c52-SFO-DOG
time="2019-01-03T15:01:01Z" level=debug msg="Request Headers map[Accept-Encoding:[gzip] Cookie:[__cfduid=db34184b8cd35697717524f702c0d62e81546526684] Cf-Ray:[4936569ebc098c52-SFO-DOG] X-Forwarded-Proto:[http] Cf-Visitor:[{\"scheme\":\"http\"}] Cache-Control:[max-age=0] Accept:[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8] Cf-Connecting-Ip:[2606:4700:2001:10d:0:0:0:a] Cf-Ipcountry:[US] X-Forwarded-For:[2606:4700:2001:10d:0:0:0:a] Accept-Language:[en-US,en;q=0.9] Upgrade-Insecure-Requests:[1] User-Agent:[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36]]"
time="2019-01-03T15:01:01Z" level=debug msg="200 OK" CF-RAY=4936569ebc098c52-SFO-DOG
time="2019-01-03T15:01:01Z" level=debug msg="Response Headers map[Date:[Thu, 03 Jan 2019 15:01:01 GMT] Content-Type:[text/plain] Connection:[keep-alive] Server:[echoserver]]"
An optional label
would be nice as well in case you run multiple ingresses.
Would it be possible to have cloudflare output json logs instead of the current format?