Substitution format string

config.core.v3.SubstitutionFormatString

[config.core.v3.SubstitutionFormatString proto]

Configuration to use multiple command operators to generate a new string in either plain text or JSON format.

{
  "text_format": "...",
  "json_format": "{...}",
  "text_format_source": "{...}",
  "omit_empty_values": "...",
  "content_type": "...",
  "formatters": []
}
Copy to clipboard
text_format

(string) Specify a format with command operators to form a text string. Its details is described in format string.

For example, setting text_format like below,

text_format: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
Copy to clipboard

generates plain text similar to:

upstream connect error:503:path=/foo
Copy to clipboard

Deprecated in favor of text_format_source. To migrate text format strings, use the inline_string field.

Precisely one of text_format, json_format, text_format_source must be set.

json_format

(Struct) Specify a format with command operators to form a JSON string. Its details is described in format dictionary. Values are rendered as strings, numbers, or boolean values as appropriate. Nested JSON objects may be produced by some command operators (e.g. FILTER_STATE or DYNAMIC_METADATA). See the documentation for a specific command operator for details.

json_format:
  status: "%RESPONSE_CODE%"
  message: "%LOCAL_REPLY_BODY%"
Copy to clipboard

The following JSON object would be created:

{
  "status": 500,
  "message": "My error message"
}
Copy to clipboard

Precisely one of text_format, json_format, text_format_source must be set.

text_format_source

(config.core.v3.DataSource) Specify a format with command operators to form a text string. Its details is described in format string.

For example, setting text_format like below,

text_format_source:
  inline_string: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
Copy to clipboard

generates plain text similar to:

upstream connect error:503:path=/foo
Copy to clipboard

Precisely one of text_format, json_format, text_format_source must be set.

omit_empty_values

(bool) If set to true, when command operators are evaluated to null,

  • for text_format, the output of the empty operator is changed from - to an empty string, so that empty values are omitted entirely.

  • for json_format the keys with null values are omitted in the output structure.

content_type

(string) Specify a content_type field. If this field is not set then text/plain is used for text_format and application/json is used for json_format.

content_type: "text/html; charset=UTF-8"
Copy to clipboard
formatters

(repeated config.core.v3.TypedExtensionConfig) Specifies a collection of Formatter plugins that can be called from the access log configuration. See the formatters extensions documentation for details.