Coder Social home page Coder Social logo

apachebench_statsd_testing's Introduction

Level 1

  • 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'))

Level 2

latency

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)

Level 3

  • 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.

tags

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

Level 4

  • 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.

counter

Level 5

  • 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.

agentCheck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.