1818local core = require (" apisix.core" )
1919local plugin = require (" apisix.plugin" )
2020local tostring = tostring
21+ local pairs = pairs
2122local http = require (" resty.http" )
2223local log_util = require (" apisix.utils.log-util" )
2324local bp_manager_mod = require (" apisix.utils.batch-processor-manager" )
@@ -98,6 +99,7 @@ local schema = {
9899 default = " apisix.apache.org%2Flogs"
99100 },
100101 log_format = {type = " object" },
102+ log_format_extra = {type = " object" },
101103 },
102104 oneOf = {
103105 { required = { " auth_config" } },
@@ -109,6 +111,9 @@ local schema = {
109111local metadata_schema = {
110112 type = " object" ,
111113 properties = {
114+ log_format_extra = {
115+ type = " object"
116+ },
112117 log_format = {
113118 type = " object"
114119 },
190195
191196
192197local function get_logger_entry (conf , ctx , oauth )
193- local entry , customized = log_util .get_log_entry (plugin_name , conf , ctx )
198+ local entry , customized , extra = log_util .get_log_entry (plugin_name , conf , ctx )
194199 local google_entry
195200 if not customized then
196201 google_entry = {
@@ -210,6 +215,14 @@ local function get_logger_entry(conf, ctx, oauth)
210215 service_id = entry .service_id ,
211216 },
212217 }
218+ -- the fixed payload above drops everything else, so add log_format_extra
219+ if extra then
220+ for k , v in pairs (extra ) do
221+ if google_entry .jsonPayload [k ] == nil then
222+ google_entry .jsonPayload [k ] = v
223+ end
224+ end
225+ end
213226 else
214227 google_entry = {
215228 jsonPayload = entry ,
0 commit comments