This document describes how to configure structured logging for Envoy via Contour.
Contour allows you to choose from a set of JSON fields that will be expanded into Envoy templates and sent to Envoy. There is a default set of fields if you enable JSON logging, and you may customize which fields you log. Custom fields are not currently possible, however, we welcome PRs on the field list.
To enable the feature you have two options:
--accesslog-format=jsonto your Contour startup line
accesslog-format: jsonto your configuration file.
To customize the logged fields, add a
json-fields list of strings to your config file.
These strings must be options from the list of valid fields.
json-fields key is not specified, the default fields will be configured.
Field names not in that list will be silently dropped. (This is not ideal, watch #1507 for updates.)
The example config file contains the full list of fields as well.
Here is a sample config:
accesslog-format: json json-fields: - "@timestamp" - "authority" - "bytes_received" - "bytes_sent" - "downstream_local_address" - "downstream_remote_address" - "duration" - "method" - "path" - "protocol" - "request_id" - "requested_server_name" - "response_code" - "response_flags" - "uber_trace_id" - "upstream_cluster" - "upstream_host" - "upstream_local_address" - "upstream_service_time" - "user_agent" - "x_forwarded_for"