Skip to content
8 changes: 6 additions & 2 deletions apisix/plugins/clickhouse-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local log_util = require("apisix.utils.log-util")
local plugin = require("apisix.plugin")
Expand Down Expand Up @@ -57,7 +56,9 @@ local schema = {
items = {
type = "array"
}
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
oneOf = {
{required = {"endpoint_addr", "user", "password", "database", "logtable"}},
Expand Down Expand Up @@ -174,6 +175,9 @@ local function send_http_data(conf, log_message)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
10 changes: 8 additions & 2 deletions apisix/plugins/elasticsearch-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local core = require("apisix.core")
local http = require("resty.http")
local log_util = require("apisix.utils.log-util")
Expand Down Expand Up @@ -104,6 +103,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = { type = "integer", minimum = 1, default = 524288 },
max_resp_body_bytes = { type = "integer", minimum = 1, default = 524288 },
},
encrypt_fields = {"auth.password"},
oneOf = {
Expand Down Expand Up @@ -214,6 +215,7 @@ local function get_logger_entry(conf, ctx)
core.json.encode(entry) .. "\n"
end


local function fetch_and_update_es_version(conf)
if conf._version then
return
Expand Down Expand Up @@ -290,12 +292,16 @@ function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end

function _M.access(conf)

function _M.access(conf, ctx)
-- fetch_and_update_es_version will call ES server only the first time
-- so this should not amount to considerable overhead
fetch_and_update_es_version(conf)

log_util.check_and_read_req_body(conf, ctx)
end


function _M.log(conf, ctx)
local metadata = plugin.plugin_metadata(plugin_name)
local max_pending_entries = metadata and metadata.value and
Expand Down
8 changes: 8 additions & 0 deletions apisix/plugins/file-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local log_util = require("apisix.utils.log-util")
local core = require("apisix.core")
local plugin = require("apisix.plugin")
Expand Down Expand Up @@ -49,6 +50,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
match = {
type = "array",
maxItems = 20,
Expand Down Expand Up @@ -204,10 +207,15 @@ local function write_file_data(conf, log_message)
end
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end


function _M.log(conf, ctx)
local entry = log_util.get_log_entry(plugin_name, conf, ctx)
if entry == nil then
Expand Down
6 changes: 5 additions & 1 deletion apisix/plugins/http-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local plugin = require("apisix.plugin")
local log_util = require("apisix.utils.log-util")
Expand Down Expand Up @@ -51,6 +50,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
concat_method = {type = "string", default = "json",
enum = {"json", "new_line"}},
ssl_verify = {type = "boolean", default = false},
Expand Down Expand Up @@ -168,6 +169,9 @@ local function send_http_data(conf, log_message)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
28 changes: 2 additions & 26 deletions apisix/plugins/kafka-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
local expr = require("resty.expr.v1")
local core = require("apisix.core")
local log_util = require("apisix.utils.log-util")
local producer = require ("resty.kafka.producer")
Expand All @@ -24,7 +23,7 @@ local plugin = require("apisix.plugin")
local math = math
local pairs = pairs
local type = type
local req_read_body = ngx.req.read_body

local plugin_name = "kafka-logger"
local batch_processor_manager = bp_manager_mod.new("kafka logger")

Expand Down Expand Up @@ -220,30 +219,7 @@ local function send_kafka_data(conf, log_message, prod)
end


function _M.access(conf, ctx)
if conf.include_req_body then
local should_read_body = true
if conf.include_req_body_expr then
if not conf.request_expr then
local request_expr, err = expr.new(conf.include_req_body_expr)
if not request_expr then
core.log.error('generate request expr err ', err)
return
end
conf.request_expr = request_expr
end

local result = conf.request_expr:eval(ctx.var)

if not result then
should_read_body = false
end
end
if should_read_body then
req_read_body()
end
end
end
_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
Expand Down
5 changes: 5 additions & 0 deletions apisix/plugins/loggly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
tags = {
type = "array",
minItems = 1,
Expand Down Expand Up @@ -177,6 +179,9 @@ function _M.check_schema(conf, schema_type)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
6 changes: 5 additions & 1 deletion apisix/plugins/loki-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local log_util = require("apisix.utils.log-util")
local core = require("apisix.core")
Expand Down Expand Up @@ -106,6 +105,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
required = {"endpoint_addrs"}
}
Expand Down Expand Up @@ -193,6 +194,9 @@ local function send_http_data(conf, log)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
5 changes: 5 additions & 0 deletions apisix/plugins/rocketmq-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
encrypt_fields = {"secret_key"},
required = {"nameserver_list", "topic"}
Expand Down Expand Up @@ -138,6 +140,9 @@ local function send_rocketmq_data(conf, log_message, prod)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
6 changes: 5 additions & 1 deletion apisix/plugins/skywalking-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local bp_manager_mod = require("apisix.utils.batch-processor-manager")
local plugin = require("apisix.plugin")
local log_util = require("apisix.utils.log-util")
Expand Down Expand Up @@ -55,6 +54,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
required = {"endpoint_addr"},
}
Expand Down Expand Up @@ -139,6 +140,9 @@ local function send_http_data(conf, log_message)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
5 changes: 5 additions & 0 deletions apisix/plugins/sls-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
timeout = {type = "integer", minimum = 1, default= 5000},
log_format = {type = "object"},
host = {type = "string"},
Expand Down Expand Up @@ -158,6 +160,9 @@ local function handle_log(entries)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
6 changes: 5 additions & 1 deletion apisix/plugins/syslog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local core = require("apisix.core")
local log_util = require("apisix.utils.log-util")
local bp_manager_mod = require("apisix.utils.batch-processor-manager")
Expand Down Expand Up @@ -50,6 +49,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
required = {"host", "port"}
}
Expand Down Expand Up @@ -85,6 +86,9 @@ function _M.check_schema(conf, schema_type)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
5 changes: 5 additions & 0 deletions apisix/plugins/tcp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
required = {"host", "port"}
}
Expand Down Expand Up @@ -132,6 +134,9 @@ local function send_tcp_data(conf, log_message)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
7 changes: 5 additions & 2 deletions apisix/plugins/tencent-cloud-cls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

local core = require("apisix.core")
local plugin = require("apisix.plugin")
local log_util = require("apisix.utils.log-util")
Expand All @@ -23,7 +22,6 @@ local cls_sdk = require("apisix.plugins.tencent-cloud-cls.cls-sdk")
local math = math
local pairs = pairs


local plugin_name = "tencent-cloud-cls"
local batch_processor_manager = bp_manager_mod.new(plugin_name)
local schema = {
Expand Down Expand Up @@ -55,6 +53,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = { type = "integer", minimum = 1, default = 524288 },
max_resp_body_bytes = { type = "integer", minimum = 1, default = 524288 },
global_tag = { type = "object" },
log_format = {type = "object"},
},
Expand Down Expand Up @@ -105,8 +105,11 @@ function _M.access(conf, ctx)
if conf.sample_ratio == 1 or math.random() < conf.sample_ratio then
core.log.debug("cls sampled")
ctx.cls_sample = true
else
return
end

log_util.check_and_read_req_body(conf, ctx)
end


Expand Down
5 changes: 5 additions & 0 deletions apisix/plugins/udp-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ local schema = {
type = "array"
}
},
max_req_body_bytes = {type = "integer", minimum = 1, default = 524288},
max_resp_body_bytes = {type = "integer", minimum = 1, default = 524288},
},
required = {"host", "port"}
}
Expand Down Expand Up @@ -117,6 +119,9 @@ local function send_udp_data(conf, log_message)
end


_M.access = log_util.check_and_read_req_body


function _M.body_filter(conf, ctx)
log_util.collect_body(conf, ctx)
end
Expand Down
Loading
Loading