montana202
montana202

Reputation: 91

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.

Upvotes: 9

Views: 10273

Answers (1)

mjkool
mjkool

Reputation: 230

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

Upvotes: 8

Related Questions