Skip to content

access_log: support for dynamic metadata set as part of the request info#590

Merged
htuch merged 9 commits intoenvoyproxy:masterfrom
glicht:dynamic-metadata
Apr 9, 2018
Merged

access_log: support for dynamic metadata set as part of the request info#590
htuch merged 9 commits intoenvoyproxy:masterfrom
glicht:dynamic-metadata

Conversation

@glicht
Copy link
Copy Markdown
Contributor

@glicht glicht commented Mar 29, 2018

documentation for PR: envoyproxy/envoy#2895

Signed-off-by: Guy Lichtman guy@lichtman.io

glicht added 2 commits March 29, 2018 11:50
documentation for PR: envoyproxy/envoy#2895

Signed-off-by: Guy Lichtman <guy@lichtman.io>
documentation for PR: envoyproxy/envoy#2895

Signed-off-by: Guy Lichtman <guy@lichtman.io>
* %DYNAMIC_METADATA(com.test.my_filter:test_key)% will log: ``"foo"``
* %DYNAMIC_METADATA(com.test.my_filter:test_object)% will log: ``{"inner_key": "bar"}``
* %DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key)% will log: ``"bar"``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add an example for an unknown key logging -.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM other than small comments. Thank you!

* tracing: the sampling decision is now delegated to the tracers, allowing the tracer to decide when and if
to use it. For example, if the :ref:`x-b3-sampled <config_http_conn_man_headers_x-b3-sampled>` header
is supplied with the client request, its value will override any sampling decision made by the Envoy proxy.
* access log: added DYNAMIC_METADATA :ref:`access log formatter <config_access_log_format>`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please alpha order

glicht added 2 commits March 31, 2018 11:12
documentation for PR: envoyproxy/envoy#2895

Signed-off-by: Guy Lichtman <guy@lichtman.io>
Signed-off-by: Guy Lichtman <guy@lichtman.io>
where NAMESPACE is the the filter namespace used when setting the metadata, KEY is an optional
lookup up key in the namespace with the option of specifying nested keys separated by ':',
and Z is an optional parameter denoting string truncation up to Z characters long. Dynamic Metadata
can be set by filters using the RequestInfo api: *setDynamicMetadata*. The data will be logged
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: s/api/API/

Add for RequestInfo with a :repo link, same as well for setDynamicMetadata.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added RequestInfo link. Will add a link to setDynamicMetadata once the code is merged.

lookup up key in the namespace with the option of specifying nested keys separated by ':',
and Z is an optional parameter denoting string truncation up to Z characters long. Dynamic Metadata
can be set by filters using the RequestInfo api: *setDynamicMetadata*. The data will be logged
as a json string. For example, for the following dynamic metadata:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: s/json/JSON/

* %DYNAMIC_METADATA(com.test.my_filter:test_object)% will log: ``{"inner_key": "bar"}``
* %DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key)% will log: ``"bar"``
* %DYNAMIC_METADATA(com.unknown_filter)% will log: ``-``
* %DYNAMIC_METADATA(com.test.my_filter:unknown_key)% will log: ``-``
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add an example with truncation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an example in latest commit

glicht added 2 commits April 3, 2018 01:18
…text fixes

Signed-off-by: Guy Lichtman <guy@lichtman.io>
Signed-off-by: Guy Lichtman <guy@lichtman.io>
* %DYNAMIC_METADATA(com.unknown_filter)% will log: ``-``
* %DYNAMIC_METADATA(com.test.my_filter:unknown_key)% will log: ``-``
* %DYNAMIC_METADATA(com.test.my_filter):25% will log (truncation at 25 characters): ``{"test_key": "foo", "test``

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a snippet for TCP this isn't implemented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can add a note that for tcp it is not implemented. Currently tcp_proxy doesn't populate dynamic metadata, but it could use this in the future if desired.. The dynamic metadata object is part of request_info which is used by tcp_proxy.

Signed-off-by: Guy Lichtman <guy@lichtman.io>
Signed-off-by: Guy Lichtman <guy@lichtman.io>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Change looks good, but also looks like somehow the file permission masks got changed (100644 → 100755). Can you take a look at that and revert?

Signed-off-by: Guy Lichtman <guy@lichtman.io>
htuch pushed a commit to envoyproxy/envoy that referenced this pull request Apr 9, 2018
…nfo (#2895)

 Relates to issue #1278.

Added new dynamic Metadata object to request_info (accessed via request_info.dynamicMetadata()). Dynamic Metadata can be set by filters and consumed by either other filters or the access log. Added to the access_log an option to specify logging of dynamic metadata through the following access log format token: %DYNAMIC_METADATA(filter_namespace:key*):Z%. "Z" is an optional parameter denoting max length. It is possible to have a nested key path. Each key is separated by ':'. For example for the following dynamic metadata:

com.test.my_filter: {"test_key": "foo", "test_object": {"inner_key": "bar"}}
%DYNAMIC_METADATA(com.test.my_filter)% will log: {"test_key": "foo", "test_object": {"inner_key": "bar"}}
%DYNAMIC_METADATA(com.test.my_filter:test_key)% will log: "foo"
%DYNAMIC_METADATA(com.test.my_filter:test_object)% will log: {"inner_key": "bar"}
%DYNAMIC_METADATA(com.test.my_filter:test_object:inner_key)% will log: "bar"

Risk Level: Low
Testing: unit tests added to access_log_formatter_test and request_info_impl_test. I've done manual testing with a custom "body parser" filter which parses the request body and stores the parsed result in the dynamic metadata of request_info. If this is of interest, I am ok with contributing this filter too.

Docs Changes: envoyproxy/data-plane-api#590

Signed-off-by: Guy Lichtman <guy@lichtman.io>
@htuch htuch merged commit a32c7f5 into envoyproxy:master Apr 9, 2018
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.

5 participants