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

cannot send log to logstash by tcp protocol #29

Closed
anjia0532 opened this issue Sep 8, 2017 · 2 comments · May be fixed by #30
Closed

cannot send log to logstash by tcp protocol #29

anjia0532 opened this issue Sep 8, 2017 · 2 comments · May be fixed by #30

Comments

@anjia0532
Copy link

env

host

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

elk version 5.5.2

openresty version 1.11.2.5

lua-resty-logger-socket version 0.03(lastest code version)

openresty configure params

./configure --prefix=/etc/openresty \
--user=nginx \
--group=nginx \
--with-cc-opt='-O2 -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \
--with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' \
--with-pcre-jit \
--with-stream \
--with-stream_ssl_module \
--with-http_v2_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_gunzip_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_auth_request_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--without-http_fastcgi_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--without-http_autoindex_module \
--without-http_memcached_module \
--without-http_empty_gif_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_browser_module \
--without-http_rds_json_module \
--without-http_rds_csv_module \
--without-http_memc_module \
--without-http_redis2_module \
--without-lua_resty_memcached \
--without-lua_resty_mysql \
-j4

nginx conf

lua_package_path "/path/to/lua-resty-logger-socket/lib/?.lua;;";

    server {
        location / {
            log_by_lua '
                local logger = require "resty.logger.socket"
                local cjson= require "cjson"

                if not logger.initted() then
                    local ok, err = logger.init{
                        host = '127.0.0.1',
                        port = 5044,
                        flush_limit = 0,
                        drop_limit = 1048576, --1024*1024=1mb
                    }
                    if not ok then
                        ngx.log(ngx.ERR, "failed to initialize the logger: ",
                                err)
                        return
                    end
                end

                local bytes, err = logger.log(cjson.encode({name='test'}))
                if err then
                    ngx.log(ngx.ERR, "failed to log message: ", err)
                    return
                end
            ';
        }
    }

logstash conf

input {
    tcp {
        port => "5044"
        codec => "json_lines" #or json
    }
}
output {
  stdout { codec => rubydebug }
}

the logstash cannot receive tcp data

wireshark has many tcp dup ack and tcp Out-Of-Order info.

udp is ok,but udp maximum size of udp datagram is 64k

@anjia0532
Copy link
Author

PR /pull/30

@anjia0532
Copy link
Author

anjia0532 commented Sep 10, 2017

Note

codec plugin is plain , timeout > 0 is worked.


local ok, err = logger.init{
    ...
    timeout = 1000
    ...
}
logger.log("msg")

codec plugin is json or jsonlines,need timeout > 0 and msg append \n.

local ok, err = logger.init{
    ...
    timeout = 1000
    ...
}
logger.log("msg\\n")

update 2017-09-11 12:56:53

append line break to msg, timeout eq 0 also work.

in my chinese email list posted https://groups.google.com/forum/#!topic/openresty/icx9jcR6Ja0

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

Successfully merging a pull request may close this issue.

1 participant