Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(syslog): correct the configuration #6551

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions apisix/plugins/syslog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ local schema = {
properties = {
host = {type = "string"},
port = {type = "integer"},
max_retry_times = {type = "integer", minimum = 1, default = 1},
retry_interval = {type = "integer", minimum = 0, default = 1},
max_retry_times = {type = "integer", minimum = 1},
retry_interval = {type = "integer", minimum = 0},
flush_limit = {type = "integer", minimum = 1, default = 4096},
drop_limit = {type = "integer", default = 1048576},
timeout = {type = "integer", minimum = 1, default = 3},
Expand All @@ -48,12 +48,7 @@ local lrucache = core.lrucache.new({
})


-- syslog uses max_retry_times/retry_interval/timeout
-- instead of max_retry_count/retry_delay/inactive_timeout
local schema = batch_processor_manager:wrap_schema(schema)
schema.max_retry_count = nil
schema.retry_delay = nil
schema.inactive_timeout = nil

local _M = {
version = 0.1,
Expand All @@ -69,11 +64,8 @@ function _M.check_schema(conf)
return false, err
end

-- syslog uses max_retry_times/retry_interval/timeout
-- instead of max_retry_count/retry_delay/inactive_timeout
conf.max_retry_count = conf.max_retry_times
conf.retry_delay = conf.retry_interval
conf.inactive_timeout = conf.timeout
conf.max_retry_count = conf.max_retry_times or conf.max_retry_count
conf.retry_delay = conf.retry_interval or conf.retry_delay
return true
end

Expand Down Expand Up @@ -103,8 +95,6 @@ local function send_syslog_data(conf, log_message, api_ctx)
drop_limit = conf.drop_limit,
timeout = conf.timeout,
sock_type = conf.sock_type,
max_retry_times = conf.max_retry_times,
retry_interval = conf.retry_interval,
pool_size = conf.pool_size,
tls = conf.tls,
}
Expand Down
4 changes: 2 additions & 2 deletions docs/en/latest/plugins/syslog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ This will provide the ability to send Log data requests as JSON objects.
| flush_limit | integer | optional | 4096 | [1, ...] | If the buffered messages' size plus the current message size reaches (>=) this limit (in bytes), the buffered log messages will be written to log server. Default to 4096 (4KB). |
| drop_limit | integer | optional | 1048576 | | If the buffered messages' size plus the current message size is larger than this limit (in bytes), the current log message will be dropped because of limited buffer size. Default to 1048576 (1MB). |
| sock_type | string | optional | "tcp" | ["tcp", "udp] | IP protocol type to use for transport layer. |
| max_retry_times | integer | optional | 1 | [1, ...] | Max number of retry times after a connect to a log server failed or send log messages to a log server failed. |
| retry_interval | integer | optional | 1 | [0, ...] | The time delay (in ms) before retry to connect to a log server or retry to send log messages to a log server |
| max_retry_times | integer | optional | | [1, ...] | Deprecated. Use max_retry_count instead. Max number of retry times after a connect to a log server failed or send log messages to a log server failed. |
| retry_interval | integer | optional | | [0, ...] | Deprecated. Use retry_delay instead. The time delay (in ms) before retry to connect to a log server or retry to send log messages to a log server |
| pool_size | integer | optional | 5 | [5, ...] | Keepalive pool size used by sock:keepalive. |
| include_req_body | boolean | optional | false | | Whether to include the request body |

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/latest/plugins/syslog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ title: syslog
| flush_limit | integer | 可选 | 4096 | [1, ...] | 如果缓冲的消息的大小加上当前消息的大小达到(> =)此限制(以字节为单位),则缓冲的日志消息将被写入日志服务器。默认为4096(4KB) |
| drop_limit | integer | 可选 | 1048576 | | 如果缓冲的消息的大小加上当前消息的大小大于此限制(以字节为单位),则由于缓冲区大小有限,当前的日志消息将被丢弃。默认为1048576(1MB) |
| sock_type | string | 可选 | "tcp" | ["tcp","udp"] | 用于传输层的 IP 协议类型。 |
| max_retry_times | integer | 可选 | 1 | [1, ...] | 连接到日志服务器失败或将日志消息发送到日志服务器失败后的最大重试次数。 |
| retry_interval | integer | 可选 | 1 | [0, ...] | 重试连接到日志服务器或重试向日志服务器发送日志消息之前的时间延迟(以毫秒为单位)。 |
| max_retry_times | integer | 可选 | | [1, ...] | 已废弃。请改用 `max_retry_count`。连接到日志服务器失败或将日志消息发送到日志服务器失败后的最大重试次数。 |
| retry_interval | integer | 可选 | | [0, ...] | 已废弃。请改用 `retry_delay`。重试连接到日志服务器或重试向日志服务器发送日志消息之前的时间延迟(以毫秒为单位)。 |
| pool_size | integer | 可选 | 5 | [5, ...] | sock:keepalive 使用的 Keepalive 池大小。 |
| include_req_body | boolean | 可选 | false | | 是否包括请求 body |

Expand Down
3 changes: 2 additions & 1 deletion t/plugin/syslog.t
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ done
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
-- before 2.13.0, timeout is incorrectly treated as inactive_timeout
[[{
"plugins": {
"syslog": {
"host" : "127.0.0.1",
"port" : 5044,
"flush_limit" : 1,
"timeout": 1
"inactive_timeout": 1
}
},
"upstream": {
Expand Down