map $time_iso8601 $time_iso8601_dateTime {
  ~([^+]+) $1;
}
map $time_iso8601 $time_iso8601_TZ {
  ~\+([0-9:]+)$ $1;
}
map $msec $millisec {
  ~\.([0-9]+)$ $1;
}

log_format json escape=json '{ "nginx_timestamp": "$time_iso8601_dateTime.$millisec+$time_iso8601_TZ", '
       '"remote_addr": "$remote_addr", '
       '"connection": "$connection", '
       '"connection_requests": $connection_requests, '
       '"pipe": "$pipe", '
       '"body_bytes_sent": $body_bytes_sent, '
       '"request_length": $request_length, '
       '"request_time": $request_time, '
       '"response_status": $status, '
       '"request_uri": "$request_uri", '
       '"request_method": "$request_method", '
       '"host": "$host", '
       '"upstream_cache_status": "$upstream_cache_status", '
       '"upstream_addr": "$upstream_addr", '
       '"http_x_stapps_version": "$http_x_stapps_version", '
       '"http_x_forwarded_for": "$http_x_forwarded_for", '
       '"http_referrer": "$http_referer", '
       '"http_user_agent": "$http_user_agent", '
       '"http_version": "$server_protocol", '
       '"remote_user": "$remote_user", '
       '"http_x_forwarded_proto": "$http_x_forwarded_proto", '
       '"upstream_response_time": "$upstream_response_time", '
       '"nginx_access": true }';
