替換格式字串 (proto)
config.core.v3.JsonFormatOptions
[config.core.v3.JsonFormatOptions proto]
可選的組態選項,用於 json_format。
{
"sort_properties": ...
}
- sort_properties
(bool) 輸出 JSON 字串屬性將會排序。
config.core.v3.SubstitutionFormatString
[config.core.v3.SubstitutionFormatString proto]
使用多個命令運算子來產生純文字或 JSON 格式新字串的組態。
{
"text_format": ...,
"json_format": {...},
"text_format_source": {...},
"omit_empty_values": ...,
"content_type": ...,
"formatters": [],
"json_format_options": {...}
}
- text_format
(string) 指定使用命令運算子來形成文字字串的格式。其詳細資訊描述於格式字串。
例如,設定
text_format
如下,text_format: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
產生類似於以下的純文字
upstream connect error:503:path=/foo
已棄用,改用text_format_source。若要遷移文字格式字串,請使用 inline_string 欄位。
必須設定 text_format、json_format 或 text_format_source 其中之一。
- json_format
(Struct) 指定使用命令運算子來形成 JSON 字串的格式。其詳細資訊描述於格式字典。值會視情況呈現為字串、數字或布林值。某些命令運算子 (例如 FILTER_STATE 或 DYNAMIC_METADATA) 可能會產生巢狀 JSON 物件。請參閱特定命令運算子的文件以取得詳細資訊。
json_format: status: "%RESPONSE_CODE%" message: "%LOCAL_REPLY_BODY%"
會建立下列 JSON 物件
{ "status": 500, "message": "My error message" }
必須設定 text_format、json_format 或 text_format_source 其中之一。
- text_format_source
(config.core.v3.DataSource) 指定使用命令運算子來形成文字字串的格式。其詳細資訊描述於格式字串。
例如,設定
text_format
如下,text_format_source: inline_string: "%LOCAL_REPLY_BODY%:%RESPONSE_CODE%:path=%REQ(:path)%\n"
產生類似於以下的純文字
upstream connect error:503:path=/foo
必須設定 text_format、json_format 或 text_format_source 其中之一。
- omit_empty_values
(bool) 如果設定為 true,當命令運算子評估為 null 時,
對於
text_format
,空運算子的輸出會從-
變更為空字串,以便完全省略空值。對於
json_format
,具有 null 值的索引鍵會在輸出結構中省略。
- content_type
(string) 指定
content_type
欄位。如果未設定此欄位,則text/plain
用於text_format
,而application/json
用於json_format
。content_type: "text/html; charset=UTF-8"
- formatters
(repeated config.core.v3.TypedExtensionConfig) 指定可從存取記錄組態呼叫的 Formatter 外掛程式集合。請參閱格式器擴充功能文件以取得詳細資訊。
- json_format_options
(config.core.v3.JsonFormatOptions) 如果使用 json_format,則選項將會套用至輸出 JSON 字串。