In this post I’ll share an example Docker Compose configuration to integrate Rails logs with Elasticsearch, Logstash, and Kibana.
Update Rails configuration to use environment variables. This enables Docker Compose to pass container hostnames and credentials.
1) Edit file: Gemfile, add: gem 'dotenv-rails'. Execute: bundle install.
And the corresponding controller, new file: app/controllers/api/pages_controller.rb. The controller simply responds in JSON with the passed params.
Execute: bundle install to install the new gems.
The app should now be accessible on port 80 through nginx.
Opened Kibana to view logs.