Collecting Logs
The Bookinfo sample application is usedas the example application throughout this task.
- in your cluster and deploy anapplication. This task assumes that Mixer is setup in a default configuration(). If you use a differentvalue, update the configuration and commands in this task to match the value.
If you use Istio 1.1.2 or prior, please use the following configuration instead:
$ kubectl apply -f @samples/bookinfo/telemetry/log-entry-crd.yaml@
- Send traffic to the sample application.
For the Bookinfo sample, visit http://$GATEWAY_URL/productpage
in your webbrowser or issue the following command:
- Verify that the log stream has been created and is being populated forrequests.
In a Kubernetes environment, search through the logs for the istio-telemetry
pods asfollows:
$ kubectl logs -n istio-system -l istio-mixer-type=telemetry -c mixer | grep "newlog" | grep -v '"destination":"telemetry"' | grep -v '"destination":"pilot"' | grep -v '"destination":"policy"' | grep -v '"destination":"unknown"'
{"level":"warn","time":"2018-09-15T20:46:36.009801Z","instance":"newlog.xxxxx.istio-system","destination":"details","latency":"13.601485ms","responseCode":200,"responseSize":178,"source":"productpage","user":"unknown"}
{"level":"warn","time":"2018-09-15T20:46:36.026993Z","instance":"newlog.xxxxx.istio-system","destination":"reviews","latency":"919.482857ms","responseCode":200,"responseSize":295,"source":"productpage","user":"unknown"}
In this task, you added Istio configuration that instructed Mixer toautomatically generate and report a new log stream for alltraffic within the mesh.
The added configuration controlled three pieces of Mixer functionality:
Generation of instances (in this example, log entries)from Istio attributes
Creation of handlers (configured Mixer adapters) capable of processinggenerated instances
The logs configuration directs Mixer to send log entries to stdout. It usesthree stanzas (or blocks) of configuration: instance configuration, handler_configuration, and _rule configuration.
The kind: instance
stanza of configuration defines a schema for generated log entries(or instances) named newlog
. This instance configuration tells Mixer _how_to generate log entries for requests based on the attributes reported by Envoy.
The severity
parameter is used to indicate the log level for any generatedlogentry
. In this example, a literal value of "warning"
is used. This value willbe mapped to supported logging levels by a logentry
handler.
The timestamp
parameter provides time information for all log entries. In thisexample, the time is provided by the attribute value of request.time
, asprovided by Envoy.
The parameter allows operators to configure what values should beincluded in each logentry
. A set of expressions controls the mapping from Istioattributes and literal values into the values that constitute a logentry
.In this example, each logentry
instance has a field named latency
populatedwith the value from the attribute response.duration
. If there is no knownvalue for response.duration
, the latency
field will be set to a duration of0ms
.
The kind: handler
stanza of configuration defines a handler named newloghandler
. Thehandler spec
configures how the stdio
compiled adapter code processes receivedlogentry
instances. The severity_levels
parameter controls how logentry
values for the field are mapped to supported logging levels. Here,the value of "warning"
is mapped to the WARNING
log level. TheoutputAsJson
parameter directs the adapter to generate JSON-formatted loglines.
The kind: rule
stanza of configuration defines a new rule named newlogstdio
. Therule directs Mixer to send all newlog
instances to thenewloghandler
handler. Because the match
parameter is set to true
, therule is executed for all requests in the mesh.
A match: true
expression in the rule specification is not required toconfigure a rule to be executed for all requests. Omitting the entire match
parameter from the spec
is equivalent to setting match: true
. It is includedhere to illustrate how to use match
expressions to control rule execution.
- Remove the new logs configuration:
If you are using Istio 1.1.2 or prior:
$ kubectl delete -f @samples/bookinfo/telemetry/log-entry-crd.yaml@
- If you are not planning to explore any follow-on tasks, refer to theBookinfo cleanup instructionsto shutdown the application.
Improving availability and reducing latency.
Provides an overview of Mixer's plug-in architecture.
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.
This task shows you how to configure Envoy proxies to print access log to their standard output.
Learn how to configure the proxies to send tracing requests to Jaeger.