Envoy Header-To-Metadata Filter

    This filter is configured with rules that will be matched against requests and responses. Each rule has either a cookie or a header and can be triggered either when the header or cookie is present or missing.

    When a rule is triggered, dynamic metadata will be added based on the configuration of the rule. If the header or cookie is present, it’s value is extracted and used along with the specified key as metadata. If the header or cookie is missing, on missing case is triggered and the value specified is used for adding metadata.

    A typical use case for this filter is to dynamically match requests with load balancer subsets. For this, a given header’s value would be extracted and attached to the request as dynamic metadata which would then be used to match a subset of endpoints.

    A sample filter configuration to route traffic to endpoints based on the presence or absence of a version header could be:

    As with headers, the value of the specified cookie will be extracted from the request and added as metadata with the key specified. Removing a cookie when a rule matches is unsupported.

    This would then allow requests with the header set to be matched against endpoints with the corresponding version. Whereas requests with that header missing would be matched with the default endpoints.

    If the header’s value needs to be transformed before it’s added to the request as dynamic metadata, this filter supports regex matching and substitution:

    Note that this filter also supports per route configuration:

    Statistics

    Currently, this filter generates no statistics.