Json-To-Metadata Filter (proto)

This extension has the qualified name envoy.filters.http.json_to_metadata

Note

This extension is functional but has not had substantial production burn time, use only with this caveat.

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

Tip

This extension extends and can be used with the following extension category:

This extension must be configured with one of the following type URLs:

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

Json to Metadata configuration overview.

extensions.filters.http.json_to_metadata.v3.JsonToMetadata

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata proto]

{
  "request_rules": {...}
}
request_rules

(extensions.filters.http.json_to_metadata.v3.JsonToMetadata.MatchRules, REQUIRED) Rules to match json body of requests

extensions.filters.http.json_to_metadata.v3.JsonToMetadata.KeyValuePair

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata.KeyValuePair proto]

{
  "metadata_namespace": ...,
  "key": ...,
  "value": {...},
  "type": ...,
  "preserve_existing_metadata_value": ...
}
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

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

When used for on_present case, if value is non-empty it’ll be used instead of the the value of the JSON key. If both are empty, the the value of the JSON key is used as-is.

When used for on_missing/on_error case, a non-empty value must be provided.

It ignores ValueType, i.e., not type casting.

type

(extensions.filters.http.json_to_metadata.v3.JsonToMetadata.ValueType) The value’s type — defaults to protobuf.Value.

preserve_existing_metadata_value

(bool) False if we want to overwrite the existing metadata value. Default to false.

extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Selector

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Selector proto]

{
  "key": ...
}
key

(string, REQUIRED) key to match

TODO(kuochunghsu): Explore matchers for array handling.

extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Rule

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Rule proto]

A Rule defines what metadata to apply when a key-value is present, missing in the json or fail to parse the payload.

{
  "selectors": [],
  "on_present": {...},
  "on_missing": {...},
  "on_error": {...}
}
selectors

(repeated extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Selector, REQUIRED) Specifies that a match will be performed on the value of a property. Here’s an example to match on 1 in {“foo”: {“bar”: 1}, “bar”: 2}

selectors: - key: foo - key: bar

on_present

(extensions.filters.http.json_to_metadata.v3.JsonToMetadata.KeyValuePair) If the attribute is present, apply this metadata KeyValuePair.

on_missing

(extensions.filters.http.json_to_metadata.v3.JsonToMetadata.KeyValuePair) If the attribute is missing, apply this metadata KeyValuePair.

The value in the KeyValuePair must be set.

on_error

(extensions.filters.http.json_to_metadata.v3.JsonToMetadata.KeyValuePair) If the body is too large or fail to parse, apply this metadata KeyValuePair.

The value in the KeyValuePair must be set.

extensions.filters.http.json_to_metadata.v3.JsonToMetadata.MatchRules

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata.MatchRules proto]

{
  "rules": [],
  "allow_content_types": [],
  "allow_empty_content_type": ...
}
rules

(repeated extensions.filters.http.json_to_metadata.v3.JsonToMetadata.Rule, REQUIRED) The list of rules to apply.

allow_content_types

(repeated string) Allowed content-type for json to metadata transformation. Default to {"application/json"}.

Set allow_empty_content_type if empty/missing content-type header is allowed.

allow_empty_content_type

(bool) Allowed empty content-type for json to metadata transformation. Default to false.

Enum extensions.filters.http.json_to_metadata.v3.JsonToMetadata.ValueType

[extensions.filters.http.json_to_metadata.v3.JsonToMetadata.ValueType proto]

PROTOBUF_VALUE

(DEFAULT) ⁣The value is a serialized protobuf.Value.

STRING

NUMBER