Skip to content
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 

Demo 2

This demo builds upon Demo 1. It demonstrates:

  • Adding characteristics to metrics
  • Analyzing the metrics using pandas

Adding characteristics to metrics

We update the middlware.py to add characteristics to our data as follows:

node_ids = ['10.0.1.1', '10.1.3.4']


def start_timer():
    request.start_time = time.time()


def stop_timer(response):
    # convert this into milliseconds for statsd
    resp_time = (time.time() - request.start_time)*1000
    node_id = node_ids[random.choice(range(len(node_ids)))]
    with open('metrics.csv', 'a', newline='') as f:
        csvwriter = csv.writer(f)
        csvwriter.writerow([
            str(int(time.time())), 'webapp1', node_id,
            request.endpoint, request.method, str(response.status_code),
            str(resp_time)
        ])

    return response
...

Run demo

  • $ sudo docker-compose up

Play with the data

docker-compose run will print a URL which you can copy-paste into the browser on our host.

Then, open the Analysis Jupyter Notebook by navigating to the demo2 directory.