pblittle / docker-logstash

Docker image for Logstash 1.4
https://hub.docker.com/r/pblittle/docker-logstash
MIT License
236 stars 90 forks source link

Logging to container - which port? #82

Closed ashleyconnor closed 9 years ago

ashleyconnor commented 9 years ago

I've fired up a container using the the command in the readme

$ docker run -d \
-p 9292:9292 \
-p 9200:9200 \
pblittle/docker-logstash

Now I'm attempting to get logs to show up on the Kibana web interface using logstash-logger

The problem is, I'm not sure what port to use in order to log to this container. Kibana is running on 9292 and elasticsearch is running on 9200. So which port should I use? I've tried (9292, 9200) which are exposed. Passed in -p 514:514 to the first command.

tcp_logger = LogStashLogger.new(type: :tcp, host: '192.168.59.103', port: 9292)
=> #<Logger:0x007fe111345090
 @default_formatter=#<Logger::Formatter:0x007fe111345068 @datetime_format=nil>,
 @device=#<LogStashLogger::Device::TCP:0x007fe111345108 @host="192.168.59.103", @port=9292, @ssl_certificate=nil, @sync=nil, @use_ssl=false>,
 @formatter=#<LogStashLogger::Formatter:0x007fe111344c58 @datetime_format=nil>,
 @level=0,
 @logdev=
  #<Logger::LogDevice:0x007fe111345018
   @dev=#<LogStashLogger::Device::TCP:0x007fe111345108 @host="192.168.59.103", @port=9292, @ssl_certificate=nil, @sync=nil, @use_ssl=false>,
   @filename=nil,
   @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fe111344ff0 @mon_count=0, @mon_mutex=#<Mutex:0x007fe111344f00>, @mon_owner=nil>,
   @shift_age=nil,
   @shift_size=nil>,
 @progname=nil>
main > logger.error '{"message": "error"}'
LogStashLogger::Device::UDP - Errno::ECONNREFUSED - Connection refused
ashleyconnor commented 9 years ago

Ah figured it out.

The default config you supply doesn't contain any exposed ports (for security I'm guessing) so I replace it with a config that exposes a port.

input {
  tcp { port => 3333 type => "json event" codec => json_lines {} }

  stdin {
    type => "stdin-type"
  }

  file {
    type => "syslog"
    path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
  }

  file {
    type => "logstash"
    path => [ "/var/log/logstash/logstash.log" ]
    start_position => "beginning"
  }
}

I can then run:

docker run -d \
-p 9292:9292 \
-p 9200:9200 \
-p 3333:3333 \
-e LOGSTASH_CONFIG_URL="https://gist.githubusercontent.com/ashleyconnor/c7267f5d66a49c2755fa/raw/8dcacbaf05d998861985648af2835f833643b0c4/logstash.conf" \
pblittle/docker-logstash

And now it is accepting logs - although I still have a few issues with my client.

pblittle commented 9 years ago

@ashleyconnor, sorry for the delay. I'm glad you figured out the port question. What's going on with this issue:

And now it is accepting logs - although I still have a few issues with my client.

Let me know if I can help.