cloudflare / cloudflare/lua-resty-logger-socket

Sent log data to logstash, log loss occurred?

Open
#41 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Raku
Stars
493
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Use UDP to send the log data sent to logstash, about 10 requests per second, each sending a thousand probably only received 400-600, strange, Udp in the LAN, the concurrency is not high, how to lose the log It?

```
local logger = require "resty.logger.socket"
local json = require "cjson"

if not logger then
ngx.log(ngx.ERR, "can't required logger module")
end
if not logger.initted() then
local ok, err = logger.init{
host = '10.105.7.43',
port = 5000,
sock_type = 'udp',
flush_limit = 1,
drop_limit = 5678,
}
if not ok then
ngx.log(ngx.ERR, "failed to initialize the logger: ",
err)
end
end

local log = {}

local client = ngx.var.http_x_forwarded_for
local url = ngx.var.uri
local x_auth_token = ngx.req.get_headers()['X-AUTH-TOKEN']
local method = ngx.var.request_method

log['client'] = client
log['url'] = url
log['method'] = method
log['X-AUTH-TOKEN'] = x_auth_token

local bytes, err = logger.log(json.encode(log))
if bytes then
ngx.log(ngx.INFO, "send done")
end
if err then
ngx.log(ngx.ERR, "failed to log message: ", err)
end

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.