Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How log request and response body in Istio

I'd like to log request and response body from incoming traffic to each my microservice. Is it possible in Istio (Envoy) out-of-the-box? I don't see body attribute for mapping in Mixer's EntryLog. Maybe it will be added in future version of Istio?

Of course I can achieve this by implementing my own filter in microservise, but maybe there is better solution to achieve this.

like image 492
montana202 Avatar asked Dec 17 '18 12:12

montana202


People also ask

Where are Envoy logs stored?

Envoy logging By default Envoy system logs are sent to /dev/stderr . This can be overridden using --log-path . Envoy on a Windows system Envoy will output to CON by default. This can also be used as a logging path when configuring logging.

Does Istio use envoy?

Istio uses an extended version of the Envoy proxy. Envoy is a high-performance proxy developed in C++ to mediate all inbound and outbound traffic for all services in the service mesh. Envoy proxies are the only Istio components that interact with data plane traffic.


1 Answers

If I understand your question correctly, then you should check out this documentation of Lua filters. https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter#script-examples

body = handle:body() should give you the request or response body, depending upon the handle.

handle:logInfo(message) should help you log it.

For me print statement also had worked. e.g. print(headers["Cache-Control"]) was putting the header value in the log of my app on GCP project's kubernetes cluster.

You need to apply an EnvoyFilter in your kubernetes cluster and in the lua code, you can log the request body. Also keep in mind that 'The filter should be configured with the name envoy.lua' ONLY

like image 58
mjkool Avatar answered Sep 22 '22 14:09

mjkool