No output from TCP input

Hi All,
I'm trying logstash with python TCP input, I followed some sample code here:

Adapted a bit the code, but I'm sending the exact same message through tcp.
From python output:
(MainThread) 2017-08-21 12:07:35,688 INFO b'{"@message": "Python test message", "@tags": ["python", "test"]}'

here is my logstash pipeline config file:
input {
tcp {
port => "9563"
host => "127.0.0.1"
codec => "json_lines"
}

	beats {
		port => "5043"
		}
}
output {
	stdout { codec => rubydebug}
	elasticsearch {
		hosts => [ "localhost:9200" ]
		}
	file {
		path => "E:\log\output.log"
	}
}

I turned on logstash logging into debug, and found out this log every time I execute the code:
[2017-08-21T12:07:35,691][DEBUG][logstash.inputs.tcp ] Accepted connection {:client=>"127.0.0.1:58256", :server=>"127.0.0.1:9563"}
[2017-08-21T12:07:35,694][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@id = "json_lines_4e6cdf95-0891-4c7f-90a1-c30fb1804c45"
[2017-08-21T12:07:35,694][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@enable_metric = true
[2017-08-21T12:07:35,695][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@charset = "UTF-8"
[2017-08-21T12:07:35,695][DEBUG][logstash.codecs.jsonlines] config LogStash::Codecs::JSONLines/@delimiter = "\n"
`[2017-08-21T12:07:35,697][DEBUG][logstash.inputs.tcp ] Connection closed {:client=>"127.0.0.1:58256"}

But after that, nothing happened, there is no stdout output, no log file generated, neither does any elasticsearch record created.

Would you pls help me on this?

After hours of trying, kind of solved issue, I tried with http input, using request lib in python , now Logstash can receive all the data properly and log them into the file properly.
For other new user as reference:

Here is the python code:
def __sendContentHTTP(self, content):
payload = {
'@message': content,
'@tags': ['your tag']
}
headers = {
'Content-Type': 'application/json'
}
r = requests.post('http://yourserver:yourport', data=json.dumps(payload), headers=headers)

Logstash config:
    input {
    	http {
    		port => 9654
    	}
    }
    filter {
    	json {
    		source => "message"
    	}
	
	split {
		field => "@message"
	}
}
output {
	stdout { }
	file { 
		path => "your path\your filename"
		codec => json
	}
}

But after that, nothing happened, there is no stdout output, no log file generated, neither does any elasticsearch record created.

Did you end each message with a newline? Judging by the JavaScript code you posted I'd say no.

Thanks
Probably that's the issue. The message I sent was about an object array with about 100 element in there, after json dumps from python, it probably became 1 line.
I might try a bit more and see

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.