Getting Envoy's Access Logs

The simplest kind of Istio logging isEnvoy’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

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})

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

Edit the istio configuration map:

  1. $ istioctl manifest apply --set values.global.proxy.accessLogFile="/dev/stdout"
  2. configmap "istio" replaced

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

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

All three of these parameters may also be configured via install options:

  • global.proxy.accessLogFile
  • global.proxy.accessLogEncoding
  • global.proxy.accessLogFormat

Test the access log

  • Send a request from sleep to httpbin:
  1. $ kubectl exec -it $(kubectl get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}') -c sleep -- curl -v httpbin:8000/status/418
  2. * Trying 172.21.13.94...
  3. * TCP_NODELAY set
  4. * Connected to httpbin (172.21.13.94) port 8000 (#0)
  5. > GET /status/418 HTTP/1.1
  6. ...
  7. < HTTP/1.1 418 Unknown
  8. < server: envoy
  9. ...
  10. -=[ teapot ]=-
  11. _...._
  12. .' _ _ `.
  13. | ."` ^ `". _,
  14. \_;`"---"`|//
  15. | ;/
  16. \_ _/
  17. `"""`
  18. * Connection #0 to host httpbin left intact
  • Check sleep’s log:
  1. $ kubectl logs -l app=sleep -c istio-proxy
  2. [2019-03-06T09:31:27.354Z] "GET /status/418 HTTP/1.1" 418 - "-" 0 135 11 10 "-" "curl/7.60.0" "d209e46f-9ed5-9b61-bbdd-43e22662702a" "httpbin:8000" "172.30.146.73:80" outbound|8000||httpbin.default.svc.cluster.local - 172.21.13.94:8000 172.30.146.82:60290 -
  • Check httpbin’s log:
  1. $ kubectl logs -l app=httpbin -c istio-proxy
  2. [2019-03-06T09:31:27.360Z] "GET /status/418 HTTP/1.1" 418 - "-" 0 135 5 2 "-" "curl/7.60.0" "d209e46f-9ed5-9b61-bbdd-43e22662702a" "httpbin:8000" "127.0.0.1:80" inbound|8000|http|httpbin.default.svc.cluster.local - 172.30.146.73:80 172.30.146.82:38618 outbound_.8000_._.httpbin.default.svc.cluster.local

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

Edit the istio configuration map and set accessLogFile to "".

  1. $ istioctl manifest apply
  2. configmap "istio" replaced

See also

Mixer and the SPOF Myth

Improving availability and reducing latency.

Mixer Adapter Model

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

Collecting Logs

This task shows you how to configure Istio to collect and customize logs.

Collecting Metrics

This task shows you how to configure Istio to collect and customize metrics.

Collecting Metrics for TCP services

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

Jaeger

Learn how to configure the proxies to send tracing requests to Jaeger.