-
Notifications
You must be signed in to change notification settings - Fork 952
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
Add TCP Access Logging #2852
Add TCP Access Logging #2852
Conversation
7dd3795
to
451e6a1
Compare
3f6511a
to
374f0c0
Compare
Signed-off-by: gargnupur <gargnupur@google.com> fix Signed-off-by: gargnupur <gargnupur@google.com> changes Signed-off-by: gargnupur <gargnupur@google.com> refactor Signed-off-by: gargnupur <gargnupur@google.com> fix test Add TCP Metrics in Stackdriver Signed-off-by: gargnupur <gargnupur@google.com> fix Signed-off-by: gargnupur <gargnupur@google.com> Add TCP access logging changes Signed-off-by: gargnupur <gargnupur@google.com> Remove local path from Makefile changes Signed-off-by: gargnupur <gargnupur@google.com> Add functions for queue fix build fix test remove debug time Signed-off-by: gargnupur <gargnupur@google.com> remove debug time Signed-off-by: gargnupur <gargnupur@google.com> Add protocol in http accesslog
e6ab245
to
da73c0b
Compare
Signed-off-by: gargnupur <gargnupur@google.com>
@bianpengyuan , @mandarjog , @douglas-reid : This is ready for review.. |
message PluginConfig { | ||
// Optional. Controls whether to export server access log. | ||
bool disable_server_access_logging = 1; | ||
|
||
// Optional. Controls whether to export TCP server access log. | ||
bool disable_tcp_server_access_logging = 9; |
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.
Shall we just use disable_server_access_logging
to control both tcp and http logging?
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.
Good idea.. removing
extensions/stackdriver/log/logger.cc
Outdated
const ::Wasm::Common::RequestInfo& request_info, | ||
google::logging::v2::LogEntry* log_entry) { | ||
auto label_map = log_entry->mutable_labels(); | ||
(*label_map)["tcp_remote_ip"] = request_info.source_address; |
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.
Do we need tcp
prefix? What did we use in mixer v1?
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.
Changed them to match mixer v1
@@ -403,6 +404,12 @@ bool StackdriverRootContext::recordTCP(uint32_t id) { | |||
// Record TCP Metrics. | |||
::Extensions::Stackdriver::Metric::recordTCP(outbound, local_node, peer_node, | |||
request_info); | |||
// Add LogEntry to Logger. Log Entries are batched and sent on timer | |||
// to Stackdriver Logging Service. | |||
if (enableTCPServerAccessLog() && shouldLogThisRequest()) { |
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.
Does shouldLogThisRequest
apply here? It only bases on http or grpc status right?
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.
Removed for now.. but I was thinking more in terms of sampling successful connections too but will change accesslog sampling filter to select failed request based on presence of response flag.. will do in a separate PR
// to Stackdriver Logging Service. | ||
if (enableTCPServerAccessLog() && shouldLogThisRequest()) { | ||
::Wasm::Common::populateExtendedRequestInfo(&request_info); | ||
logger_->addLogEntry(request_info, peer_node, true); |
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.
logger_->addLogEntry(request_info, peer_node, true); | |
logger_->addLogEntry(request_info, peer_node, /* is_tcp = */ true); |
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.
Fixed
@@ -351,7 +352,7 @@ void StackdriverRootContext::record() { | |||
!config_.disable_http_size_metrics()); | |||
if (enableServerAccessLog() && shouldLogThisRequest()) { | |||
::Wasm::Common::populateExtendedHTTPRequestInfo(&request_info); | |||
logger_->addLogEntry(request_info, peer_node); | |||
logger_->addLogEntry(request_info, peer_node, false); |
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.
logger_->addLogEntry(request_info, peer_node, false); | |
logger_->addLogEntry(request_info, peer_node, /* is_tcp = */ false); |
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.
Fixed
extensions/stackdriver/stackdriver.h
Outdated
@@ -80,7 +80,11 @@ class StackdriverRootContext : public RootContext { | |||
void deleteFromTCPRequestQueue(uint32_t id); | |||
void incrementReceivedBytes(uint32_t id, size_t size); | |||
void incrementSentBytes(uint32_t id, size_t size); | |||
void incrementTotalReceivedBytes(uint32_t id, size_t size); |
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.
Why not reuse the existing functions?
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.
Because the metrics are different... this is incrementing tcp_total_received_bytes...
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.
You can increment total_x_bytes inside the existing function.
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.
This is not fixed yet.
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.
yup. thanks.. fixed
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.
I don't see a new commit, did you push?
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.
weird.. change was there in the branch bot not in PR.. I pushed again with a comment.. PTAL
@@ -155,6 +162,8 @@ class StackdriverContext : public Context { | |||
|
|||
is_tcp_ = true; | |||
getRootContext()->addToTCPRequestQueue(context_id_); | |||
getRootContext()->setConnectionState( |
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.
I think you will need to trigger log record in connection open, otherwise it will not be recorded. Also I think it is necessary to record log entry in open and close event, so that they could have correct time stamp.
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.
And test make sure that all three types of connection states are covered.
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.
Yes.. I was going to ping you offline about this :) I had exact same question in my other PR.. #2843 (comment) but reading it now, I think you were referring to Metrics and I was referring to calling Record method in general that does everything.
One of the things for TCP would be that metadata exchange doesn't happen until data comes so, connection open log won't have peer data. But it would be good to still get connection open logged.
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.
Will add this change in a separate PR because of metadata exchange stuff..
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.
Ok, I think time stamp is the only thing special with connection open. All other labels should have no difference from other state. You can keep an connection open time stamp somewhere and use that as a signal to record connection open event.
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.
Are you planning to fix this in separated PR?
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.
Yes, will do in a separate PR.. started a conversation about this with you, Mandar and Doug..
Signed-off-by: gargnupur <gargnupur@google.com>
@@ -203,7 +204,7 @@ bool StackdriverRootContext::configure(size_t configuration_size) { | |||
} | |||
} | |||
|
|||
if (!logger_ && enableServerAccessLog()) { | |||
if (!logger_ && (enableServerAccessLog())) { |
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.
if (!logger_ && (enableServerAccessLog())) { | |
if (!logger_ && enableServerAccessLog()) { |
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.
Thanks..Fixed
@@ -313,7 +314,7 @@ bool StackdriverRootContext::onDone() { | |||
// called, but onConfigure is not triggered. onConfigure is only triggered in | |||
// thread local VM, which makes it possible that logger_ is empty ptr even | |||
// when logging is enabled. | |||
if (logger_ && enableServerAccessLog() && | |||
if (logger_ && (enableServerAccessLog()) && |
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.
if (logger_ && (enableServerAccessLog()) && | |
if (logger_ && enableServerAccessLog() && |
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.
Thanks..Fixed
@@ -155,6 +162,8 @@ class StackdriverContext : public Context { | |||
|
|||
is_tcp_ = true; | |||
getRootContext()->addToTCPRequestQueue(context_id_); | |||
getRootContext()->setConnectionState( |
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.
Are you planning to fix this in separated PR?
extensions/stackdriver/stackdriver.h
Outdated
@@ -80,7 +80,11 @@ class StackdriverRootContext : public RootContext { | |||
void deleteFromTCPRequestQueue(uint32_t id); | |||
void incrementReceivedBytes(uint32_t id, size_t size); | |||
void incrementSentBytes(uint32_t id, size_t size); | |||
void incrementTotalReceivedBytes(uint32_t id, size_t size); |
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.
This is not fixed yet.
Signed-off-by: gargnupur <gargnupur@google.com>
What this PR does / why we need it:
This is built on top of #2843
Ref: istio/istio#23134