Skip to content

Instantly share code, notes, and snippets.

@afirth
Created July 31, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afirth/35f2e422fd056c776a4463a5948cf6fd to your computer and use it in GitHub Desktop.
Save afirth/35f2e422fd056c776a4463a5948cf6fd to your computer and use it in GitHub Desktop.
JSON logs for ingress-nginx (stackdriver compatible)
log-format-escape-json: "true"
http-snippet: |
map $msec $timestamp_secs { ~(.*)\..* $1; }
map $msec $timestamp_nanos { ~.*\.(?<tsn>.*) "${tsn}000000"; }
log-format-upstream: '{"timestampSeconds":"$timestamp_secs", "timestampNanos":"$timestamp_nanos", "time_epoch":"$msec", "time_iso8601":"$time_iso8601", "remote_addr":"$proxy_protocol_addr", "x-forward-for":"$proxy_add_x_forwarded_for", "request_id":"$req_id", "remote_user":"$remote_user", "bytes_sent":$bytes_sent, "request_time":$request_time, "status":$status, "vhost":"$host", "request_proto":"$server_protocol", "path":"$uri", "request_query":"$args", "request_length":$request_length, "duration":$request_time, "method":"$request_method", "http_referrer":"$http_referer", "http_user_agent":"$http_user_agent" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment