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

feat(splunk-logger): allow configuring keepalive_timeout #11611

Merged
merged 3 commits into from
Sep 30, 2024
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
7 changes: 7 additions & 0 deletions apisix/plugins/splunk-hec-logging.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ local schema = {
type = "integer",
minimum = 1,
default = 10
},
keepalive_timeout = {
type = "integer",
minimum = 1000,
default = 60000,
description = "keepalive timeout in milliseconds",
}
},
required = { "uri", "token" }
Expand Down Expand Up @@ -142,6 +148,7 @@ local function send_to_splunk(conf, entries)
method = "POST",
body = table_concat(t),
headers = request_headers,
keepalive_timeout = conf.endpoint.keepalive_timeout
})

if not res then
Expand Down
1 change: 1 addition & 0 deletions docs/en/latest/plugins/splunk-hec-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ When the Plugin is enabled, APISIX will serialize the request context informatio
| endpoint.token | True | | Splunk HEC authentication token. |
| endpoint.channel | False | | Splunk HEC send data channel identifier. Read more: [About HTTP Event Collector Indexer Acknowledgment](https://docs.splunk.com/Documentation/Splunk/8.2.3/Data/AboutHECIDXAck). |
| endpoint.timeout | False | 10 | Splunk HEC send data timeout in seconds. |
| endpoint.keepalive_timeout | False | 60000 | Keepalive timeout in milliseconds. |
| ssl_verify | False | true | When set to `true` enables SSL verification as per [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake). |
| log_format | False | | Log format declared as key value pairs in JSON format. Values only support strings. [APISIX](../apisix-variable.md) or [Nginx](http://nginx.org/en/docs/varindex.html) variables can be used by prefixing the string with `$`. |

Expand Down
37 changes: 37 additions & 0 deletions t/plugin/splunk-hec-logging.t
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,40 @@ passed
tail -n 1 ci/pod/vector/splunk.log
--- response_body eval
qr/.*test batched data.*/



=== TEST 13: set route with keepalive_timeout (success write)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT, {
uri = "/hello",
upstream = {
type = "roundrobin",
nodes = {
["127.0.0.1:1980"] = 1
}
},
plugins = {
["splunk-hec-logging"] = {
endpoint = {
uri = "http://127.0.0.1:18088/services/collector",
token = "BD274822-96AA-4DA6-90EC-18940FB2414C",
keepalive_timeout = 5000
},
batch_max_size = 1,
inactive_timeout = 1
}
}
})

if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed
Loading