Skip to content

Example of logging metadata set by a route? #6156

@cetanu

Description

@cetanu

In the envoy docs for core.Metadata, it says:

An example use of metadata is providing additional values to http_connection_manager in the envoy.http_connection_manager.access_log namespace.

I've tried to set metadata on a route with this namespace with the intention of it being logged by the parent listener, to no avail.

Here are the relevant snippets of my config:

RouteConfiguration:

version_info: '0'
resources:
  - '@type': type.googleapis.com/envoy.api.v2.RouteConfiguration
    name: foobar-route-config
    virtual_hosts:
      - name: foobar-virtualhost
        domains:
          - 'foobar.com'
        routes:
        - match:
            prefix: /
          route:
            cluster: foobar-cluster
          metadata:
            filter_metadata:
              envoy.http_connection_manager.access_log:
                example: 'something'

Listener:

version_info: '0'
resources:
  - '@type': type.googleapis.com/envoy.api.v2.Listener
    name: foobar-listener
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
        protocol: TCP
    filter_chains:
      - filters:
        - name: envoy.http_connection_manager
          config:
            stat_prefix: upstreams
            codec_type: AUTO
            idle_timeout: 300s
            use_remote_address: yes
            access_log:
              - name: envoy.file_access_log
                config:
                  path: /var/log/envoy/access.log
                  json_format:
                    my_metadata_value: "%DYNAMIC_METADATA(envoy.http_connection_manager.access_log:example)%"
              - name: envoy.router
            rds:
              route_config_name: foobar-route-config
              config_source:
                api_config_source:
                  api_type: REST
                  cluster_names: [controlplane]
                  refresh_delay: 5s

These are responses sent by an envoy control-plane.

Am I doing this wrong? The value is logged as '-'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestions that are neither investigations, bugs, nor enhancementsstalestalebot believes this issue/PR has not been touched recently

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions