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

output tcp server return repeat message #7

Open
jordansissel opened this issue May 17, 2015 · 0 comments
Open

output tcp server return repeat message #7

jordansissel opened this issue May 17, 2015 · 0 comments

Comments

@jordansissel
Copy link
Contributor

(This issue was originally filed by @binlaniua at elastic/logstash#2181)


new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Socket socket = new Socket("xx", xx);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    String line = null;
                    while((line = reader.readLine()) != null){
                        System.out.println("thread one: " +line);
                    }
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Socket socket = new Socket("xx", xx);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    String line = null;
                    while((line = reader.readLine()) != null){
                        System.out.println("thread two: " +line);
                    }
                } catch (UnknownHostException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

the logstash config

input {

    file {
        path => "xx/access.log"
        type => "web_nginx_access"
    }

}


output {

    tcp {
        host => "xx"
        port => xx
        mode => "server"
    }
}

when i access the nginx website, the console print

thread one: {"message":"xx|-|[05/Dec/2014:09:16:49 +0800]|GET / HTTP/1.1|304|0|-|Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36|-|0.000|530|-","@version":"1","@timestamp":"2014-12-05T01:16:50.064Z","type":"web_nginx_access","host":"lin-22-36","path":"xx/access.log"}
thread two: {"message":"xx|-|[05/Dec/2014:09:16:49 +0800]|GET / HTTP/1.1|304|0|-|Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36|-|0.000|530|-","@version":"1","@timestamp":"2014-12-05T01:16:50.064Z","type":"web_nginx_access","host":"lin-22-36","path":"xx/access.log"}

i want the logstash each message to one client, not all.. how can i do..

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