Getting Envoy’s Access Logs

The simplest kind of Istio logging is Envoy’s access logging. Envoy proxies print access information to their standard output. The standard output of Envoy’s containers can then be printed by the kubectl logs command.

Before you begin

  • Setup Istio by following the instructions in the Installation guide.

    The egress gateway and access logging will be enabled if you install the demo configuration profile.

  • Deploy the sleep sample app to use as a test source for sending requests. If you have automatic sidecar injection enabled, run the following command to deploy the sample app:

    Zip

    1. $ kubectl apply -f @samples/sleep/sleep.yaml@

    Otherwise, manually inject the sidecar before deploying the sleep application with the following command:

    Zip

    1. $ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@)

    You can use any pod with curl installed as a test source.

  • Set the SOURCE_POD environment variable to the name of your source pod:

    1. $ export SOURCE_POD=$(kubectl get pod -l app=sleep -o jsonpath={.items..metadata.name})
  • Start the httpbin sample.

    If you have enabled automatic sidecar injection, deploy the httpbin service:

    Zip

    1. $ kubectl apply -f @samples/httpbin/httpbin.yaml@

    Otherwise, you have to manually inject the sidecar before deploying the httpbin application:

    Zip

    1. $ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@)

Enable Envoy’s access logging

If you used an IstioOperator CR to install Istio, add the following field to your configuration:

  1. spec:
  2. meshConfig:
  3. accessLogFile: /dev/stdout

Otherwise, add the equivalent setting to your original istioctl install command, for example:

  1. $ istioctl install <flags-you-used-to-install-Istio> --set meshConfig.accessLogFile=/dev/stdout

You can also choose between JSON and text by setting accessLogEncoding to JSON or TEXT.

You may also want to customize the format of the access log by editing accessLogFormat.

Refer to global mesh options for more information on all three of these settings:

  • meshConfig.accessLogFile
  • meshConfig.accessLogEncoding
  • meshConfig.accessLogFormat

Test the access log

  1. Send a request from sleep to httpbin:

    1. $ kubectl exec "$SOURCE_POD" -c sleep -- curl -v httpbin:8000/status/418
    2. ...
    3. < HTTP/1.1 418 Unknown
    4. < server: envoy
    5. ...
    6. -=[ teapot ]=-
    7. _...._
    8. .' _ _ `.
    9. | ."` ^ `". _,
    10. \_;`"---"`|//
    11. | ;/
    12. \_ _/
    13. `"""`
  2. Check sleep’s log:

    1. $ kubectl logs -l app=sleep -c istio-proxy
    2. [2020-10-30T12:36:44.547Z] "GET /status/418 HTTP/1.1" 418 - "-" 0 135 25 24 "-" "curl/7.69.1" "f13c2118-3ef9-9ed9-91b7-5d21358029c3" "httpbin:8000" "10.244.0.30:80" outbound|8000||httpbin.default.svc.cluster.local 10.244.0.29:46348 10.96.148.56:8000 10.244.0.29:44678 - default
  3. Check httpbin’s log:

    1. $ kubectl logs -l app=httpbin -c istio-proxy
    2. [2020-10-30T12:36:44.553Z] "GET /status/418 HTTP/1.1" 418 - "-" 0 135 3 2 "-" "curl/7.69.1" "f13c2118-3ef9-9ed9-91b7-5d21358029c3" "httpbin:8000" "127.0.0.1:80" inbound|8000|| 127.0.0.1:42940 10.244.0.30:80 10.244.0.29:46348 outbound_.8000_._.httpbin.default.svc.cluster.local default

Note that the messages corresponding to the request appear in logs of the Istio proxies of both the source and the destination, sleep and httpbin, respectively. You can see in the log the HTTP verb (GET), the HTTP path (/status/418), the response code (418) and other request-related information.

Cleanup

Shutdown the sleep and httpbin services:

ZipZip

  1. $ kubectl delete -f @samples/sleep/sleep.yaml@
  2. $ kubectl delete -f @samples/httpbin/httpbin.yaml@

Disable Envoy’s access logging

Remove, or set to "", the meshConfig.accessLogFile setting in your Istio install configuration.

In the example below, replace default with the name of the profile you used when you installed Istio.

  1. $ istioctl install --set profile=default
  2. Istio core installed
  3. Istiod installed
  4. Ingress gateways installed
  5. Installation complete

See also

Reworking our Addon Integrations

A new way to manage installation of telemetry addons.

Mixer and the SPOF Myth

Improving availability and reducing latency.

Mixer Adapter Model

Provides an overview of Mixer’s plug-in architecture.

Classifying Metrics Based on Request or Response (Experimental)

This task shows you how to improve telemetry by grouping requests and responses by their type.

Collecting Metrics for TCP Services

This task shows you how to configure Istio to collect metrics for TCP services.

Configurability (Beta/Development)

How to configure tracing options (beta/development).