Ruby on Rails Tuesday, August 14, 2018



On Tuesday, 14 August 2018 15:14:20 UTC+2, belgoros wrote:
Can anybody provide some links to how to set up correctly Lograge, logstash-logger with a Rails API app ? I followed their READMEs but still nothing sent to Kibana :(.

Here is how these gems are declared in Gemfile:

group :development do

  gem
'lograge',         '~> 0.10.0'
  gem
'logstash-event',  '~> 1.2'
  gem
'logstash-logger', '~> 0.26.1'
end


I added the following lines in  config/environments/development.rb:

config.lograge.enabled = true
  config
.lograge.base_controller_class = 'ActionController::API'
  config
.lograge.formatter = Lograge::Formatters::Logstash.new
 
#config.lograge.logger = LogStashLogger.new(uri: ENV['logstash_uri'], verify_hostname: false)
  config
.lograge.logger = LogStashLogger.new(host: ENV['logstash_host'], port: ENV['logstash_port'], verify_hostname: false)
  config
.lograge.custom_options = lambda do |event|
   
{ name: "decastore-development" }
 
end


As you see, I tried 2 different ways to initialize LogStashLogger, but still without success.
What's wrong with that ? 
I'm using Rails 5.2.0 (API only), ruby 2.5.0.

Thank you

Even moving the above declaration to config/application.rb:

module MyAppApi
  class Application < Rails::Application


...
config
.api_only = true
   
    config
.lograge.enabled = true
    config
.lograge.base_controller_class = 'ActionController::API'
    config
.lograge.formatter = Lograge::Formatters::Logstash.new
    config
.lograge.logger = LogStashLogger.new(type: :tcp, host: ENV['logstash_host'], port: ENV['logstash_port'])
    config
.lograge.custom_options = lambda do |event|
     
{ name: "myapp-development" }
   
end



didn't send anything to Kibana.

--
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/c53e4f6d-d7d9-4c30-8e11-341b9fb035c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment