moresandeep opened a new pull request #536:
URL: https://github.com/apache/knox/pull/536
## What changes were proposed in this pull request?
This PR adds correlation id generated by Knox to gateway logs. In case where
a request comes to Knox with header `X-Request-Id` that value is logged instead
as trace id. This feature can be turned off by removing `%X{trace_id}` variable
from `gateway-log4j2.xml` file.
Correlation is a random UUID or 16 random bytes, in hexadecimal if
[generated by
nginx](https://www.nginx.com/blog/application-tracing-nginx-plus/).
One thing to note is that with this PR if correlation id is present it will
be logged so it will slightly increase log size.
## How was this patch tested?
Tested locally on single knox instance.
e.g.
`
curl -k -u guest:guest-password -X GET -H "X-Request-Id: 1234567890ABCD"
https://localhost:8443/gateway/sandbox/webhdfs/v1/tmp/hello.txt\?op\=LISTSTATUS
`
```
==>
/Users/smore/dev/committer/knox/install/knox-2.0.0-SNAPSHOT/logs/gateway.log <==
2022-02-15 14:05:42,850 1234567890ABCD INFO knox.gateway
(KnoxLdapRealm.java:getUserDn(688)) - Computed userDn:
uid=guest,ou=people,dc=hadoop,dc=apache,dc=org using dnTemplate for principal:
guest
==>
/Users/smore/dev/committer/knox/install/knox-2.0.0-SNAPSHOT/logs/gateway-audit.log
<==
22/02/15 14:05:43
||1234567890ABCD|audit|127.0.0.1|WEBHDFS|guest|||authentication|uri|/gateway/sandbox/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS|success|
22/02/15 14:05:43
||1234567890ABCD|audit|127.0.0.1|WEBHDFS|guest|||authentication|uri|/gateway/sandbox/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS|success|Groups:
[]
22/02/15 14:05:43
||1234567890ABCD|audit|127.0.0.1|WEBHDFS|guest|||dispatch|uri|http://localhost:50070/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS&user.name=guest|unavailable|Request
method: GET
22/02/15 14:05:44
||1234567890ABCD|audit|127.0.0.1|WEBHDFS|guest|||dispatch|uri|http://localhost:50070/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS&user.name=guest|failure|
```
`curl -k -u guest:guest-password -X GET
https://localhost:8443/gateway/sandbox/webhdfs/v1/tmp/hello.txt\?op\=LISTSTATUS`
```
==>
/Users/smore/dev/committer/knox/install/knox-2.0.0-SNAPSHOT/logs/gateway.log <==
2022-02-15 14:08:39,713 123549b8-8f7f-4301-9d81-dbeefb842652 INFO
knox.gateway (KnoxLdapRealm.java:getUserDn(688)) - Computed userDn:
uid=guest,ou=people,dc=hadoop,dc=apache,dc=org using dnTemplate for principal:
guest
==>
/Users/smore/dev/committer/knox/install/knox-2.0.0-SNAPSHOT/logs/gateway-audit.log
<==
22/02/15 14:08:39
||123549b8-8f7f-4301-9d81-dbeefb842652|audit|127.0.0.1|WEBHDFS|guest|||authentication|uri|/gateway/sandbox/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS|success|
22/02/15 14:08:39
||123549b8-8f7f-4301-9d81-dbeefb842652|audit|127.0.0.1|WEBHDFS|guest|||authentication|uri|/gateway/sandbox/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS|success|Groups:
[]
22/02/15 14:08:39
||123549b8-8f7f-4301-9d81-dbeefb842652|audit|127.0.0.1|WEBHDFS|guest|||dispatch|uri|http://localhost:50070/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS&user.name=guest|unavailable|Request
method: GET
22/02/15 14:08:40
||123549b8-8f7f-4301-9d81-dbeefb842652|audit|127.0.0.1|WEBHDFS|guest|||dispatch|uri|http://localhost:50070/webhdfs/v1/tmp/hello.txt?op=LISTSTATUS&user.name=guest|failure|
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]