Reputation: 949
I have one question regarding the access log of envoy:
%REQ(:AUTHORITY)%
, can I remove the port?Or is there another fields which include the AUTHORITY
and doesn't include the port?
Upvotes: 1
Views: 1303
Reputation: 5267
First, the "%REQ(:AUTHORITY)%"
field does not contain any information about the port. Look at this official documentation:
Format strings are plain strings, specified using the
format
key. They may contain either command operators or other characters interpreted as a plain string. The access log formatter does not make any assumptions about a new line separator, so one has to specified as part of the format string. See the default format for an example.
If custom format string is not specified, Envoy uses the following default format:
[%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%"
%RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION%
%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%"
"%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n
Example of the default Envoy access log format:
[2016-04-15T20:17:00.310Z] "POST /api/v1/locations HTTP/2" 204 - 154 0 226 100 "10.0.35.28"
"nsq2http" "cc21d9b0-cf5c-432b-8c7e-98aeb7988cd2" "locations" "tcp://10.0.2.1:80"
Field "%REQ(:AUTHORITY)%"
shows value "locations"
and field "%UPSTREAM_HOST%"
shows "tcp://10.0.2.1:80"
.
You can customise your log format based on format keys.
Here you can find good article about understanding these logs. Field "%REQ(:AUTHORITY)%"
is value of the Host
(HTTP/1.1) or Authority
(HTTP/2) header. Look at this picture to better understand.
I suppose you want to edit the field "%UPSTREAM_HOST%"
It is impossible to remove the port from this field. You can find documentation with description of these fields here:
%UPSTREAM_HOST%
Upstream host URL (e.g., tcp://ip:port for TCP connections).
I haven't found any other field that returns just an IP address without a port.
Answering your question:
- I use the field host:
%REQ(:AUTHORITY)%
, can I remove the port ?
No, because this field does not return a port at all.
is there another fields which include the AUTHORITY and doesnt include the port?
You can use %REQ(:AUTHORITY)%
field without "%UPSTREAM_HOST%"
field. You can do this by creating your custom log format. As far as I know it is impossible to have only IP adress without port in the logs.
Upvotes: 1