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

feat(access-log): omit empty fields in Envoy logs #6077

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

abbas-gheydi
Copy link
Contributor

Pull Request

Description

This PR addresses the issue #6067 by implementing the feature to omit empty fields in Envoy logs for the access log.

Changes Made

  • Modified the access log to exclude empty fields in Envoy logs.

Related Issue

#6067

@abbas-gheydi abbas-gheydi requested a review from a team as a code owner January 13, 2024 17:31
@abbas-gheydi abbas-gheydi requested review from skriss and sunjayBhatia and removed request for a team January 13, 2024 17:31
@sunjayBhatia sunjayBhatia requested review from a team and clayton-gonsalves and removed request for a team January 13, 2024 17:31
Copy link

Hi @abbas-gheydi! Welcome to our community and thank you for opening your first Pull Request. Someone will review it soon. Thank you for committing to making Contour better. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace

@abbas-gheydi abbas-gheydi force-pushed the main branch 2 times, most recently from 472d48f to 44d0cd8 Compare January 13, 2024 17:46
@tsaarni tsaarni added the release-note/small A small change that needs one line of explanation in the release notes. label Jan 15, 2024
@tsaarni
Copy link
Member

tsaarni commented Jan 15, 2024

Thank you for the PR!

For JSON based logs, omitting values is possibly less likely to break systems that process the logs, but what about text based access logs? I did not try this change myself yet but Envoy docs seem to suggest that fields will be missing from there too

for text_format, the output of the empty operator is changed from - to an empty string, so that empty values are omitted entirely.

How would one reliably count the position of fields, to recognise which field is which, if this is the case?

Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think I agree with @tsaarni, I would rather this is implemented only for JSON logging if we want it as a default, otherwise text based logs will be hard to read

@abbas-gheydi abbas-gheydi reopened this Jan 19, 2024
@sunjayBhatia sunjayBhatia requested review from a team and izturn and removed request for a team January 19, 2024 17:37
@abbas-gheydi abbas-gheydi force-pushed the main branch 2 times, most recently from edce293 to b0be80a Compare January 19, 2024 17:42
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (61b6fae) 78.85% compared to head (edce293) 78.85%.
Report is 10 commits behind head on main.

❗ Current head edce293 differs from pull request most recent head 41461d9. Consider uploading reports for the commit 41461d9 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6077   +/-   ##
=======================================
  Coverage   78.85%   78.85%           
=======================================
  Files         138      138           
  Lines       19731    19732    +1     
=======================================
+ Hits        15558    15559    +1     
  Misses       3870     3870           
  Partials      303      303           
Files Coverage Δ
internal/envoy/v3/accesslog.go 93.44% <100.00%> (+0.05%) ⬆️

@abbas-gheydi
Copy link
Contributor Author

I removed the 'omit empty fields' feature for Envoy format logs as it may disrupt the log structure. Instead, I've enabled this feature exclusively for JSON logs.

Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

example with the change:

{"downstream_local_address":"10.244.1.167:8080","@timestamp":"2024-01-22T19:17:35.988Z","upstream_host":"10.244.1.152:8080","bytes_received":0,"upstream_local_address":"10.244.1.167:60970","upstream_service_time":"6","response_flags":"-","x_forwarded_for":"172.18.0.1","method":"GET","user_agent":"curl/8.5.0","upstream_cluster":"default_s1_80","downstream_remote_address":"172.18.0.1:59700","path":"/","authority":"foo-basic.bar.com","protocol":"HTTP/1.1","request_id":"c49948b0-d0b0-4bc5-8ff1-862dbb11874b","bytes_sent":1674,"response_code":200,"duration":8}

vs. without

{"bytes_received":0,"@timestamp":"2024-01-22T19:21:17.543Z","path":"/","upstream_service_time":"5","x_forwarded_for":"172.18.0.1","response_flags":"-","bytes_sent":1674,"downstream_local_address":"10.244.1.175:8080","request_id":"8f3f29dd-e66d-40a4-b288-ee226167a852","upstream_cluster":"default_s1_80","protocol":"HTTP/1.1","grpc_status":null,"method":"GET","downstream_remote_address":"172.18.0.1:59752","user_agent":"curl/8.5.0","upstream_host":"10.244.1.152:8080","duration":6,"requested_server_name":null,"upstream_local_address":"10.244.1.175:48790","grpc_status_number":null,"uber_trace_id":null,"authority":"foo-basic.bar.com","response_code":200}

Copy link
Member

@izturn izturn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@izturn izturn assigned izturn and abbas-gheydi and unassigned izturn Jan 23, 2024
abbas-gheydi and others added 2 commits January 23, 2024 13:33
Signed-off-by: Abbas Gheydi <abbas.gheydi@gmail.com>
Co-authored-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Abbas Gheydi <abbas.gheydi@gmail.com>
@sunjayBhatia sunjayBhatia merged commit 5f22aeb into projectcontour:main Jan 23, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants