Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access-log: Add JSON support #1350

Merged
merged 64 commits into from
Jan 21, 2022
Merged

access-log: Add JSON support #1350

merged 64 commits into from
Jan 21, 2022

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Nov 1, 2021

Depends on #1319.

This branch adds the option to configure the access logging layer to
output JSON rather than the Apache Common access log format.

Currently, this is configured based on whether or not the file specified
in the LINKERD2_PROXY_ACCESS_LOG environment variable ends in .json.
We could also add a separate environment variable for the access log
format, but I thought this approach made more sense...

A bit of sample output:

{"client.addr":"127.0.0.1:51764","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"836068","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.844393794Z","total_ns":"4225011","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:46812","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"917210","request_bytes":"","response_bytes":"8","status":200,"timestamp":"2021-11-01T21:54:28.843909802Z","total_ns":"4566057","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"POST","processing_ns":"617010","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.852085211Z","total_ns":"1428744","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"PUT","processing_ns":"445462","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.855927578Z","total_ns":"1094081","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"DELETE","processing_ns":"389387","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.859080459Z","total_ns":"944251","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"HEAD","processing_ns":"404264","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.862128314Z","total_ns":"978064","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"PATCH","processing_ns":"404874","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.865139581Z","total_ns":"996539","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"982353","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.844075551Z","total_ns":"5095004","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}

tustvold and others added 30 commits January 28, 2021 14:06
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
Signed-off-by: Raphael Taylor-Davies <r.taylordavies@googlemail.com>
The `Settings::build` method is fairly large and complex. This change
splits into a few smaller units and reduces boilerplate--especially
around reading the settings from the environment.

This change is being made in service of #601 to help avoid making the
build method even more complicated.
hawkw and others added 12 commits October 8, 2021 15:03
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
may be a tracing bug!

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
this fixes the issue with adding a layer filter to the `fmt` layer; i
forgot the access log layer was relying on the `fmt` layer to format
the span fields.

anyway this fixes that.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Depends on #1319.

This branch adds the option to configure the access logging layer to
output JSON rather than the Apache Common access log format.

Currently, this is configured based on whether or not the file specified
in the `LINKERD2_PROXY_ACCESS_LOG` environment variable ends in `.json`.
We could also add a separate environment variable for the access log
format, but I thought this approach made more sense...

A bit of sample output:
```json
{"client.addr":"127.0.0.1:51764","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"836068","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.844393794Z","total_ns":"4225011","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:46812","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"917210","request_bytes":"","response_bytes":"8","status":200,"timestamp":"2021-11-01T21:54:28.843909802Z","total_ns":"4566057","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"POST","processing_ns":"617010","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.852085211Z","total_ns":"1428744","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"PUT","processing_ns":"445462","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.855927578Z","total_ns":"1094081","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"DELETE","processing_ns":"389387","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.859080459Z","total_ns":"944251","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"HEAD","processing_ns":"404264","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.862128314Z","total_ns":"978064","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"PATCH","processing_ns":"404874","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.865139581Z","total_ns":"996539","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
{"client.addr":"127.0.0.1:34510","client.id":"-","host":"transparency.test.svc.cluster.local","method":"GET","processing_ns":"982353","request_bytes":"","response_bytes":"0","status":200,"timestamp":"2021-11-01T21:54:28.844075551Z","total_ns":"5095004","trace_id":"","uri":"http://transparency.test.svc.cluster.local/","user_agent":"","version":"HTTP/2.0"}
```
@hawkw hawkw requested a review from a team November 1, 2021 22:08
Base automatically changed from eliza/access-logging-2 to main January 20, 2022 21:55
hawkw added 3 commits January 21, 2022 09:47
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
linkerd/tracing/Cargo.toml Outdated Show resolved Hide resolved
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
linkerd/tracing/src/lib.rs Outdated Show resolved Hide resolved
linkerd/tracing/src/lib.rs Outdated Show resolved Hide resolved
hawkw and others added 3 commits January 21, 2022 10:27
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@olix0r olix0r merged commit 1d62fd5 into main Jan 21, 2022
@olix0r olix0r deleted the eliza/access-log-json branch January 21, 2022 19:22
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jan 21, 2022
This release adds a new configuration variable,
`LINKERD2_PROXY_ACCESS_LOG` that configures whether per-request access
logs are emitted from inbound HTTP proxies. This variable may be set to
`apache` for Apache Common Log output or `json` for JSON formatted logs.
Access logs are emitted to stderr and the proxy's diagnostics logs are
emitted to stdout.

---

* build(deps): bump h2 from 0.3.9 to 0.3.10 (linkerd/linkerd2-proxy#1430)
* Update Rust to v1.56.1 (linkerd/linkerd2-proxy#1431)
* build(deps): bump indexmap from 1.7.0 to 1.8.0 (linkerd/linkerd2-proxy#1433)
* Add a devcontainer config (linkerd/linkerd2-proxy#1432)
* build(deps): bump serde_json from 1.0.74 to 1.0.75 (linkerd/linkerd2-proxy#1436)
* build(deps): bump tracing-subscriber from 0.3.5 to 0.3.6 (linkerd/linkerd2-proxy#1435)
* test: remove `env::set_var` call in test logging initialization  (linkerd/linkerd2-proxy#1437)
* trace: Apache Common Log Format access logging (linkerd/linkerd2-proxy#1319)
* build(deps): bump libc from 0.2.112 to 0.2.113 (linkerd/linkerd2-proxy#1438)
* build(deps): bump socket2 from 0.4.2 to 0.4.3 (linkerd/linkerd2-proxy#1439)
* access-log: Add JSON support (linkerd/linkerd2-proxy#1350)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants