- 2022-Docker Performance Testing
- Metrics for Apache applications running in Docker
- How to Provision Dashboard in Grafana
- Creating Docker Container Resource Consumption Dashboard
- Managing Dashboards through UI vs as Code
- Pull Docker metrics into Prometheus
- Pull Apache metrics into Prometheus
- Push Artillery metrics into Prometheus
- Testing with Artillery
-
Install Docker (Tested on version 20.10.23)
-
Install Docker Compose (Tested on version 2.16.0)
-
Create a docker
Volume
for grafana calledgrafana-storage
docker volume create grafana-storage
Follow the steps below to perform the observability tests on the PHP application:
-
Create a docker
Volume
for PostgreSQL:docker volume create postgres-data
-
Create inside the current directory a directory an
.env
file with the following content:UID=1000 GID=1000 POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=postgres
Change the values of UID and GID to your user and group IDs. To find out your user and group IDs, run the following commands:
id -u # User ID id -g # Group ID
-
Run the docker-compose:
docker compose -f docker-compose.yml up -d
-
Clone the repository app-apache-php
git clone [email protected]:MarioRP-01/app-apache-php.git # SSH git clone https://github.com/MarioRP-01/app-apache-php.git # HTTPS
-
Copy the .env file into the
app-apache-php
directory and change to theapp-apache-php
directory:cp .env app-apache-php/ cd app-apache-php
-
Follow the instructions of the set up resources guide to dump the information in the volume.
It's possible to use the
docker-compose.yml
containers instead of the ones in the guide. Skip the steps 1 and 2 in the Postgres section. -
Finally, copy the
resources
directory into this directory and remove theapp-apache-php
directory`:cp -r app-apache-php/resources ./apache-resources rm -rf app-apache-php
docker compose up -d
For grafana to be able to query prometheus, you need to create a data source in grafana. There are two ways to do this:
- Run the docker-compose file
- Open the browser and go to
localhost:3000
and login with the default username and passwordadmin:admin
- Go to Configuration > Data sources > Add data source
- Pick Prometheus as data type
- Save the URL as
http://prometheus:9090
and save the data source
Alternatively, you can create a provisioning file for grafana to automatically create the data source. See the directory grafana/provisioning/datasources
for an example. For more information, see the references section.
One of the goals of this repository is to be able to observe the changes in the metrics when the application is subjected to different loads. To do this, we use Artillery, a load testing tool that allows us to simulate different loads on the application.
The artillery
directory contains all the Artillery tests and other artifacts used by the tests.
-
Ensure that you have Artillery installed (last tested with version 2.0.0-31)
npm install -g artillery@latest
-
To run a specific test, execute the following command:
artillery run artillery/<test-script>
Replace
<test-script>
with the name of the Artillery test script you want to run.
-
To run the tests using Docker, execute the following command:
docker run --rm -it \ --volume ${PWD}/artillery:/scripts \ --network host \ artilleryio/artillery:2.0.0-31 \ run /scripts/<test-script>
Replace
<test-script>
with the name of the Artillery test script you want to run. -
Alternatively, you can use the shell script
run-artillery
to run the tests:./run-artillery <test-script>
Replace
<test-script>
with the name of the Artillery test script you want to run.
-
apache-test-1.yml
: Go to the main page, then ask for pages until there are no more pages to ask for.# Artillery CLI artillery run artillery/apache-test-1.yml
# Docker docker run --rm -it \ --volume ${PWD}/artillery:/scripts \ --network host \ artilleryio/artillery:2.0.0-31 \ run /scripts/apache-test-1.yml
# Shell script ./run-artillery apache-test-1.yml
-
apache-test-2.yml
: Go to the main page and then navigate to a new product each two seconds twenty times.# Artillery CLI artillery run artillery/apache-test-2.yml
# Docker docker run --rm -it \ --volume ${PWD}/artillery:/scripts \ --network host \ artilleryio/artillery:2.0.0-31 \ run /scripts/apache-test-2.yml
# Shell script ./run-artillery apache-test-2.yml
-
apache-test-3.yml
: Search for a product and navigate to the first result.# Artillery CLI artillery run artillery/apache-test-3.yml
# Docker docker run --rm -it \ --volume ${PWD}/artillery:/scripts \ --network host \ artilleryio/artillery:2.0.0-31 \ run /scripts/apache-test-3.yml
# Shell script ./run-artillery apache-test-3.yml
- Configuration used for cAdvisor in docker-compose
- How to monitor docker containers with Prometheus
- cAdvisor metrics for Prometheus