Commit 47d708a
committed
c8962e1 refactor: [#238] fix Law of Demeter violations and implement consistent delegation (Jose Celano)
a624d80 refactor: simplify execute() method in RenderDockerComposeTemplatesStep (Jose Celano)
f2c3cb0 refactor: implement Builder Pattern for DockerComposeContext (Jose Celano)
010e6fc refactor: use composition for TrackerPorts in DockerComposeContext (Jose Celano)
b056f2a style: apply rustfmt formatting to template renderers (Jose Celano)
22ef8ae refactor: reorganize docker_compose context module following conventions (Jose Celano)
cbeac26 feat: [#238] add Prometheus smoke test validation after run command (Jose Celano)
b79b436 chore: [#238] add Traefik to project dictionary and fix formatting (Jose Celano)
4292c9a refactor: [#238] standardize renderer constants to use three-part pattern (Jose Celano)
8638430 docs: [#238] add comprehensive security guide for production deployments (Jose Celano)
3eb96f9 docs: [#238] refactor user guide to extract Prometheus content into service-specific guide (Jose Celano)
254a9a8 docs: [#238] refactor manual E2E testing documentation to eliminate duplication (Jose Celano)
c0e3192 refactor: simplify Prometheus build directory structure (Jose Celano)
1bdd612 docs: [#238] mark issue complete - all 8 phases implemented (Jose Celano)
2a820e2 feat: [#238] add Prometheus integration documentation (Phase 8) (Jose Celano)
a257fcf feat: [#238] add E2E validation and manual testing guide for Prometheus (Phase 7) (Jose Celano)
2f33fe0 docs: [#238] mark Phase 6 complete with commit hash (Jose Celano)
9c1b91a feat: [#238] add Ansible deployment for Prometheus (Phase 6) (Jose Celano)
f20d45c feat: [#238] add independent Prometheus template rendering in release workflow (Jose Celano)
22790de feat: [#238] integrate Prometheus with Docker Compose (Jose Celano)
731eaf4 feat: [#238] implement Prometheus template renderer (Jose Celano)
92aab59 feat: [#238] add Prometheus domain configuration (Jose Celano)
2ca0fa9 feat: [#238] add PrometheusContext for template rendering (Jose Celano)
5ae2a69 feat: [#238] add Prometheus configuration template (Jose Celano)
64b1ae4 docs: [#238] update Prometheus slice spec with correct architecture (Jose Celano)
Pull request description:
## Overview
Implements issue #238 - Adds Prometheus as a metrics collection service for the Torrust Tracker deployment.
## Changes
This PR adds complete Prometheus integration across 8 phases:
### Phase 1: Template Structure & Data Flow Design (2ca0fa9)
- Created `PrometheusContext` struct for template rendering
- Implemented module structure following existing patterns
- Added `templates/prometheus/prometheus.yml.tera` template
- 5 comprehensive unit tests
### Phase 2: Environment Configuration (92aab59)
- Created `PrometheusConfig` domain struct in `src/domain/prometheus/`
- Added optional `prometheus` field to `UserInputs` (enabled by default)
- Updated constructors and test fixtures
- 5 comprehensive unit tests
### Phase 3: Prometheus Template Renderer (731eaf4)
- Created `PrometheusConfigRenderer` to load and render templates
- Implemented `PrometheusTemplate` wrapper for Tera integration
- Created `PrometheusProjectGenerator` for rendering workflow
- 12 comprehensive unit tests with full coverage
### Phase 4: Docker Compose Integration (22790de)
- Added `prometheus_config: Option<PrometheusConfig>` to `DockerComposeContext`
- Implemented `with_prometheus()` method for builder pattern
- Added conditional Prometheus service to `docker-compose.yml.tera`
- Bind mount: `./storage/prometheus/etc:/etc/prometheus:Z`
- 4 comprehensive unit tests
### Phase 5: Release Command Integration (f20d45c)
- **Fixed**: Moved Prometheus template rendering to independent step
- Created `RenderPrometheusTemplatesStep` in release handler
- Prometheus templates rendered independently (Step 5 of 9)
- Extended `EnvironmentTestBuilder` with `with_prometheus_config()`
- **Architectural Principle**: Each service renders templates independently
### Phase 6: Ansible Deployment (9c1b91a)
- Created Ansible playbooks for Prometheus storage and config deployment
- `create-prometheus-storage.yml` - Creates directory structure
- `deploy-prometheus-config.yml` - Deploys configuration with verification
- Registered playbooks in `AnsibleProjectGenerator` (16 total)
- Updated release handler with Prometheus deployment steps
### Phase 7: Testing & Verification (a257fcf)
- Refactored validation with `ServiceValidation` struct for extensibility
- Created `PrometheusConfigValidator` for file verification
- Updated E2E tests to use ServiceValidation pattern
- Created test environments (with/without Prometheus)
- Manual E2E testing completed successfully:
- ✅ Prometheus container running
- ✅ Both tracker endpoints scraped successfully
- ✅ Prometheus UI accessible
- ✅ Metrics being collected
- Created comprehensive manual testing documentation (450+ lines)
### Phase 8: Documentation (2a820e2)
- Created ADR: `docs/decisions/prometheus-integration-pattern.md`
- Documents enabled-by-default with opt-out approach
- Explains independent template rendering pattern
- Documents ServiceValidation struct for extensibility
- Updated user guide with Prometheus configuration section
- Added technical terms to project dictionary
## Key Features
✅ **Enabled by Default**: Prometheus included in generated environment templates
✅ **Opt-Out Available**: Users can disable by removing the `prometheus` section
✅ **Configuration-Driven**: Service presence controlled by config section existence
✅ **Independent Rendering**: Each service renders its templates independently
✅ **Extensible Testing**: ServiceValidation pattern supports future services (Grafana, etc.)
## Configuration
```json
{
"prometheus": {
"scrape_interval": 15
}
}
```
**To disable**: Remove the entire `prometheus` section from environment config.
## Architecture
- **DDD Layers**: Domain + Infrastructure + Application
- **Pattern**: Template System with Project Generator pattern
- **Service Detection**: Presence of `prometheus` section → Service enabled
- **Dependencies**: Prometheus depends on tracker service
## Testing
- ✅ All linters passing
- ✅ 1507+ tests passing
- ✅ E2E validation (automated + manual)
- ✅ Manual verification with real LXD VM deployment
## Documentation
- ADR: `docs/decisions/prometheus-integration-pattern.md`
- User Guide: `docs/user-guide/README.md`
- Manual Testing: `docs/e2e-testing/manual/prometheus-verification.md`
- Issue Tracking: `docs/issues/238-prometheus-slice-release-run-commands.md`
## Related Issues
Closes #238
Parent Epic: #216
## Checklist
- [x] All goals achieved
- [x] Code follows project conventions
- [x] All tests passing (unit + E2E)
- [x] All linters passing
- [x] Documentation complete (ADR + user guide + manual verification)
- [x] Manual testing completed successfully
ACKs for top commit:
josecelano:
ACK c8962e1
Tree-SHA512: 26e0e19a9a76d8457aedba7eb7f8cf41ae1a9d3f2a79c9106e35caa51c552efae1680b159bb865a84884e8e64c4071c940f043a017cb6b9588c3bad45857bbb7
File tree
56 files changed
+5223
-555
lines changed- docs
- decisions
- e2e-testing
- manual
- issues
- user-guide
- services
- src
- application
- command_handlers/release
- steps
- application
- rendering
- bin
- domain
- environment
- state
- prometheus
- infrastructure
- remote_actions/validators
- templating
- ansible/template/renderer
- docker_compose/template
- renderer
- wrappers/docker_compose
- prometheus
- template
- renderer
- wrapper
- prometheus_config
- tracker/template/renderer
- testing/e2e/tasks
- templates
- ansible
- docker-compose
- prometheus
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
56 files changed
+5223
-555
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
0 commit comments