Ruby on Rails
Friday, August 17, 2018
On Thursday, 16 August 2018 22:34:36 UTC+2, Hassan Schroeder wrote:
On Thu, Aug 16, 2018 at 1:04 AM, belgoros <s.ca...@gmail.com> wrote:
> Yeas, I knew that. I tried both tcp and udp, none of them worked. The only
> one that works is when I specify the type as file:
>
> config.lograge.logger = LogStashLogger.new(type: :file, path:
> 'log/development.log', sync: true)
Taking "lograge" out of the picture for the moment, using this config:
config.logger = LogStashLogger.new(type: :udp, host: '127.0.0.1',
port: 5228, verify_hostname: false)
> This way the logs shall be written in Logstash format in development.log.
> The question I have not found the answer to is what host and port values
> should correspond to ? Are they the values of Logstash server ?
I do this below in a Rails console:
Loading development environment (Rails 5.2.1)
2.5.1 (main):0 > Rails.logger.info("test message from a rails app")
=> true
2.5.1 (main):0 > Rails.logger.flush()
=> true
2.5.1 (main):0 >
with this test endpoint (Erlang, but that's not important)
Eshell V9.2 (abort with ^G)
1> {ok, Logstash} = gen_udp:open(5228, [binary, {active,false}]).
{ok,#Port<0.490>}
2> gen_udp:recv(Logstash, 0).
{ok,{{127,0,0,1},
49369,
<<"{\"message\":\"test message from a rails
app\",\"@timestamp\":\"2018-08-16T13:25:48.113-07:00\",\"@ versio"...>>}}
3>
Note that nothing showed up on receiving end until I flushed the logger
on the Rails side, so that might have something to do with your testing
not apparently doing anything. But for sure, the `host` and `port` values
are for the remote logstash endpoint.
HTH!
Thank you for your time. Yeah, I also tested Lograge/Logstash from inside the rails console in the deployed docker container:
rails c
logger = LogStashLogger.new(type: :tcp, host: 'logstash_host', port: logstash_port, verify_hostname: false)
logger.info 'logstash-draft => test port XXX'
and I could see the produced log message in Kibana dashboard.
The problem is now on Logstash server configuration side :) (devops will take a look at that).
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/954591d3-7e02-4f81-a214-5e07e83f88f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment