Skip to content

Commit 63046a8

Browse files
feat(splunk-logger): allow configuring keepalive_timeout (#11611)
1 parent 1773655 commit 63046a8

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

apisix/plugins/splunk-hec-logging.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ local schema = {
5151
type = "integer",
5252
minimum = 1,
5353
default = 10
54+
},
55+
keepalive_timeout = {
56+
type = "integer",
57+
minimum = 1000,
58+
default = 60000,
59+
description = "keepalive timeout in milliseconds",
5460
}
5561
},
5662
required = { "uri", "token" }
@@ -142,6 +148,7 @@ local function send_to_splunk(conf, entries)
142148
method = "POST",
143149
body = table_concat(t),
144150
headers = request_headers,
151+
keepalive_timeout = conf.endpoint.keepalive_timeout
145152
})
146153

147154
if not res then

docs/en/latest/plugins/splunk-hec-logging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ When the Plugin is enabled, APISIX will serialize the request context informatio
4343
| endpoint.token | True | | Splunk HEC authentication token. |
4444
| 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). |
4545
| endpoint.timeout | False | 10 | Splunk HEC send data timeout in seconds. |
46+
| endpoint.keepalive_timeout | False | 60000 | Keepalive timeout in milliseconds. |
4647
| ssl_verify | False | true | When set to `true` enables SSL verification as per [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake). |
4748
| 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 `$`. |
4849

t/plugin/splunk-hec-logging.t

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,40 @@ passed
426426
tail -n 1 ci/pod/vector/splunk.log
427427
--- response_body eval
428428
qr/.*test batched data.*/
429+
430+
431+
432+
=== TEST 13: set route with keepalive_timeout (success write)
433+
--- config
434+
location /t {
435+
content_by_lua_block {
436+
local t = require("lib.test_admin").test
437+
local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT, {
438+
uri = "/hello",
439+
upstream = {
440+
type = "roundrobin",
441+
nodes = {
442+
["127.0.0.1:1980"] = 1
443+
}
444+
},
445+
plugins = {
446+
["splunk-hec-logging"] = {
447+
endpoint = {
448+
uri = "http://127.0.0.1:18088/services/collector",
449+
token = "BD274822-96AA-4DA6-90EC-18940FB2414C",
450+
keepalive_timeout = 5000
451+
},
452+
batch_max_size = 1,
453+
inactive_timeout = 1
454+
}
455+
}
456+
})
457+
458+
if code >= 300 then
459+
ngx.status = code
460+
end
461+
ngx.say(body)
462+
}
463+
}
464+
--- response_body
465+
passed

0 commit comments

Comments
 (0)