
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
github.com/grafana/quickpizza
QuickPizza
is a web application, used for demonstrations and workshops, that generates new and exciting pizza combinations!
The app is built using SvelteKit for the frontend and Go for the backend.
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.
To run the app locally with Docker, run the command:
docker run --rm -it -p 3333:3333 ghcr.io/grafana/quickpizza-local:latest
or build image from the repo:
docker run --rm -it -p 3333:3333 $(docker build -q .)
That's it!
Now you can go to localhost:3333 and get some pizza recommendations!
All tests live in the k6
folder. Within this folder, you will find the following folders:
To run tests on the foundations
folder, you can use the following commands:
cd k6/foundations
k6 run 01.basic.js
If you want to run one iteration with one virtual user, you can use the following command:
k6 run --iterations 1 --vus 1 01.basic.js
If QuickPizza is deployed remotely, then pass the hostname and port through the BASE_URL
environment variable as follows:
k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
cd k6/extensions
xk6 build --with xk6-internal=../internal
To run the test that uses the k6/x/internal
module, use previously created k6 binary in the k6/extensions
folder:
./k6 run 01.basic-internal.js
First, create a Docker network. Then, run Quickpizza, assigning a hostname and connecting to the created network.
docker network create quickpizza_network
docker run --network=quickpizza_network --hostname=quickpizza --rm -it -p 3333:3333 ghcr.io/grafana/quickpizza-local:latest
Next, you can use the k6 Docker image to execute the k6 test. Run the k6 Docker container within the same network (quickpizza_network
) and pass the BASE_URL
environment variable with the value of the Quickpizza container's hostname as follows:
docker run -i --network=quickpizza_network -e BASE_URL=http://quickpizza:3333 grafana/k6 run - <01.basic.js
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 or send it to Grafana Cloud.
If you encounter any issues during operation, you can enable debug logging by setting the following environment variable:
export QUICKPIZZA_LOG_LEVEL=debug
The docker-compose-local.yaml file is set up to run and orchestrate the QuickPizza, Grafana, Tempo, Loki, Prometheus, Pyroscope, and Grafana Alloy containers.
Grafana Alloy collects traces, metrics, logs and profiling data from the QuickPizza app, forwarding them to the Tempo, Prometheus and Loki. Finally, you can visualize and correlate data stored in these containers with the locally running Grafana instance.
To start the local environment, use the following command:
docker compose -f docker-compose-local.yaml up -d
Like before, QuickPizza is available at localhost:3333. It's time to discover some fancy pizzas!
Then, you can visit the Grafana instance running at localhost:3000 to access QuickPizza data.
Please refer to alloy-local.river and docker-compose-local.yaml to find the labels applied to the telemetry data.
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 Grafana Plugin.
[!TIP] To send Data to Pyroscope directly for a Local Setup, use the value
http://pyroscope:4040
for theQUICKPIZZA_PYROSCOPE_ENDPOINT
environment variable
To correlate the profiling data with the k6 test results, use the k6 Pyroscope library.
Additional variables are available to configure the Tags/Labels for the Profiles:
QUICKPIZZA_PYROSCOPE_NAME
- the value of the service_name
Label in Pyroscope (uses quickpizza
by default).QUICKPIZZA_PYROSCOPE_NAMESPACE
- the value of the namespace
Label in Pyroscope (uses quickpizza
by default).To send k6 results to the Prometheus instance, execute the k6 run
command with the value of the output
flag set to experimental-prometheus-rw
as follows:
k6 run -o experimental-prometheus-rw 01.basic.js
The local Grafana instance includes the k6 Prometheus and k6 Prometheus (Native Histogram) dashboards to help visualize, query, and correlate k6 results with telemetry data.
For detailed instructions about the different options of the k6 Prometheus output, refer to the k6 output guide for Prometheus remote write.
The docker-compose-cloud.yaml file is set up to run the QuickPizza and Grafana Alloy containers.
In this setup, Grafana Alloy collects observability data from the QuickPizza app and forwards it to Grafana Cloud.
You will need the following settings:
stacks:read
, metrics:write
, logs:write
, traces:write
, and profiles:write
.Then, create an .env
file with the following environment variables and the values of the previous settings:
# Your Grafana Cloud Stack Name (Slug)
GRAFANA_CLOUD_STACK=name
# Your Grafana Cloud Access Policy Token
GRAFANA_CLOUD_TOKEN=
# The Endpoint to use to send your Profiling Data too
QUICKPIZZA_PYROSCOPE_ENDPOINT=
# Your Grafana Cloud Profiles Username for your Grafana Cloud Stack
QUICKPIZZA_GRAFANA_CLOUD_USER=
# Your Grafana Cloud Profiles Password for your Grafana Cloud Stack (this is typically your Grafana Cloud Access Policy Token)
QUICKPIZZA_GRAFANA_CLOUD_PASSWORD=${GRAFANA_CLOUD_TOKEN}
Finally, execute the Docker Compose command using the docker-compose-cloud.yaml
file, just as in the local setup:
docker compose -f docker-compose-cloud.yaml up -d
QuickPizza is available at localhost:3333. Click the Pizza, Please!
button and discover some awesome pizzas!
Now, you can log in to Grafana Cloud and explore QuickPizza's telemetry data on the Prometheus, Tempo, Loki, and Pyroscope instances of your Grafana Cloud Stack. Refer to alloy-cloud.river and docker-compose-cloud.yaml to find the labels applied to the telemetry data.
Whenever there is a Pyroscope endpoint provided via the QUICKPIZZA_PYROSCOPE_ENDPOINT
environment variable, as well as suitable Authentication Credentials, the QuickPizza app will emit and push profiling data to Grafana Cloud Profiles. You can visualize the profiling data with the Grafana Cloud Profiles data source in Grafana Cloud and the Explore Profiles feature.
To enable Grafana Cloud Profiling, ensure the following Environment Variables are set in the .env
file, with values set to match your Grafana Cloud Stack:
QUICKPIZZA_PYROSCOPE_ENDPOINT
- The Endpoint to use to send your Profiling Data too for your Grafana Cloud Stack.QUICKPIZZA_GRAFANA_CLOUD_USER
and QUICKPIZZA_GRAFANA_CLOUD_PASSWORD
are the Basic auth credentials to authenticate with the Grafana Cloud instance.Additional variables are available to configure the Tags/Labels for the Profiles, and support some Grafana Cloud Profiling Integrations;
QUICKPIZZA_PYROSCOPE_NAME
- the value of the service_name
Label in Grafana Cloud Profiles (uses quickpizza
by default).QUICKPIZZA_PYROSCOPE_NAMESPACE
- the value of the namespace
Label in Grafana Cloud Profiles (uses quickpizza
by default).QUICKPIZZA_PYROSCOPE_SERVICE_GIT_REF
- This allows you to provide the Git Ref for the QuickPizza Source in GitHub, to use with the Go Profiles GitHub Integration in Grafana Cloud.Frontend Observability is available exclusively in Grafana Cloud. To enable Grafana Cloud Frontend Observability for QuickPizza, add the QUICKPIZZA_CONF_FARO_URL
variable to the .env
file, setting its value to your Faro web URL:
QUICKPIZZA_CONF_FARO_URL=
Restart the docker-compose-cloud.yaml
environment.
Just like in the local setup, we can output k6 result metrics to a Prometheus instance; in this case, it is provided by our Grafana Cloud Stack.
K6_PROMETHEUS_RW_USERNAME=USERNAME \
K6_PROMETHEUS_RW_PASSWORD=API_KEY \
K6_PROMETHEUS_RW_SERVER_URL=REMOTE_WRITE_ENDPOINT \
k6 run -o experimental-prometheus-rw script.js
For detailed instructions, refer to the k6 output guide for Grafana Cloud Prometheus.
The Dockerfile contains the setup for running QuickPizza without collecting data with Grafana Alloy.
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:
Then, run the CLI to deploy the application and set up the internal port 3333
that the server listens to.
fly launch --internal-port 3333 --now
For deployments on remote servers, you need to pass the BASE_URL
environment variable when running the k6 tests as follows:
k6 run -e BASE_URL=https://acmecorp.dev:3333 01.basic.js
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.
Example connection strings:
# a remote PostgreSQL instance
export QUICKPIZZA_DB="postgres://user:password@localhost:5432/database?sslmode=disable"
# a local sqlite3 database
export QUICKPIZZA_DB="quickpizza.db"
If you want to run a test that uses xk6-disruptor, or want to experiment with distributed tracing, you will need to deploy QuickPizza to Kubernetes.
For a detailed setup instructions, see the QuickPizza Kubernetes guide.
You can introduce errors from the client side using custom headers. Below is a list of the currently supported error headers:
Example of header usage:
curl -X POST http://localhost:3333/api/pizza \
-H "Content-Type: application/json" \
-H "Authorization: abcdef0123456789" \
-H "x-error-record-recommendation: internal-error" \
-H "x-error-record-recommendation-percentage: 20" \
-d '{}'
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.