-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: enable L4 stream logging #5768
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,16 @@ stream { | |
lua_ssl_trusted_certificate {* ssl.ssl_trusted_certificate *}; | ||
{% end %} | ||
|
||
# for stream logs | ||
{% if stream.enable_access_log == false then %} | ||
access_log off; | ||
{% else %} | ||
log_format main escape={* stream.access_log_format_escape *} '{* stream.access_log_format *}'; | ||
|
||
access_log {* stream.access_log *} main buffer=16384 flush=3; | ||
{% end %} | ||
open_log_file_cache max=1000 inactive=60; | ||
|
||
# stream configuration snippet starts | ||
{% if stream_configuration_snippet then %} | ||
{* stream_configuration_snippet *} | ||
|
@@ -261,7 +271,7 @@ http { | |
|
||
access_log {* http.access_log *} main buffer=16384 flush=3; | ||
{% end %} | ||
open_file_cache max=1000 inactive=60; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open_file_cache is there: https://nginx.org/en/docs/http/ngx_http_core_module.html#open_file_cache There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack |
||
open_log_file_cache max=1000 inactive=60; | ||
client_max_body_size {* http.client_max_body_size *}; | ||
keepalive_timeout {* http.keepalive_timeout *}; | ||
client_header_timeout {* http.client_header_timeout *}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,11 @@ nginx_config: # config for render the template to generate n | |
# - TEST_ENV | ||
|
||
stream: | ||
enable_access_log: true # enable access log or not, default true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The access_log in stream is false by default: https://nginx.org/en/docs/stream/ngx_stream_log_module.html#access_log There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
access_log: logs/access_stream.log | ||
access_log_format: "$remote_addr [$time_local] $status $bytes_sent $session_time $upstream_connect_time \"$protocol://$upstream_addr\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spacewander by consulting http://nginx.org/en/docs/varindex.html, I created the log format. Do you think we can do better? Do let me know. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can use Nginx's basic format in its example?
See https://nginx.org/en/docs/stream/ngx_stream_log_module.html. Kong also uses it too: https://github.com/Kong/kong/blob/d65101fe80fd7ac9870a84d34d81bda8bcb461ac/kong/templates/nginx_kong_stream.lua#L3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
# create your custom log format by visiting http://nginx.org/en/docs/varindex.html | ||
access_log_format_escape: default # allows setting json or default characters escaping in variables | ||
lua_shared_dict: | ||
etcd-cluster-health-check-stream: 10m | ||
lrucache-lock-stream: 10m | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it, as the log file name doesn't contain variable. There is only one open log file.
See https://nginx.org/en/docs/http/ngx_http_log_module.html#open_log_file_cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. Thanks