Skip to content

Sent log data to logstash, log loss occurred? #41

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

Open
vegaoqiang opened this issue Dec 19, 2017 · 0 comments
Open

Sent log data to logstash, log loss occurred? #41

vegaoqiang opened this issue Dec 19, 2017 · 0 comments

Comments

@vegaoqiang
Copy link

vegaoqiang commented Dec 19, 2017

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
@vegaoqiang vegaoqiang changed the title 发送日志到logstash,出现丢失日志的情况? Sent log to logstash, log loss occurred? Dec 20, 2017
@vegaoqiang vegaoqiang changed the title Sent log to logstash, log loss occurred? Sent log data to logstash, log loss occurred? Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant