Skip to content

Commit eb58d72

Browse files
authored
Update Docker Compose images for local setup and improve README organization (#220)
1 parent afa2418 commit eb58d72

File tree

6 files changed

+99
-125
lines changed

6 files changed

+99
-125
lines changed

README.md

Lines changed: 33 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,21 @@
44

55
## What is QuickPizza? 🍕🍕🍕
66

7-
`QuickPizza` is a web application, used for demonstrations and workshops, that generates new and exciting pizza combinations!
7+
**QuickPizza** is a simple web application, used for demonstrations and workshops, that generates new and exciting pizza combinations!
88

9-
The app is built using [SvelteKit](https://kit.svelte.dev/) for the frontend and [Go](https://go.dev/) for the backend.
109

11-
The tests written for `QuickPizza` demonstrates the basic and advanced functionalities of k6, ranging from a basic load test to using different modules and extensions. QuickPizza is used in the the [k6-oss-workshop](https://github.com/grafana/k6-oss-workshop).
10+
You can run QuickPizza locally or deploy it to your own infrastructure. For demo purposes, QuickPizza is also publicly available at:
11+
1. [quickpizza.grafana.com](https://quickpizza.grafana.com/)— Use this environment to run small-scale performance tests like the ones in the [k6 folder](./k6/).
12+
2. [quickpizza-demo.grafana.fun](https://quickpizza.grafana.com/) — Install the [SRE Demo environment](https://grafana.com/docs/grafana-cloud/get-started/#install-demo-data-sources-and-dashboards) to observe this deployment, or explore it in [Grafana Play](https://play.grafana.org/d/d2e206e1-f72b-448c-83d8-657831c2ea6d/).
1213

13-
## Requirements
14-
15-
- [Docker](https://docs.docker.com/get-docker/)
16-
- [Grafana k6](https://grafana.com/docs/k6/latest/set-up/install-k6/) (v0.53.0 or higher)
14+
The QuickPizza tests showcase key k6 features, from basic usage to custom modules and extensions.
1715

18-
## Run locally with Docker
19-
20-
To run the app locally with Docker, run the command:
21-
22-
```bash
23-
docker run --rm -it -p 3333:3333 ghcr.io/grafana/quickpizza-local:latest
24-
```
25-
26-
or build image from the repo:
27-
28-
```bash
29-
docker run --rm -it -p 3333:3333 $(docker build -q .)
30-
```
16+
## Requirements
3117

32-
That's it!
18+
- [Grafana k6](https://grafana.com/docs/k6/latest/set-up/install-k6/) (v1.0.0 or higher) to run the k6 tests used in this project to test QuickPizza.
19+
- [Docker](https://docs.docker.com/get-docker/) to run QuickPizza [locally](#run-locally-with-docker).
20+
- [Docker Compose](https://docs.docker.com/get-docker/) to run and instrument QuickPizza, storing metrics, logs, traces, and profiling data using the Grafana Observability stack. You can either [store this data locally](#run-and-observe-locally-with-grafana-oss-) or send it to [Grafana Cloud](#run-locally-and-observe-with-grafana-cloud-️).
3321

34-
Now you can go to [localhost:3333](http://localhost:3333) and get some pizza recommendations!
3522

3623
## Use k6 to test QuickPizza
3724

@@ -40,7 +27,6 @@ All tests live in the `k6` folder. Within this folder, you will find the followi
4027
- [foundations](k6/foundations/) - covers the basic functionalities of k6.
4128
- [browser](k6/browser/) - covers the [k6 browser module](https://grafana.com/docs/k6/latest/using-k6-browser/) for browser and web performance testing.
4229
- [extensions](k6/extensions/) - covers basic tests using [k6 extensions](https://grafana.com/docs/k6/latest/extensions/).
43-
- [disruptor](k6/disruptor/) - covers a more deep-dive look on how to use [xk6-disruptor](https://grafana.com/docs/k6/latest/testing-guides/injecting-faults-with-xk6-disruptor/first-steps/) for failure injection testing.
4430

4531
To run tests on the `foundations` folder, you can use the following commands:
4632

@@ -49,16 +35,10 @@ cd k6/foundations
4935
k6 run 01.basic.js
5036
```
5137

52-
If you want to run one iteration with one virtual user, you can use the following command:
53-
54-
```bash
55-
k6 run --iterations 1 --vus 1 01.basic.js
56-
```
57-
58-
If QuickPizza is [deployed remotely](#deploy-quickpizza-docker-image), then pass the hostname and port through the `BASE_URL` environment variable as follows:
38+
If QuickPizza is publicly available , then pass the hostname and port through the `BASE_URL` environment variable as follows:
5939

6040
```bash
61-
k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
41+
k6 run -e BASE_URL=https://quickpizza.grafana.com 01.basic.js
6242
```
6343

6444
<details>
@@ -99,21 +79,31 @@ k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
9979
```
10080
</details>
10181

102-
### Collect Telemetry (Docker Compose)
10382

104-
Testing something you can't observe is only half the fun. QuickPizza is instrumented using best practices to record logs, emit metrics, traces and allow profiling. You can either collect and [store this data locally](#local-setup) or send it to [Grafana Cloud](#grafana-cloud).
83+
## Run locally with Docker
10584

106-
### Enabling Debug Logging
85+
To run the app locally with Docker, run the command:
10786

108-
If you encounter any issues during operation, you can enable debug logging by setting the following environment variable:
87+
```bash
88+
docker run --rm -it -p 3333:3333 ghcr.io/grafana/quickpizza-local:latest
89+
```
90+
91+
or build image from the repo:
10992

110-
```shell
111-
export QUICKPIZZA_LOG_LEVEL=debug
93+
```bash
94+
docker run --rm -it -p 3333:3333 $(docker build -q .)
11295
```
11396

114-
---
97+
That's it!
98+
99+
Now you can go to [localhost:3333](http://localhost:3333) and get some pizza recommendations!
100+
101+
102+
103+
**Testing something you can't observe is only half the fun!** 🔍✨ QuickPizza is instrumented using best practices to record logs, emit metrics, traces and allow profiling. Get ready to dive deep into observability! 🚀
104+
105+
## Run and observe locally with Grafana OSS 🐳📊
115106

116-
## Local Setup
117107

118108
The [docker-compose-local.yaml](./docker-compose-local.yaml) file is set up to run and orchestrate the QuickPizza, Grafana, Tempo, Loki, Prometheus, Pyroscope, and Grafana Alloy containers.
119109

@@ -127,25 +117,11 @@ docker compose -f docker-compose-local.yaml up -d
127117

128118
Like before, QuickPizza is available at [localhost:3333](http://localhost:3333). It's time to discover some fancy pizzas!
129119

130-
Then, you can visit the Grafana instance running at [localhost:3000](http://localhost:3000) to access QuickPizza data.
131-
132-
Please refer to [alloy-local.river](./contrib/alloy-local.river) and [docker-compose-local.yaml](./docker-compose-local.yaml) to find the labels applied to the telemetry data.
133-
134-
### Correlate Pyroscope Data with k6 Tests
135-
136-
Whenever there is a Pyroscope instance endpoint provided via the `QUICKPIZZA_PYROSCOPE_ENDPOINT` environment variable, the QuickPizza app will emit and push profiling data to Pyroscope. You can visualize the profiling data with the Pyroscope data source in Grafana and the [Explore Profiles](https://grafana.com/docs/grafana/latest/explore/simplified-exploration/profiles/) Grafana [Plugin](https://grafana.com/grafana/plugins/grafana-pyroscope-app/).
137-
138-
> [!TIP]
139-
> To send Data to Pyroscope directly for a Local Setup, use the value `http://pyroscope:4040` for the `QUICKPIZZA_PYROSCOPE_ENDPOINT` environment variable
140-
141-
To correlate the profiling data with the k6 test results, use the [k6 Pyroscope library](https://grafana.com/docs/k6/next/javascript-api/jslib/http-instrumentation-pyroscope/).
120+
Then, you can visit the Grafana instance running at [localhost:3000](http://localhost:3000) and use **Explore** or **Drilldown apps** to access QuickPizza data.
142121

143-
![Pyroscope Data Source](./docs/images/local-env-grafana-with-pyroscope.png)
122+
![Use Profiles Drilldown](./docs/images/drilldown-profiles.png)
144123

145-
Additional variables are available to configure the Tags/Labels for the Profiles:
146-
147-
- `QUICKPIZZA_PYROSCOPE_NAME` - the value of the `service_name` Label in Pyroscope (uses `quickpizza` by default).
148-
- `QUICKPIZZA_PYROSCOPE_NAMESPACE` - the value of the `namespace` Label in Pyroscope (uses `quickpizza` by default).
124+
To find the labels applied to the telemetry data, refer to [alloy-local.river](./contrib/alloy-local.river) and [docker-compose-local.yaml](./docker-compose-local.yaml).
149125

150126
### Send k6 Test Results to Prometheus and visualize them in Grafana with prebuilt dashboards
151127

@@ -161,7 +137,7 @@ The local Grafana instance includes the [k6 Prometheus](https://grafana.com/graf
161137

162138
For detailed instructions about the different options of the k6 Prometheus output, refer to the [k6 output guide for Prometheus remote write](https://grafana.com/docs/k6/latest/results-output/real-time/prometheus-remote-write/).
163139

164-
## Grafana Cloud
140+
## Run locally and observe with Grafana Cloud ☁📊
165141

166142
The [docker-compose-cloud.yaml](./docker-compose-cloud.yaml) file is set up to run the QuickPizza and Grafana Alloy containers.
167143

@@ -238,66 +214,3 @@ k6 run -o experimental-prometheus-rw script.js
238214

239215
For detailed instructions, refer to the [k6 output guide for Grafana Cloud Prometheus](https://grafana.com/docs/k6/latest/results-output/real-time/grafana-cloud-prometheus/).
240216

241-
---
242-
243-
## Deploy QuickPizza Docker image
244-
245-
The [Dockerfile](./Dockerfile) contains the setup for running QuickPizza without collecting data with Grafana Alloy.
246-
247-
You can use the Dockerfile or build a Docker image to deploy the QuickPizza app on any cloud provider that supports Docker deployments. For simplicity, here are the `Fly.io` instructions:
248-
249-
1. [Authenticate using the fly CLI](https://fly.io/docs/speedrun/).
250-
2. Then, run the CLI to deploy the application and set up the internal port `3333` that the server listens to.
251-
252-
```bash
253-
fly launch --internal-port 3333 --now
254-
```
255-
256-
For deployments on remote servers, you need to pass the `BASE_URL` environment variable when running the k6 tests as follows:
257-
258-
```bash
259-
k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
260-
```
261-
262-
## Use an external database
263-
264-
By default, QuickPizza stores all its data in an in-memory SQLite database. This allows for a quick start while still closely resembling a real world application. If you want to add an external database, you can set the `QUICKPIZZA_DB` environment variable to a supported connection string. Currently only PostgreSQL and SQLite is supported.
265-
266-
Example connection strings:
267-
268-
```shell
269-
# a remote PostgreSQL instance
270-
export QUICKPIZZA_DB="postgres://user:password@localhost:5432/database?sslmode=disable"
271-
# a local sqlite3 database
272-
export QUICKPIZZA_DB="quickpizza.db"
273-
```
274-
275-
## Deploy the application to Kubernetes
276-
277-
If you want to run a test that uses [xk6-disruptor](https://grafana.com/docs/k6/latest/testing-guides/injecting-faults-with-xk6-disruptor/first-steps/), or want to experiment with distributed tracing, you will need to deploy QuickPizza to Kubernetes.
278-
279-
For a detailed setup instructions, see the [QuickPizza Kubernetes guide](./docs/kubernetes-setup.md).
280-
281-
## Injecting Errors from Client via Headers
282-
283-
You can introduce errors from the client side using custom headers. Below is a list of the currently supported error headers:
284-
285-
- **x-error-record-recommendation**: Triggers an error when recording a recommendation. The header value should be the error message.
286-
- **x-error-record-recommendation-percentage**: Specifies the percentage chance of an error occurring when recording a recommendation, if x-error-record-recommendation is also included. The header value should be a number between 0 and 100.
287-
- **x-delay-record-recommendation**: Introduces a delay when recording a recommendation. The header value should specify the delay duration and unit. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w", "y".
288-
- **x-delay-record-recommendation-percentage**: Specifies the percentage chance of a delay occurring when recording a recommendation, if x-delay-record-recommendation is also included. The header value should be a number between 0 and 100.
289-
- **x-error-get-ingredients**: Triggers an error when retrieving ingredients. The header value should be the error message.
290-
- **x-error-get-ingredients-percentage**: Specifies the percentage chance of an error occurring when retrieving ingredients, if x-error-get-ingredients is also included. The header value should be a number between 0 and 100.
291-
- **x-delay-get-ingredients**: Introduces a delay when retrieving ingredients. The header value should specify the delay duration and unit. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w", "y".
292-
- **x-delay-get-ingredients-percentage**: Specifies the percentage chance of a delay occurring when retrieving ingredients, if x-delay-get-ingredients is also included. The header value should be a number between 0 and 100.
293-
294-
Example of header usage:
295-
296-
```shell
297-
curl -X POST http://localhost:3333/api/pizza \
298-
-H "Content-Type: application/json" \
299-
-H "Authorization: abcdef0123456789" \
300-
-H "x-error-record-recommendation: internal-error" \
301-
-H "x-error-record-recommendation-percentage: 20" \
302-
-d '{}'
303-
```

docker-compose-local.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ services:
99
QUICKPIZZA_OTLP_ENDPOINT: http://alloy:4318
1010
QUICKPIZZA_TRUST_CLIENT_TRACEID: 1
1111
QUICKPIZZA_PYROSCOPE_ENDPOINT: http://pyroscope:4040
12+
# Enable logging. Possible values: error, warn, debug. Default: info
13+
# QUICKPIZZA_LOG_LEVEL: debug
14+
# Service name label in Pyroscope. Default: quickpizza
15+
# QUICKPIZZA_PYROSCOPE_NAME: quickpizza
16+
# Namespace label in Pyroscope. Default: quickpizza
17+
# QUICKPIZZA_PYROSCOPE_NAMESPACE: quickpizza
18+
# Database configuration (default: in-memory SQLite)
19+
# QUICKPIZZA_DB: postgres://user:password@postgres:5432/quickpizza?sslmode=disable
1220

1321
loki:
14-
image: grafana/loki:2.8.3
22+
image: grafana/loki:3.4.3
1523
ports:
1624
- "3100:3100"
1725

1826
prometheus:
19-
image: prom/prometheus:v2.47.0
27+
image: prom/prometheus:v3.2.1
2028
command:
2129
- --web.enable-remote-write-receiver
2230
- --enable-feature=native-histograms
@@ -25,12 +33,12 @@ services:
2533
- "9090:9090"
2634

2735
pyroscope:
28-
image: grafana/pyroscope:latest
36+
image: grafana/pyroscope:1.14.0
2937
ports:
3038
- "4040:4040"
3139

3240
tempo:
33-
image: grafana/tempo:2.1.0
41+
image: grafana/tempo:2.8.1
3442
command:
3543
- "-storage.trace.backend=local" # tell tempo where to permanently put traces
3644
- "-storage.trace.local.path=/tmp/tempo/traces"
@@ -43,7 +51,7 @@ services:
4351
- "4318:4318"
4452

4553
grafana:
46-
image: grafana/grafana:10.1.2
54+
image: grafana/grafana:${GRAFANA_VERSION:-12.0.2}
4755
ports:
4856
- "3000:3000"
4957
environment:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Deploy QuickPizza Docker image
2+
3+
The [Dockerfile](./Dockerfile) contains the setup for running QuickPizza without collecting data with Grafana Alloy.
4+
5+
You can use the Dockerfile or build a Docker image to deploy the QuickPizza app on any cloud provider that supports Docker deployments. For simplicity, here are the `Fly.io` instructions:
6+
7+
1. [Authenticate using the fly CLI](https://fly.io/docs/speedrun/).
8+
2. Then, run the CLI to deploy the application and set up the internal port `3333` that the server listens to.
9+
10+
```bash
11+
fly launch --internal-port 3333 --now
12+
```
13+
14+
For deployments on remote servers, you need to pass the `BASE_URL` environment variable when running the k6 tests as follows:
15+
16+
```bash
17+
k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
18+
```

docs/images/drilldown-profiles.png

595 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Injecting Errors from Client via Headers
2+
3+
You can introduce errors from the client side using custom headers. Below is a list of the currently supported error headers:
4+
5+
- **x-error-record-recommendation**: Triggers an error when recording a recommendation. The header value should be the error message.
6+
- **x-error-record-recommendation-percentage**: Specifies the percentage chance of an error occurring when recording a recommendation, if x-error-record-recommendation is also included. The header value should be a number between 0 and 100.
7+
- **x-delay-record-recommendation**: Introduces a delay when recording a recommendation. The header value should specify the delay duration and unit. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w", "y".
8+
- **x-delay-record-recommendation-percentage**: Specifies the percentage chance of a delay occurring when recording a recommendation, if x-delay-record-recommendation is also included. The header value should be a number between 0 and 100.
9+
- **x-error-get-ingredients**: Triggers an error when retrieving ingredients. The header value should be the error message.
10+
- **x-error-get-ingredients-percentage**: Specifies the percentage chance of an error occurring when retrieving ingredients, if x-error-get-ingredients is also included. The header value should be a number between 0 and 100.
11+
- **x-delay-get-ingredients**: Introduces a delay when retrieving ingredients. The header value should specify the delay duration and unit. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w", "y".
12+
- **x-delay-get-ingredients-percentage**: Specifies the percentage chance of a delay occurring when retrieving ingredients, if x-delay-get-ingredients is also included. The header value should be a number between 0 and 100.
13+
14+
Example of header usage:
15+
16+
```shell
17+
curl -X POST http://localhost:3333/api/pizza \
18+
-H "Content-Type: application/json" \
19+
-H "Authorization: abcdef0123456789" \
20+
-H "x-error-record-recommendation: internal-error" \
21+
-H "x-error-record-recommendation-percentage: 20" \
22+
-d '{}'
23+
```

docs/use-an-external-database.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Use an external database
2+
3+
By default, QuickPizza stores all its data in an in-memory SQLite database. This allows for a quick start while still closely resembling a real world application. If you want to add an external database, you can set the `QUICKPIZZA_DB` environment variable to a supported connection string. Currently only PostgreSQL and SQLite is supported.
4+
5+
Example connection strings:
6+
7+
```shell
8+
# a remote PostgreSQL instance
9+
export QUICKPIZZA_DB="postgres://user:password@localhost:5432/database?sslmode=disable"
10+
# a local sqlite3 database
11+
export QUICKPIZZA_DB="quickpizza.db"
12+
```

0 commit comments

Comments
 (0)