istio envoyfilter lua to do some logging
Sometimes for doing troubleshooting, we need to create an envoyfilter to logs certain responses or headers related data. To do so we can use the following example:-
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: log-headers
namespace: default
spec:
workloadSelector:
labels:
app: httpbin
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.lua
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
inlineCode: |
function envoy_on_request(request_handle)
request_handle:logInfo("Hey hey hey: " .. request_handle:headers():get(":path"))
end
Noticed that the envoy is scope to default namespace and not istio-system. If you placed this in istio-system, then you are applying it to the entire workload.
You might need to use "istioctl pc log httpbin-b5f55c9db-sh8hx --level=debug" to give it a kick, otherwise the log might stay hidden.
To view your logs, simply
k logs httpbin-b5f55c9db-sh8hx -n default -c istio-proxy -f | findstr "Hey hey"
Comments