The Envoy proxies can be configured to export their access logs in OpenTelemetry format. In this example, the proxies send access logs to an OpenTelemetry collector, which is configured to print the logs to standard output. The standard output of the OpenTelemetry collector can then be accessed via the kubectl logs command.

Before you begin

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

  • 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:

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

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

    $ kubectl apply -f <(istioctl kube-inject -f @samples/sleep/sleep.yaml@)
  • Set the SOURCE_POD environment variable to the name of your source pod:

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

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

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

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

    $ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@)
  • Create a namespace for the OpenTelemetry Collector:

    $ kubectl create namespace observability
  • Deploy the OpenTelemetry Collector. You can use this example configuration as a starting point: otel.yaml

    $ kubectl apply -f @samples/open-telemetry/otel.yaml@ -n observability

Enable Envoy’s access logging

To enable access logging, use the Telemetry API.

Edit MeshConfig to add an OpenTelemetry provider, named otel. This involves adding an extension provider stanza:

- name: otel
    service: opentelemetry-collector.observability.svc.cluster.local
    port: 4317

The final configuration should look something like:

apiVersion: v1
kind: ConfigMap
  name: istio
  namespace: istio-system
  mesh: |-
    accessLogFile: /dev/stdout
      discoveryAddress: istiod.istio-system.svc:15012
      proxyMetadata: {}
          address: zipkin.istio-system:9411
    enablePrometheusMerge: true
    - name: otel
        service: opentelemetry-collector.observability.svc.cluster.local
        port: 4317
    rootNamespace: istio-system
    trustDomain: cluster.local
  meshNetworks: 'networks: {}'

Next, add a Telemetry resource that tells Istio to send access logs to the OpenTelemetry collector.

$ cat <<EOF | kubectl apply -n default -f -
kind: Telemetry
  name: sleep-logging
      app: sleep
    - providers:
      - name: otel

The above example uses the otel access log provider, and we do not configure anything other than default settings.

Similar configuration can also be applied on an individual namespace, or to an individual workload, to control logging at a fine grained level.

For more information about using the Telemetry API, see the Telemetry API overview.

Using Mesh Config

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

    accessLogFile: /dev/stdout
    - name: otel
        service: opentelemetry-collector.observability.svc.cluster.local
        port: 4317
      - envoy
      - otel

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

$ istioctl install -f <your-istio-operator-config-file>

Default access log format

Istio will use the following default access log format if accessLogFormat is not specified:


The following table shows an example using the default access log format for a request sent from sleep to httpbin:

Log operatoraccess log in sleepaccess log in httpbin
\"%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%\""GET /status/418 HTTP/1.1""GET /status/418 HTTP/1.1"

Test the access log

  1. Send a request from sleep to httpbin:

    $ kubectl exec "$SOURCE_POD" -c sleep -- curl -sS -v httpbin:8000/status/418
    < HTTP/1.1 418 Unknown
    < server: envoy
        -=[ teapot ]=-
         .'  _ _ `.
        | ."` ^ `". _,
          |       ;/
          \_     _/
  2. Check otel-collector’s log:

    $ kubectl logs -l app=opentelemetry-collector -n observability
    [2020-11-25T21:26:18.409Z] "GET /status/418 HTTP/1.1" 418 - via_upstream - "-" 0 135 3 1 "-" "curl/7.73.0-DEV" "84961386-6d84-929d-98bd-c5aee93b5c88" "httpbin:8000" "" inbound|8000|| 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.


Shutdown the sleep and httpbin services:

$ kubectl delete telemetry sleep-logging
$ kubectl delete -f @samples/sleep/sleep.yaml@
$ kubectl delete -f @samples/httpbin/httpbin.yaml@
$ kubectl delete -f @samples/open-telemetry/otel.yaml@ -n istio-system
$ kubectl delete namespace observability

Disable Envoy’s access logging

Remove, or set to "", the meshConfig.extensionProviders and meshConfig.defaultProviders setting in your Istio install configuration.

$ istioctl install --set profile=default
✔ Istio core installed
✔ Istiod installed
✔ Ingress gateways installed
✔ Installation complete
Was this information useful?
Do you have any suggestions for improvement?

Thanks for your feedback!