Hello there, I'm new here!
What I want to achieve
I want to set ELK stack on docker containers and configure it to listen and process logs coming from various applications in JSON form already, over tcp/udp/syslog (whatever will give me proper data).
What is my problem
Logstash can't collect logs over a specified port.
Details
I'll show you all my configuration in a moment but let me explain what I tried to do and what is going on.
For testing I wrote some simple log spammer in java and tried to send it over tcp or udp or syslog to logstash sitting on it's docker container. When I used SocketAppender in log4j everything worked and I managed to have all my logs in elasticsearch database and can visualize it in Kibana. But there is a problem. As far as I know SocketAppender doesn't support any conversionPattern and the output I've seen in kibana is messy. What does it mean is that one actual log, was splitted in a couple of messages, and grokparserfailure was seen. Neverthless, I tried to use syslogAppender to send logs already in JSON format straight to the logstash over say 3456 port. An example of such JSON:
{"source_host":"Wojter","method":"run","level":"ERROR","message":"This is error","mdc":{},"environment":"dev","@timestamp":"2017-01-10T15:41:42.365Z","file":"Logging.java","application":"spam","line_number":"21","thread_name":"pool-1-thread-1","@version":1,"logger_name":"Logging","class":"Logging"}
One important thing to notice is that using tcpdump I can see those logs being send all the time on this port, so the problem is probably input configuration of logstash.
Here is my configuration:
log4j appender:
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.SyslogHost=localhost:3456
log4j.appender.SYSLOG.Facility=Local3
log4j.appender.SYSLOG.Header=true
log4j.appender.SYSLOG.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern = net.logstash.log4j.JSONEventLayoutV1
Logstash conf file:
input {
syslog {
port => 3456
}
}
output {
elasticsearch {
hosts => "elasticsearch:9200"
}
stdout {
codec => rubydebug
}
}
I just can't get any single log into logstash. When I used socket appender it actually worked but here it doesn't.
I've read that syslog plugin may have a hard time to process such json logs so I switched it to udp, still to no success. Remember, those are java logs, not syslog ones, and I want to send them somehow to logstash in this particular pattern I showed you.
Please help me with this issue, because I'm literally stuck and I feel it can be easily fixed or achieved.
Greetings, Wojtek