This integration enables you to get web access logging from your Sinatra applications in order to monitor:
Install the Agent on the instance that runs your Sinatra application.
Here is a configuration example that generate logs in a file and the console. This can be set in the Rack configuration file (
config.ru) or the configuration block for your Sinatra application.
require 'sinatra' configure do # logging is enabled by default in classic style applications, # so `enable :logging` is not needed file = File.new("/var/log/sinatra/access.log", 'a+') file.sync = true use Rack::CommonLogger, file end get '/' do 'Hello World' end
More details are available in the Rack recipes documentation.
This logger uses the common Apache Access format and generates logs in the following format:
127.0.0.1 - - [15/Jul/2018:17:41:40 +0000] "GET /uptime_status HTTP/1.1" 200 34 0.0004 127.0.0.1 - - [15/Jul/2018 23:40:31] "GET /uptime_status HTTP/1.1" 200 6997 1.8096
Available for Agent versions >6.0
Collecting logs is disabled by default in the Datadog Agent. Enable it in your
datadog.yaml file with:
Add this configuration block to your
sinatra.d/conf.yaml file at the root of your Agent’s configuration directory to start collecting your Sinatra application logs:
logs: - type: file path: /var/log/sinatra/access.log source: sinatra service: webapp
service parameter values and configure them for your environment.