envoy: add duration and size to access log (#735)

This commit is contained in:
Caleb Doxsey 2020-05-19 12:11:48 -06:00 committed by GitHub
parent e30e717942
commit d2e463e9ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package controlplane
import (
envoy_service_accesslog_v2 "github.com/envoyproxy/go-control-plane/envoy/service/accesslog/v2"
"github.com/golang/protobuf/ptypes"
"github.com/pomerium/pomerium/internal/log"
)
@ -32,6 +33,9 @@ func (srv *Server) StreamAccessLogs(stream envoy_service_accesslog_v2.AccessLogS
evt = evt.Str("forwarded-for", entry.GetRequest().GetForwardedFor())
evt = evt.Str("request-id", entry.GetRequest().GetRequestId())
// response properties
dur, _ := ptypes.Duration(entry.CommonProperties.TimeToLastDownstreamTxByte)
evt = evt.Dur("duration", dur)
evt = evt.Uint64("size", entry.Response.ResponseBodyBytes)
evt = evt.Uint32("response-code", entry.GetResponse().GetResponseCode().GetValue())
evt = evt.Str("response-code-details", entry.GetResponse().GetResponseCodeDetails())
evt.Msg("http-request")