Envoy Thrift-To-Metadata Filter

  • This filter should be configured with the type URL type.googleapis.com/envoy.extensions.filters.http.thrift_to_metadata.v3.ThriftToMetadata.

  • v3 API reference

The thrift-to-metadata filter serves for thrift over HTTP traffic, expecting serialized thrift request and response messages in the HTTP payload. This filter is configured with rules that will be matched against Apache thrift compatible requests and responses in HTTP payload. The filter will parse the thrift messages, extract thrift metadata or thrift payload, and add them to dynamic filter metadata based on the configuration of the rule.

The filter metadata can then be used for load balancing decisions, consumed from logs, etc.

A typical use case for this filter is to dynamically match a specified thrift method of requests with rate limit. For this, thrift method name is attached to the request as dynamic filter metadata which would then be used to match a rate limit action on filter metadata.

Example

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

25          http_filters:
26          - name: envoy.filters.http.thrift_to_metadata
27            typed_config:
28              "@type": type.googleapis.com/envoy.extensions.filters.http.thrift_to_metadata.v3.ThriftToMetadata
29              request_rules:
30              - field: PROTOCOL
31                on_present:
32                  metadata_namespace: envoy.lb
33                  key: protocol
34                on_missing:
35                  metadata_namespace: envoy.lb
36                  key: protocol
37                  value: "unknown"
38              - field: TRANSPORT
39                on_present:
40                  metadata_namespace: envoy.lb
41                  key: transport
42                on_missing:
43                  metadata_namespace: envoy.lb
44                  key: transport
45                  value: "unknown"
46              response_rules:
47              - field: MESSAGE_TYPE
48                on_present:
49                  metadata_namespace: envoy.filters.http.thrift_to_metadata
50                  key: response_message_type
51                on_missing:
52                  metadata_namespace: envoy.filters.http.thrift_to_metadata
53                  key: response_message_type
54                  value: "exception"
55              - field: REPLY_TYPE

Statistics

The thrift to metadata filter outputs statistics in the http.<stat_prefix>.thrift_to_metadata. namespace. The stat prefix comes from the owning HTTP connection manager.

Name

Type

Description

rq_success

Counter

Total requests that succeed to parse the thrift message.

rq_mismatched_content_type

Counter

Total requests that mismatch the content type

rq_no_body

Counter

Total requests without http body

rq_invalid_thrift_body

Counter

Total requests with invalid thrift message

resp_success

Counter

Total responses that succeed to parse the thrift message.

resp_mismatched_content_type

Counter

Total responses that mismatch the content type

resp_no_body

Counter

Total responses without http body

resp_invalid_thrift_body

Counter

Total responses with invalid thrift message