docker: use profiles to optionally enable Prometheus, Loki and Grafana

This is used for demo, it makes sense to also do that for the other
components. This helps test one of the component temporarily, for
example during the e2e tests.
This commit is contained in:
Vincent Bernat
2025-09-06 17:19:57 +02:00
parent a61adbb59b
commit 529a8f69be
9 changed files with 39 additions and 14 deletions

14
.env
View File

@@ -11,15 +11,23 @@ COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-ipinfo.yml
# And you need to update the paths in config/akvorado.yaml.
## Prometheus (metrics)
# COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-prometheus.yml
# To enable Prometheus, uncomment the next line.
# COMPOSE_PROFILES=${COMPOSE_PROFILES+${COMPOSE_PROFILES-},}prometheus
COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-prometheus.yml
## Loki (logs)
# COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-loki.yml
# To enable Loki, uncomment the next line.
# COMPOSE_PROFILES=${COMPOSE_PROFILES+${COMPOSE_PROFILES-},}loki
COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-loki.yml
## Grafana (visualization)
# COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-grafana.yml
# To enable Grafana, uncomment the next line.
# COMPOSE_PROFILES=${COMPOSE_PROFILES+${COMPOSE_PROFILES-},}grafana
COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-grafana.yml
## Demo
# To enable the demo exporters, uncomment the next line.
# COMPOSE_PROFILES=${COMPOSE_PROFILES+${COMPOSE_PROFILES-},}demo
COMPOSE_FILE=${COMPOSE_FILE}:docker/docker-compose-demo.yml
## For testing only: use a ClickHouse cluster

View File

@@ -104,5 +104,7 @@ When using `docker compose`, use the following commands to get an updated
# docker compose up -d
```
The `docker-compose-upgrade.tar.gz` tarball contains `.env.dist` instead of `.env`.
You may want to check for differences with your setup. Usually, there are no differences.
The `docker-compose-upgrade.tar.gz` tarball contains `.env.dist` instead of
`.env`, and `docker/docker-compose-local.yml.dist` instead of
`docker/docker-compose-local.yml.dist`. You may want to check for differences
with your setup.

View File

@@ -928,12 +928,19 @@ Then, you can restart the **outlet** service.
The default Docker Compose setup is meant to help you get started quickly. However,
you can also use it for a production setup.
The `.env` file selects the Docker Compose files that are assembled for a
complete setup. Look at the comments for guidance. You should avoid modifying
any existing files, except for `docker/docker-compose-local.yml`, which should
contain your local setup.
You are allowed to modify `.env` and `docker/docker-compose-local.yml`, as well
as anything in `config/`. Everything else will be erased during upgrades.
This file can override parts of the configuration. The [merge
The `.env` file tailors the complete Docker Compose setup. Some parts are
enabled using [Docker Compose
profiles](https://docs.docker.com/compose/how-tos/profiles/). You can
temporarily enable them with `--profile` flag to `docker compose`. In this case,
any profile set with `COMPOSE_PROFILES` are overridden. Some other parts require
you to uncomment additional Docker Compose configuration files directly in
`.env`.
This `docker/docker-compose-local.yml` file can override parts of the
configuration. The [merge
rules](https://docs.docker.com/reference/compose-file/merge/) are a bit complex.
The general rule is that scalars are replaced, while lists and mappings are
merged. However, there are exceptions.

View File

@@ -12,6 +12,8 @@ identified with a specific icon:
## Unreleased
- 💥 *docker*: use profiles to optionally enable Prometheus, Loki, and Grafana
(if you were already using them, you also need to enable the profile)
- 🩹 *console*: display missing images in documentation
- 🩹 *console*: ensure main table is used when required even when there is no data
- 🩹 *docker*: fix broken `/metrics` endpoint for inlet

View File

@@ -4,8 +4,7 @@ services:
extends:
file: versions.yml
service: akvorado
profiles:
- demo
profiles: [ demo ]
restart: unless-stopped
command: demo-exporter http://akvorado-orchestrator:8080#0
depends_on:

View File

@@ -189,7 +189,7 @@ services:
file: versions.yml
service: vector
restart: "no"
profiles: [manual]
profiles: [ manual ]
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./vector.yaml:/etc/vector/vector.yaml:ro

View File

@@ -6,6 +6,7 @@ services:
extends:
file: versions.yml
service: grafana
profiles: [ grafana ]
environment:
GF_SERVER_ROOT_URL: /grafana
GF_SERVER_SERVE_FROM_SUB_PATH: "true"

View File

@@ -7,6 +7,7 @@ services:
extends:
file: versions.yml
service: loki
profiles: [ loki ]
restart: unless-stopped
volumes:
- akvorado-loki:/loki
@@ -23,6 +24,7 @@ services:
extends:
file: versions.yml
service: vector
profiles: [ loki ]
restart: unless-stopped
user: root # for access to /var/run/docker.sock
volumes:

View File

@@ -8,6 +8,7 @@ services:
extends:
file: versions.yml
service: prometheus
profiles: [ prometheus ]
restart: unless-stopped
volumes:
- akvorado-prometheus:/prometheus
@@ -38,6 +39,7 @@ services:
extends:
file: versions.yml
service: alloy
profiles: [ prometheus ]
restart: unless-stopped
user: root # for access to /var/run/docker.sock
volumes:
@@ -69,6 +71,7 @@ services:
extends:
file: versions.yml
service: node-exporter
profiles: [ prometheus ]
restart: unless-stopped
volumes:
- /:/host:ro,rslave
@@ -86,6 +89,7 @@ services:
extends:
file: versions.yml
service: cadvisor
profiles: [ prometheus ]
restart: unless-stopped
privileged: true
volumes: