-
Sign up for Datadog, get the agent reporting metrics from your local machine.
Answer: I have set up the agent reporting metrics for my local machine:host:Daras-MacBook-Air-2.local
-
Bonus question: what is the agent?
Answer: The agent is a piece of software that collects events and metrics on the users hosts for monitoring and managing performance data. -
Submit an event via the API.
Answer: To submit an event via the API, my code:require 'dogapi' api_key = 'DATADOG_API_KEY' dog = Dogapi::Client.new(api_key)
response = dog.emit_event(Dogapi::Event.new('Level 1 question 3', :msg_title => 'Support Engineer Dara Mao'))
-
Get an event to appear in your email inbox (the email address you signed up for the account with)
Answer: By adding @[email protected] in the event body. My code:require 'dogapi' api_key = 'DATADOG_API_KEY' dog = Dogapi::Client.new(api_key)
response = dog.emit_event(Dogapi::Event.new('Level 1 question 4 to @[email protected]', :msg_title => 'Support Engineer Dara Mao'))
-
Take a simple web app (in any of our supported languages) that you've already built and instrument your code with dogstatsd. This will create metrics.
Answer: I have implemented dogstatsd for one of my rails project, Blackbox. -
While running a load test (see References) for a few minutes, visualize page views per second. Send us the link to this graph!
Answer: This is the page view graph I generated using ApacheBench load test as follows:My code for page view:
require 'statsd' statsd = Statsd.new statsd.increment('page.views')
My code for load test:
ab -n 157 -c 10 http://127.0.0.1:3000/periods/show ab -n 2000 -c 10 http://127.0.0.1:3000/periods/show ab -n 364 -c 100 http://127.0.0.1:3000/periods/show ab -n 10034 -c 1 http://127.0.0.1:3000/periods/show ab -n 100 -c 10 http://127.0.0.1:3000/periods/show ab -n 750 -c 100 http://127.0.0.1:3000/periods/show
-
Create a histogram to see the latency; also give us the link to the graph. Bonus points for putting together more creative dashboards.
Answer: This dashboard includes histogram along with page view load test.
My code for histogram:
require 'statsd'
statsd = Statsd.new
begin = Time.now
statsd.increment('page.views')
end = Time.now
frame = end - begin
statsd.histogram('statsd.increment.latency', frame)
- tag your metrics with
support
(one tag for all metrics) - tag your metrics per page.
Answer: I have added:tags =>['support, support:page1']
and:tags =>['support, support:page2']
to all the metrics for 2 pages of the app. - visualize the latency by page on a graph (using stacked areas, with one color per
page
)
Answer: Attached dashboard of graphs.
My code for load test:
ab -n 120 -c 100 http://127.0.0.1:3000/periods
ab -n 500 -c 10 http://127.0.0.1:3000/periods/show
ab -n 45 -c 1 http://127.0.0.1:3000/periods
ab -n 1532 -c 10 http://127.0.0.1:3000/periods/show
ab -n 3495 -c 1 http://127.0.0.1:3000/periods
ab -n 1200 -c 100 http://127.0.0.1:3000/periods/show
- count the overall number of page views using dogstatsd counters.
- count the number of page views, split by page (hint: use tags)
- visualize the results on a graph
- Bonus question: do you know why the graphs are very spiky?
Answer: Attached dashboard of graphs. The spikes in the graphs are due to time lapse in page load.
-
Write an agent check that samples a random value. Call this new metric:
test.support.random
Answer: My code for random_test.py:import random import statsd
from checks import AgentCheck class RandomCheck(AgentCheck): def check(self, instance): self.gauge('test.support.random', random.random()) self.event({ "api_key": "DATADOG_API_KEY", "msg_title": "testing random AgentCheck", "tags": "test.support.random" })
print(random.random()) from statsd import statsd statsd.gauge('test.support.random', random.random())
My code for random_test.yaml:
init_config: default_timeout: 5
instances: - url: http://127.0.0.1:3000/periods
-
Visualize this new metric on Datadog, send us the link.
Answer: I ran a few random tests, see attached dashboard of graphs.