Git Product home page Git Product logo

loadtest_setup's Introduction

loadtest_setup

Load test setup with containerized Locust, Prometheus and Grafana

This project demonstrates how we can perform a load test with locust, scrape the results via locust_exporter into Prometheus and display them on Grafana.

This project is heavily insprired by this blog post by ContainerSolutions. The locust_exporter and Grafana dashboard are directly taken from the blog post itself. This project tries to put them all into a single docker-compose file which can run them at once.

I have modified the dashboard JSON to tweak a few things, remove unwanted panels, some cosmetic changes here and there. Feel free to modify the same as per your requirements. You can find the JSON at grafana/dashboard.json.

Data flow

We have kept all the ports as default ones, for ease of use. You can change them as per your convenience, in their respective config files.

  1. Locust starts on port 8089 and sends stats on the /stats/requests endpoint.
  2. locust_exporter scrapes this endpoint, converts the stats into a format that is understood by Prometheus and pushes them on port 9646
  3. Prometheus listens on this port (that's what we configure in prometheus/loadtest.yaml) and pushes its metris to port 9090
  4. Next, we configure Prometheus as datasource in Grafana (grafana/provisioning/datasources/prom.yaml) to read from port 9090.
  5. Lastly, we configure dashboard in Grafana (in grafana/provisioning/dashboards/loadtest.yaml).

Instructions

  1. Make sure your script is ready to be executed. It should be named as locustfile.py and must be present in the same directory as the docker_compose.yml
    1. If you want to run a different file, you can make changes the the docker_compose.yml.

Refer the tree structure below:

.
├── docker-compose.yml
├── grafana
│   ├── dashboard.json
│   └── provisioning
│       ├── dashboards
│       │   └── loadtest.yaml
│       └── datasources
│           └── prom.yaml
├── LICENSE
├── locustfile.py
├── prometheus
│   └── loadtest.yaml
├── requirements.py
└── setup.cfg
  1. Build and run services using docker-compose up
  2. Go to localhost:8089, enter the number of concurrent users, the spawn rate, the host, and begin.
    1. Alternately, you can also run locust in headless mode and just look at the Grafana dashboard in the next step.

locsut_start_page.png

  1. Go to localhost:3000 to view your Grafana dashboard.

grafana_dashboard.png

loadtest_setup's People

Contributors

saveshodhan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.