About access logging

Access logs, sometimes referred to as audit logs, represent all traffic requests that pass through the ingress gateway. The access log entries can be customized to include data from the request, the routing destination, and the response.

Access logs can be written to a file, the stdout stream of the gateway proxy container, or exported to a gRPC server for custom handling.

Envoy data that can be logged

Envoy exposes a lot of data that can be used when customizing access logs. The following data properties are available for both TCP and HTTP access logging:

  • The downstream (client) address, connection information, TLS configuration, and timing
  • The upstream (service) address, connection information, TLS configuration, timing, and Envoy routing information
  • Relevant Envoy configuration, such as rate of sampling (if used)
  • Filter-specific context that is published to Envoy’s dynamic metadata during the filter chain

Additional HTTP properties

When Envoy is used as an HTTP proxy, additional HTTP information is available for access logging, including:

  • Request data, including the method, path, scheme, port, user agent, headers, body, and more
  • Response data, including the response code, headers, body, and trailers, as well as a string representation of the response code
  • Protocol version

Before you begin

  1. Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.

  2. Get the external address of the gateway and save it in an environment variable.

Set up access logging for stdout

  1. Create a ListenerOption resource to define your access logging rules. The following example writes access logs to the stdout stream of the ingress gateway container. Because no custom string format is defined, the default Envoy format is used.

      kubectl apply -f- <<EOF
    apiVersion: gateway.solo.io/v1
    kind: ListenerOption
      name: access-logs
      namespace: gloo-system
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: http
          - fileSink:
              path: /dev/stdout
              stringFormat: ""
  2. Send a request to the httpbin app on the www.example.com domain. Verify that your request succeeds and that you get back a 200 HTTP response code.

    Example output:

      HTTP/1.1 200 OK
    access-control-allow-credentials: true
    access-control-allow-origin: *
    date: Fri, 07 Jun 2024 21:10:03 GMT
    x-envoy-upstream-service-time: 2
    server: envoy
    transfer-encoding: chunked
  3. Get the logs for the gateway pod and verify that you see an entry for each request that you sent to the httpbin app.

      kubectl logs -n gloo-system deploy/gloo-proxy-http

    Example output:

      [2024-06-07T21:10:03.139Z] "HEAD /status/200 HTTP/1.1" 200 - 0 0 3 2 "-" "curl/7.77.0" "9fc55ba1-ff39-4868-b1be-5e8347faeaa5" "www.example.com:8080" "10.XX.X.XX:8080"


Remove the resources that you created in this guide.

  kubectl delete listeneroption access-logs -n gloo-system