Header-To-Metadata Filter

This extension may be referenced by the qualified name envoy.filters.http.header_to_metadata

Note

This extension is intended to be robust against untrusted downstream traffic. It assumes that the upstream is trusted.

The configuration for transforming headers into metadata. This is useful for matching load balancer subsets, logging, etc.

Header to Metadata configuration overview.

config.filter.http.header_to_metadata.v2.Config

[config.filter.http.header_to_metadata.v2.Config proto]

{
  "request_rules": [],
  "response_rules": []
}
request_rules

(config.filter.http.header_to_metadata.v2.Config.Rule) The list of rules to apply to requests.

response_rules

(config.filter.http.header_to_metadata.v2.Config.Rule) The list of rules to apply to responses.

config.filter.http.header_to_metadata.v2.Config.KeyValuePair

[config.filter.http.header_to_metadata.v2.Config.KeyValuePair proto]

{
  "metadata_namespace": "...",
  "key": "...",
  "value": "...",
  "type": "...",
  "encode": "..."
}
metadata_namespace

(string) The namespace — if this is empty, the filter’s namespace will be used.

key

(string, REQUIRED) The key to use within the namespace.

value

(string) The value to pair with the given key.

When used for a on_header_present case, if value is non-empty it’ll be used instead of the header value. If both are empty, no metadata is added.

When used for a on_header_missing case, a non-empty value must be provided otherwise no metadata is added.

type

(config.filter.http.header_to_metadata.v2.Config.ValueType) The value’s type — defaults to string.

encode

(config.filter.http.header_to_metadata.v2.Config.ValueEncode) How is the value encoded, default is NONE (not encoded). The value will be decoded accordingly before storing to metadata.

config.filter.http.header_to_metadata.v2.Config.Rule

[config.filter.http.header_to_metadata.v2.Config.Rule proto]

A Rule defines what metadata to apply when a header is present or missing.

{
  "header": "...",
  "on_header_present": "{...}",
  "on_header_missing": "{...}",
  "remove": "..."
}
header

(string, REQUIRED) The header that triggers this rule — required.

on_header_present

(config.filter.http.header_to_metadata.v2.Config.KeyValuePair) If the header is present, apply this metadata KeyValuePair.

If the value in the KeyValuePair is non-empty, it’ll be used instead of the header value.

on_header_missing

(config.filter.http.header_to_metadata.v2.Config.KeyValuePair) If the header is not present, apply this metadata KeyValuePair.

The value in the KeyValuePair must be set, since it’ll be used in lieu of the missing header value.

remove

(bool) Whether or not to remove the header after a rule is applied.

This prevents headers from leaking.

Enum config.filter.http.header_to_metadata.v2.Config.ValueType

[config.filter.http.header_to_metadata.v2.Config.ValueType proto]

STRING

(DEFAULT)

NUMBER

PROTOBUF_VALUE

⁣The value is a serialized protobuf.Value.

Enum config.filter.http.header_to_metadata.v2.Config.ValueEncode

[config.filter.http.header_to_metadata.v2.Config.ValueEncode proto]

ValueEncode defines the encoding algorithm.

NONE

(DEFAULT) ⁣The value is not encoded.

BASE64

⁣The value is encoded in Base64. Note: this is mostly used for STRING and PROTOBUF_VALUE to escape the non-ASCII characters in the header.