Repository navigation
Closed
Description
Parent Epic: #216 (Implement ReleaseCommand and RunCommand with vertical slices)
Overview
Add Grafana as a metrics visualization service for the Torrust Tracker deployment. This extends the docker-compose stack with a Grafana service that connects to Prometheus for displaying tracker metrics through dashboards.
Key Features:
- Enabled by default in generated templates (opt-out pattern)
- Requires Prometheus to be enabled (hard dependency with validation)
- Exposes UI on port 3100 (public access until HTTPS/proxy added in roadmap task 6)
- Includes firewall configuration for port access
- Provides sample dashboards from torrust-demo as examples
Specification
Complete specification: docs/issues/grafana-slice-release-run-commands.md
Implementation Plan
Phase 1: Environment Configuration & Validation (1-2 hours)
- Create
GrafanaConfigdomain model withPasswordtype foradmin_password - Add
grafana: Option<GrafanaConfig>to environment user inputs - Implement Grafana-Prometheus dependency validation
- Add validation error with clear fix instructions
Phase 2: Docker Compose & Firewall Integration (2-3 hours)
- Add Grafana service to docker-compose template (conditional on config)
- Create environment variables context with Grafana credentials
- Create Ansible playbook for firewall configuration (
configure-grafana-firewall.yml) - Create
ConfigureGrafanaFirewallStepand integrate into configure command - Add
ConfigureGrafanaFirewalltoConfigureStepenum
Phase 3: Testing & Verification (2-3 hours)
- Add E2E test configurations (with/without Grafana, validation error)
- Create
GrafanaValidatorwith firewall verification - Update E2E tests for Grafana scenarios
- Manual testing with full deployment workflow
Phase 4: Documentation (1-2 hours)
- Create ADR for Grafana integration pattern
- Update user guide with Grafana configuration
- Create
docs/user-guide/services/grafana/with sample dashboards - Create manual verification guide
Acceptance Criteria
Functional Requirements
- Grafana service included in docker-compose when config present
- Validation fails if Grafana enabled but Prometheus disabled
- Port 3100 opened in firewall when Grafana enabled
- Grafana UI accessible externally from host machine
- Admin credentials work for login
- Grafana connects to Prometheus successfully
Testing Requirements
- Unit tests for domain model, validation, and firewall step
- E2E tests for all scenarios (enabled, disabled, validation error)
- Manual testing confirms deployment and external access
Quality Requirements
- Pre-commit checks pass:
./scripts/pre-commit.sh- No unused dependencies (
cargo machete) - All linters pass (markdown, yaml, toml, clippy, rustfmt, shellcheck)
- All unit tests pass (
cargo test- 1500+ tests) - E2E tests pass (
cargo run --bin e2e-deployment-workflow-tests)
- No unused dependencies (
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
Architecture
- DDD Layers: Infrastructure + Domain + Application
- New Modules:
src/domain/grafana/- Configuration domain typessrc/application/steps/configure_grafana_firewall.rs- Firewall stepsrc/application/command_handlers/create/config/validation/- Dependency validation
- Templates:
configure-grafana-firewall.yml.tera, docker-compose updates
Security Notes
admin_passwordusesPasswordtype from secrecy crate (automatic redaction, memory zeroing)- Port 3100 exposure is temporary until HTTPS/reverse proxy (roadmap task 6)
- Default credentials ("admin"/"admin") must be changed in production
Related
- Parent: Implement ReleaseCommand and RunCommand with vertical slices #216 (Epic - Implement ReleaseCommand and RunCommand)
- Reference: torrust-demo - Sample dashboards
- Dependency: Prometheus slice (Prometheus Slice - Release and Run Commands #238) must be completed first
Activity
docs: [#246] create Grafana slice specification
feat: [#246] add GrafanaConfig domain model
feat: [#246] add Grafana service configuration to UserInputs
feat: [#246] add GrafanaRequiresPrometheus error variant
feat: [#246] use NonZeroU32 for Prometheus scrape interval domain model
feat: [#246] implement Phase 2 Docker Compose integration for Grafana…
feat: [#246] implement Phase 3 Grafana firewall configuration
11 remaining items
docs: [#246] update Phase 3 & 4 progress with manual testing completi…
docs: [#246] complete Phase 4 - add Grafana terms to dictionary and f…
docs: [#246] mark all acceptance criteria as complete
docs: [#246] complete Phase 4 documentation and enable Grafana in E2E…
docs: [#246] Add extension tasks for Grafana health checks and auto-p…
feat: [#246] Add health checks for Prometheus and Grafana services
feat: [#246] Add Grafana datasource auto-provisioning and health checks
docs: [#246] Update issue progress and enhance Grafana verification g…
docs: [#246] Add note about upcoming show command for getting VM IP
docs: [#246] Add comprehensive tracker verification guide
test: [#246] Fix doctests creating schema.json artifacts in root
chore: remove closed issue documentation files
docs: mark Grafana slice as completed in roadmap
Merge #249: feat: [#248] implement Docker/UFW firewall security strategy