Skip to content

Conversation

@TAOXUY
Copy link
Contributor

@TAOXUY TAOXUY commented Jan 22, 2026

Commit Message:support custom stat generation in stats accesslogger using general matcher.

The supported input is the TagName which allows matching the stats which has the expected tag.

The supported actions on the matched stats are

  • DropStatAction: drop the matched stats. For example, we only want track error tcp connection and we can drop stats with %RESPONSE_FLAGS_LONG%= "-".
                - stat:
                    name: "network-errors"
                    tags:
                    - name: "error.type"
                      value_format: "%RESPONSE_FLAGS_LONG%"
                      tag_filter:
                        matcher_tree:
                          input:
                            name: stat_tag_value_input
                            typed_config:
                              "@type": type.googleapis.com/envoy.extensions.matching.common_inputs.stats.v3.StatTagValueInput
                          exact_match_map:
                            map:
                              "-":
                                action:
                                  name: drop_action
                                  typed_config:
                                    "@type": type.googleapis.com/envoy.extensions.access_loggers.stats.v3.DropStatAction

  • DropTagAction: drop some uninterested stats tag in the matched stats. For example, we don't want to add http error label(we set error equal to %RESPONSE_CODE_DETAILS%) if it is via_upstream.
                    - stat:
                        name: "http-client-request-count"
                        tags:
                        - name: "error.type"
                          value_format: "%RESPONSE_CODE_DETAILS%"
                          tag_filter:
                            matcher_tree:
                              input:
                                name: stat_tag_value_input
                                typed_config:
                                  "@type": type.googleapis.com/envoy.extensions.matching.common_inputs.stats.v3.StatTagValueInput
                              exact_match_map:
                                map:
                                  "via_upstream":
                                    action:
                                      name: drop_action
                                      typed_config:
                                        "@type": type.googleapis.com/envoy.extensions.access_loggers.stats.v3.DropTagAction

  • InsertTagAction: replace(also allow insert) the stats value. For example, we wanna collect if the tcp connection reset is sent from local or sent from remote, we want convert the %DOWNSTREAM_DETECTED_CLOSE_TYPE% the value we are interested.
image
              - stat:
                  name: "network-connection-resets"
                  tags:
                  - name: "network.io.direction"
                    value_format: "%UPSTREAM_DETECTED_CLOSE_TYPE%"
                    tag_filter:
                      matcher_tree:
                        input:
                          name: stat_tag_value_input
                          typed_config:
                            "@type": type.googleapis.com/envoy.extensions.matching.common_inputs.stats.v3.StatTagValueInput
                        exact_match_map:
                          map:
                            "RemoteReset":
                              action:
                                name: replace_action
                                typed_config:
                                  "@type": type.googleapis.com/envoy.extensions.access_loggers.stats.v3.InsertTagAction
                                  target_tag_value: "received"
                            "LocalReset":
                              action:
                                name: replace_action
                                typed_config:
                                  "@type": type.googleapis.com/envoy.extensions.access_loggers.stats.v3.InsertTagAction
                                  target_tag_value: "sent"

Additional Description:no
Risk Level:lo
Testing:added
Docs Changes:added
Release Notes:added
Platform Specific Features:no

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #43123 was opened by TAOXUY.

see: more, trace.

Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@TAOXUY TAOXUY changed the title Support custom stat generation in stats accesslogger Support custom generation in stats accesslogger Jan 23, 2026
wbpcode added a commit that referenced this pull request Jan 24, 2026
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)

!!!ATTENTION!!!

Please check the [use of generative AI
policy](https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md?plain=1#L41).

You may use generative AI only if you fully understand the code. You
need to disclose
this usage in the PR description to ensure transparency.
-->

Commit Message:
Additional Description:

May because some conflicts, #43123 introduced duplicated labels in the
document and broken the docs CI. This PR fixed it.

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: wbpcode <wbphub@gmail.com>
Copy link
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

From reading the proto docs, I don't understand at all what this PR does. Please add better documentation of this.

/wait

@TAOXUY
Copy link
Contributor Author

TAOXUY commented Jan 24, 2026

From reading the proto docs, I don't understand at all what this PR does. Please add better documentation of this.

/wait

Updated. How about now?

Signed-off-by: Xuyang Tao <taoxuy@google.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
@TAOXUY
Copy link
Contributor Author

TAOXUY commented Jan 26, 2026

@ggreenway @wbpcode @kyessenov gentle ping~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants