Adress mail : [email protected]
The agent is a software that watch for metrics on your machine and send it to datadog.
require 'rubygems'
require 'dogapi'
api_key='...'
dog = Dogapi::Client.new(api_key)
dog.emit_event(Dogapi::Event.new('Hello dog !', :msg_title => 'Hello'))
require 'rubygems'
require 'dogapi'
api_key='...'
dog = Dogapi::Client.new(api_key)
dog.emit_event(Dogapi::Event.new('What if @[email protected] ?', :msg_title => 'Mailing with mention'))
For this par I took a local web app in Ruby on Rails with 4 public pages
- demoreel (root)
- production
- resume
- contact
I used the level2-tsung.xml file for load test
### Page views count & latency I've added some code in my static_pages_controller.rb
class StaticPagesController < ApplicationController
require 'statsd'
layout false
def contact
start = Time.now
s = Statsd.new
s.increment('web.page_views')
render 'contact'
lag = Time.now - start
s.histogram('latency', lag)
end
# [...]
# Similar for demoreel, production and resume function
end
I'm quite surprise by the result of the page views per second. There is none sometimes whereas there are some page views. .
### Tagging metrics
To tag metrics all metrics I've introduced a variable in my controller
common_tags = ["support"]
Then in each function I've introduced the specific tag
def contact
start = Time.now
s = Statsd.new
tags = Array.new(common_tags).push("page:contact")
s.increment('web.page_views', :tags => tags)
render 'contact'
lag = Time.now - start
s.histogram('latency', lag, :tags => tags)
end
### Overall number of page views and by page
First we need to create a random_check.yaml in /etc/dd-agent/conf.d/
init_config:
instances:
[{}]
Then random_check.py in /etc/dd-agent/checks.d/
from checks import AgentCheck
import random
class random_check(AgentCheck):
def check(self,instance):
self.gauge('test.support.random' , random.random())
And we restrat with sudo /etc/init.d/datadog-agent restart