decidim-telemetry 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/entrypoint.sh +153 -0
  3. data/.dockerignore +1 -0
  4. data/.erb-lint.yml +2134 -0
  5. data/.github/workflows/website.yml +52 -0
  6. data/.gitignore +13 -0
  7. data/.gitlab-ci.yml +157 -0
  8. data/.markdownlint.yaml +11 -0
  9. data/.prettierrc +4 -0
  10. data/.rspec +1 -0
  11. data/.rubocop.yml +2 -0
  12. data/CONTRIBUTING.md +21 -0
  13. data/Gemfile +39 -0
  14. data/Gemfile.lock +1094 -0
  15. data/LICENSE.md +661 -0
  16. data/README.md +58 -0
  17. data/Rakefile +42 -0
  18. data/app/controllers/decidim/telemetry/application_controller.rb +11 -0
  19. data/app/controllers/decidim/telemetry/health_controller.rb +68 -0
  20. data/bin/check +8 -0
  21. data/bin/ci-setup +21 -0
  22. data/bin/postversion +22 -0
  23. data/crowdin.yaml +23 -0
  24. data/decidim-telemetry.gemspec +39 -0
  25. data/docker-compose.ci.yml +48 -0
  26. data/docker-compose.yml +70 -0
  27. data/lib/decidim/telemetry/configuration.rb +33 -0
  28. data/lib/decidim/telemetry/engine.rb +138 -0
  29. data/lib/decidim/telemetry/middleware/basic_auth.rb +44 -0
  30. data/lib/decidim/telemetry/open_telemetry/configuration.rb +61 -0
  31. data/lib/decidim/telemetry/open_telemetry/configurator.rb +146 -0
  32. data/lib/decidim/telemetry/open_telemetry/decidim_context_attributes.rb +58 -0
  33. data/lib/decidim/telemetry/open_telemetry/logger_provider_resolver.rb +15 -0
  34. data/lib/decidim/telemetry/open_telemetry/logs_setup.rb +163 -0
  35. data/lib/decidim/telemetry/open_telemetry/otel_decidim_context.rb +36 -0
  36. data/lib/decidim/telemetry/open_telemetry/otel_error_subscriber.rb +101 -0
  37. data/lib/decidim/telemetry/open_telemetry/otel_logger.rb +127 -0
  38. data/lib/decidim/telemetry/open_telemetry/request_env.rb +37 -0
  39. data/lib/decidim/telemetry/open_telemetry.rb +18 -0
  40. data/lib/decidim/telemetry/overrides/decidim_application_controller.rb +20 -0
  41. data/lib/decidim/telemetry/overrides/decidim_proposal_command.rb +25 -0
  42. data/lib/decidim/telemetry/test/factories.rb +3 -0
  43. data/lib/decidim/telemetry/version.rb +11 -0
  44. data/lib/decidim/telemetry.rb +52 -0
  45. data/lib/tasks/decidim/telemetry/opentelemetry.rake +96 -0
  46. data/lib/tasks/decidim/telemetry/telemetry_upgrade.rake +13 -0
  47. data/lib/tasks/decidim/telemetry/telemetry_webpacker.rake +58 -0
  48. data/package.json +15 -0
  49. data/svgo.config.js +14 -0
  50. data/website/docs/configuration.md +78 -0
  51. data/website/docs/developer/_category_.json +4 -0
  52. data/website/docs/developer/code-of-conduct.md +16 -0
  53. data/website/docs/developer/contribute.md +70 -0
  54. data/website/docs/developer/documentation.md +47 -0
  55. data/website/docs/endpoints.md +62 -0
  56. data/website/docs/faq.md +61 -0
  57. data/website/docs/index.md +47 -0
  58. data/website/docs/install.md +79 -0
  59. data/website/docs/metrics.md +57 -0
  60. data/website/docs/opentelemetry.md +80 -0
  61. data/website/docs/prometheus.md +69 -0
  62. data/website/docs/security.md +50 -0
  63. data/website/docusaurus.config.ts +88 -0
  64. data/website/package.json +31 -0
  65. data/website/sidebars.ts +7 -0
  66. data/website/src/css/custom.css +22 -0
  67. data/website/static/img/logo.svg +1 -0
  68. data/website/tsconfig.json +6 -0
  69. data/website/yarn.lock +8336 -0
  70. metadata +294 -0
@@ -0,0 +1,47 @@
1
+ ---
2
+ sidebar_position: 2
3
+ title: Documentation website
4
+ description: Edit and build the Docusaurus site
5
+ ---
6
+
7
+ # Documentation website
8
+
9
+ [Docusaurus 3](https://docusaurus.io/) site with docs at the site root (`routeBasePath: /`). Published at [octree.ch/decidim-telemetry](https://octree.ch/decidim-telemetry/).
10
+
11
+ ## Site layout
12
+
13
+ ```text
14
+ website/docs/
15
+ index.md # Overview (sysadmin entry)
16
+ install.md # Installation
17
+ configuration.md # Env vars
18
+ endpoints.md # Health + metrics URLs
19
+ prometheus.md # Scrape jobs
20
+ metrics.md # Counter reference
21
+ security.md # Auth and exposure
22
+ faq.md # Troubleshooting
23
+ developer/ # Contributors
24
+ ```
25
+
26
+ Sidebar is autogenerated from the folder tree (`sidebars.ts`).
27
+
28
+ ## Edit locally
29
+
30
+ ```bash
31
+ cd website
32
+ yarn
33
+ yarn start
34
+ ```
35
+
36
+ ## Build before merge
37
+
38
+ ```bash
39
+ cd website && yarn build
40
+ ```
41
+
42
+ `onBrokenLinks: 'throw'` — fix broken links before merging.
43
+
44
+ ## See also
45
+
46
+ - [Contribute](./contribute.md)
47
+ - [Overview](../index.md)
@@ -0,0 +1,62 @@
1
+ ---
2
+ sidebar_position: 4
3
+ title: Endpoints
4
+ description: Health probes and metrics URL
5
+ ---
6
+
7
+ # Endpoints
8
+
9
+ All paths are mounted at the **host application root** (same port as Decidim unless noted).
10
+
11
+ **Prerequisite:** [Install](./install.md).
12
+
13
+ ## Health (always available)
14
+
15
+ | Path | Purpose | Auth |
16
+ |------|---------|------|
17
+ | `GET /health` | Simple OK check | none |
18
+ | `GET /health/live` | Liveness probe | none |
19
+ | `GET /health/ready` | Readiness probe | none |
20
+
21
+ ### Readiness checks
22
+
23
+ `/health/ready` returns `200` when all checks pass, `503` otherwise.
24
+
25
+ | Check | What it verifies |
26
+ |-------|------------------|
27
+ | `database` | PostgreSQL connection active |
28
+ | `yabeda` | Yabeda configured |
29
+ | `cache` | Rails cache read/write |
30
+ | `public_files_accessibles` | `public/decidim-packs/manifest.json` exists |
31
+ | `redis` | Redis answer to PING. Included only when `REDIS_URL` is set |
32
+
33
+ Example ready response:
34
+
35
+ ```json
36
+ {
37
+ "status": "ready",
38
+ "checks": {
39
+ "database": true,
40
+ "yabeda": true,
41
+ "cache": true,
42
+ "public_files_accessibles": true
43
+ },
44
+ "timestamp": "2026-06-26T12:00:00Z"
45
+ }
46
+ ```
47
+
48
+ ## Metrics (when enabled)
49
+
50
+ | Path | Content-Type | Condition |
51
+ |------|--------------|-----------|
52
+ | `GET /metrics` | `text/plain` | `DECIDIM_TELEMETRY_ENABLED=true` and `DECIDIM_TELEMETRY_MOUNT_EXPORTER=true` |
53
+
54
+ When `DECIDIM_TELEMETRY_MOUNT_EXPORTER=false`, scrape `/metrics` on the **Puma Yabeda port** (default `9394`) instead.
55
+
56
+ Basic auth applies to `/metrics` only when both `DECIDIM_TELEMETRY_USER` and `DECIDIM_TELEMETRY_PASSWORD` are set. See [Security](./security.md).
57
+
58
+ ## See also
59
+
60
+ - [Prometheus](./prometheus.md)
61
+ - [Metrics reference](./metrics.md)
62
+ - [FAQ](./faq.md)
@@ -0,0 +1,61 @@
1
+ ---
2
+ sidebar_position: 8
3
+ title: FAQ
4
+ description: Common installation and operations questions
5
+ ---
6
+
7
+ # FAQ
8
+
9
+ **Prerequisite:** [Install](./install.md).
10
+
11
+ ## `/health/ready` returns 503
12
+
13
+ Check the `checks` object in the JSON response:
14
+
15
+ | Failed check | Likely cause |
16
+ |--------------|--------------|
17
+ | `database` | PostgreSQL down or wrong `DATABASE_URL` |
18
+ | `cache` | Cache store misconfigured |
19
+ | `public_files_accessibles` | Assets not compiled — run `rails assets:precompile` |
20
+ | `yabeda` | Gem not loaded — verify `bundle install` and restart |
21
+ | `redis` | `REDIS_URL` set but Redis unreachable |
22
+
23
+ ## `/metrics` returns 404
24
+
25
+ - Confirm `DECIDIM_TELEMETRY_ENABLED=true`
26
+ - If `DECIDIM_TELEMETRY_MOUNT_EXPORTER=false`, scrape port **9394** instead of the Rails port
27
+ - Restart Puma after env changes
28
+
29
+ ## `/metrics` returns 401
30
+
31
+ Basic auth is enabled. Pass credentials in your scraper or unset `DECIDIM_TELEMETRY_USER` and `DECIDIM_TELEMETRY_PASSWORD`.
32
+
33
+ ## Metrics are empty or zero
34
+
35
+ - Counters increment on Decidim activity — generate a test comment or registration
36
+ - `rack_attack_matches` requires Rack::Attack rules to fire
37
+ - Check `DECIDIM_TELEMETRY_EXPORT_INTERVAL` — buckets are coarse by design
38
+
39
+ ## Do I need migrations?
40
+
41
+ No. `bundle install` is enough.
42
+
43
+ ## Does this send data to a third party?
44
+
45
+ No. Metrics stay on your infrastructure. Prometheus pulls from your app; nothing is pushed outbound by default.
46
+
47
+ OpenTelemetry only exports when you set `OTEL_*` endpoints and leave `config.open_telemetry.enabled` on — data goes to **your** OTLP collector.
48
+
49
+ ## Traces or logs do not appear
50
+
51
+ - Confirm `config.open_telemetry.enabled` is true and the feature flags you need (`traces_enabled`, `logs_enabled`) are true
52
+ - Set `OTEL_EXPORTER_OTLP_ENDPOINT` (or specific traces/logs endpoints)
53
+ - Run `bundle exec rake decidim:telemetry:opentelemetry:config` and `:test`
54
+ - Check app logs for `[OpenTelemetry]` messages; set `OTEL_DEBUG=true` for extra warnings
55
+
56
+ ## See also
57
+
58
+ - [Endpoints](./endpoints.md)
59
+ - [Configuration](./configuration.md)
60
+ - [OpenTelemetry](./opentelemetry.md)
61
+ - [Prometheus](./prometheus.md)
@@ -0,0 +1,47 @@
1
+ ---
2
+ sidebar_position: 1
3
+ slug: /
4
+ title: Overview
5
+ description: Prometheus metrics, health probes, and OpenTelemetry for Decidim
6
+ ---
7
+
8
+ # Decidim Telemetry
9
+
10
+ **decidim-telemetry** adds **Prometheus metrics**, **health probes**, and optional **OpenTelemetry** (traces, OTLP logs, exception reporting) to a running Decidim host application. It does not replace your monitoring stack — it exposes `/metrics` and `/health/*`, and can export OTLP data to your collector.
11
+
12
+ **Prerequisite:** a Decidim host app (≥ 0.29.4), Puma, and a Prometheus-compatible scraper. OpenTelemetry needs an OTLP collector when enabled.
13
+
14
+ ## What you get
15
+
16
+ - **Health endpoints** — liveness and readiness checks for orchestrators
17
+ - **Prometheus `/metrics`** — Decidim activity counters, Rack::Attack matches, Yabeda Rails/Puma/ActiveJob metrics
18
+ - **OpenTelemetry** — traces, WARN+ logs, and `Rails.error` exception spans (configurable)
19
+ - **No database migrations** — drop-in gem
20
+
21
+ ## Compatibility
22
+
23
+ | Decidim | Supported |
24
+ |---------|-----------|
25
+ | ≥ 0.29.4 | yes |
26
+ | 0.28 and older | no |
27
+
28
+ ## Quick install
29
+
30
+ ```ruby
31
+ # Gemfile
32
+ gem "decidim-telemetry", "~> 0.1"
33
+ ```
34
+
35
+ ```bash
36
+ bundle install
37
+ ```
38
+
39
+ Then follow [Install](./install.md) for Puma plugins, environment variables, and Prometheus scrape config. For traces and logs, see [OpenTelemetry](./opentelemetry.md).
40
+
41
+ ## See also
42
+
43
+ - [Install](./install.md)
44
+ - [Configuration](./configuration.md)
45
+ - [OpenTelemetry](./opentelemetry.md)
46
+ - [Endpoints](./endpoints.md)
47
+ - [Metrics reference](./metrics.md)
@@ -0,0 +1,79 @@
1
+ ---
2
+ sidebar_position: 2
3
+ slug: /install
4
+ title: Installation
5
+ description: Five steps to add observability to a Decidim host app
6
+ ---
7
+
8
+ # Installation
9
+
10
+ Install the gem on your **host application**. No migrations are required.
11
+
12
+ **Prerequisite:** [Overview](./index.md).
13
+
14
+ **Next:** [Configure environment variables](./configuration.md), then [Prometheus scrape](./prometheus.md).
15
+
16
+ ## 1. Add the gem
17
+
18
+ ```ruby
19
+ # Gemfile
20
+ gem "decidim-telemetry", "~> 0.1"
21
+ ```
22
+
23
+ ## 2. Bundle
24
+
25
+ ```bash
26
+ bundle install
27
+ ```
28
+
29
+ ## 3. Enable Puma metrics
30
+
31
+ Add to `config/puma.rb`:
32
+
33
+ ```ruby
34
+ activate_control_app
35
+ plugin :yabeda
36
+ plugin :yabeda_prometheus
37
+ ```
38
+
39
+ Puma exposes an additional metrics port (default **9394**) when `DECIDIM_TELEMETRY_MOUNT_EXPORTER=false`. See [Configuration](./configuration.md).
40
+
41
+ ## 4. Set environment variables
42
+
43
+ Minimum for production (metrics on the main Rails port):
44
+
45
+ ```bash
46
+ DECIDIM_TELEMETRY_ENABLED=true
47
+ ```
48
+
49
+ Optional tuning — full list in [Configuration](./configuration.md).
50
+
51
+ ## 5. Configure Prometheus and restart
52
+
53
+ Point your scraper at `/metrics` on port **3000** (or **9394** when the exporter is not mounted on Rails). Example in [Prometheus](./prometheus.md).
54
+
55
+ Restart Puma after changing env vars or `puma.rb`.
56
+
57
+ ## Kubernetes probes
58
+
59
+ ```yaml
60
+ livenessProbe:
61
+ httpGet:
62
+ path: /health/live
63
+ port: 3000
64
+ initialDelaySeconds: 30
65
+ readinessProbe:
66
+ httpGet:
67
+ path: /health/ready
68
+ port: 3000
69
+ periodSeconds: 10
70
+ ```
71
+
72
+ Probes do not require authentication. See [Endpoints](./endpoints.md).
73
+
74
+ ## See also
75
+
76
+ - [Configuration](./configuration.md)
77
+ - [Prometheus](./prometheus.md)
78
+ - [Security](./security.md)
79
+ - [FAQ](./faq.md)
@@ -0,0 +1,57 @@
1
+ ---
2
+ sidebar_position: 6
3
+ title: Metrics reference
4
+ description: Decidim-specific Prometheus counters
5
+ ---
6
+
7
+ # Metrics reference
8
+
9
+ Custom counters exported by decidim-telemetry. All use tags: `decidim_tenant`, `type`, `time_bucket`.
10
+
11
+ **Prerequisite:** [Endpoints](./endpoints.md).
12
+
13
+ ## Decidim counters
14
+
15
+ | Metric | Description |
16
+ |--------|-------------|
17
+ | `decidim_activity_per_minute` | Incremented on every `decidim.*` notification event |
18
+ | `decidim_registrations` | New participant welcome notifications |
19
+ | `decidim_comments` | Comments created |
20
+ | `decidim_comment_votes` | Comment upvotes and downvotes |
21
+ | `decidim_proposals` | Proposals published |
22
+ | `decidim_proposal_votes` | Proposal votes |
23
+ | `rack_attack_matches` | Rack::Attack throttle, blocklist, and track events |
24
+
25
+ ### Tags
26
+
27
+ | Tag | Example | Meaning |
28
+ |-----|---------|---------|
29
+ | `decidim_tenant` | `participate.example.org` | Organization host |
30
+ | `type` | `upvote`, `post_comments_allow2ban` | Event or rule name |
31
+ | `time_bucket` | Unix timestamp | Bucket start (see `DECIDIM_TELEMETRY_EXPORT_INTERVAL`) |
32
+
33
+ ### Example PromQL
34
+
35
+ ```promql
36
+ # Comments per tenant in the last hour
37
+ sum by (decidim_tenant) (increase(decidim_comments_total[1h]))
38
+
39
+ # Rack::Attack blocks
40
+ sum by (type) (increase(rack_attack_matches_total[5m]))
41
+ ```
42
+
43
+ Exact metric names in Prometheus include the `_total` suffix for counters.
44
+
45
+ ## Supported processes
46
+
47
+ | Process | Metrics source |
48
+ |---------|----------------|
49
+ | Puma (master + workers) | `yabeda-puma-plugin` on port 9394 |
50
+ | ActiveJob | `yabeda-activejob` |
51
+ | GoodJob | ActiveJob adapter (same job metrics) |
52
+
53
+ ## See also
54
+
55
+ - [Prometheus](./prometheus.md)
56
+ - [Configuration](./configuration.md)
57
+ - [FAQ](./faq.md)
@@ -0,0 +1,80 @@
1
+ ---
2
+ sidebar_position: 4
3
+ title: OpenTelemetry
4
+ description: Traces, OTLP logs, and exception reporting
5
+ ---
6
+
7
+ # OpenTelemetry
8
+
9
+ **decidim-telemetry** can export **traces**, **logs** (WARN and above), and **exception reports** via OpenTelemetry Protocol (OTLP) to your collector.
10
+
11
+ **Persona:** Decidim operators and integrators configuring observability.
12
+
13
+ **Prerequisite:** [Install](./install.md) and [Configuration](./configuration.md).
14
+
15
+ ## Overview
16
+
17
+ When `config.open_telemetry.enabled` is `true` (default):
18
+
19
+ | Flag | Default | Behavior |
20
+ |------|---------|----------|
21
+ | `traces_enabled` | `true` | OTLP span export + instrumentations |
22
+ | `logs_enabled` | `true` | OTLP log export; extends `Rails.logger` (WARN+) |
23
+ | `exceptions_enabled` | `true` | Subscribes to `Rails.error` and records exceptions on spans |
24
+
25
+ Set `enabled = false` to disable the whole OpenTelemetry module.
26
+
27
+ ## Infrastructure
28
+
29
+ You need an **OTLP collector** (or backend that accepts OTLP HTTP) reachable from the Rails process. Example env:
30
+
31
+ ```bash
32
+ OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
33
+ OTEL_SERVICE_NAME=decidim-production
34
+ ```
35
+
36
+ ### Local development (Docker)
37
+
38
+ Dev Compose ships [otel-desktop-viewer](https://github.com/CtrlSpice/otel-desktop-viewer#via-docker). After `docker compose up -d`, open **http://localhost:8000** for traces, logs, and metrics. The `telemetry` service already sets `OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-desktop-viewer:4318`. Exception reports show up as spans (and related log lines under **Logs**). See [Contribute](./developer/contribute.md#local-opentelemetry-viewer).
39
+
40
+ Service name resolution is **only** `OTEL_SERVICE_NAME`, falling back to `rails-app`. Extra resource attributes use the standard `OTEL_RESOURCE_ATTRIBUTES` env var.
41
+
42
+ ## Decidim context on spans
43
+
44
+ Middleware and error reporting attach attributes when available:
45
+
46
+ - `enduser.id` / `enduser.nickname`
47
+ - `decidim.organization.id` / `decidim.organization.slug`
48
+ - `decidim.participatory_space.*`
49
+ - `decidim.component.*`
50
+
51
+ ## Initializer example
52
+
53
+ ```ruby
54
+ # config/initializers/decidim_telemetry.rb
55
+ Decidim::Telemetry.configure do |config|
56
+ config.open_telemetry.enabled = Rails.env.production?
57
+ config.open_telemetry.traces_enabled = true
58
+ config.open_telemetry.logs_enabled = true
59
+ config.open_telemetry.exceptions_enabled = true
60
+ config.open_telemetry.traces_endpoint = ENV["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"]
61
+ config.open_telemetry.logs_endpoint = ENV["OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"]
62
+ config.open_telemetry.service_name = ENV.fetch("OTEL_SERVICE_NAME", "rails-app")
63
+ config.open_telemetry.exporter_timeout = 5
64
+ config.open_telemetry.debug = false
65
+ end
66
+ ```
67
+
68
+ OpenTelemetry boots **after** Rails config initializers, so this block can override defaults before the SDK starts.
69
+
70
+ ## Debug rake tasks
71
+
72
+ ```bash
73
+ bundle exec rake decidim:telemetry:opentelemetry:config
74
+ bundle exec rake decidim:telemetry:opentelemetry:test
75
+ ```
76
+
77
+ ## See also
78
+
79
+ - [Configuration](./configuration.md)
80
+ - [FAQ](./faq.md)
@@ -0,0 +1,69 @@
1
+ ---
2
+ sidebar_position: 5
3
+ title: Prometheus
4
+ description: Scrape configuration for Decidim metrics
5
+ ---
6
+
7
+ # Prometheus
8
+
9
+ Configure Prometheus (or any OpenMetrics-compatible scraper) to pull `/metrics` from your Decidim host.
10
+
11
+ **Prerequisite:** [Install](./install.md) and [Configuration](./configuration.md).
12
+
13
+ ## Scrape Rails port (default)
14
+
15
+ When `DECIDIM_TELEMETRY_MOUNT_EXPORTER=true` (default):
16
+
17
+ ```yaml
18
+ # prometheus.yml
19
+ scrape_configs:
20
+ - job_name: decidim
21
+ metrics_path: /metrics
22
+ scheme: http
23
+ static_configs:
24
+ - targets: ['decidim-web:3000']
25
+ ```
26
+
27
+ Replace `decidim-web:3000` with your service hostname and port.
28
+
29
+ ## Scrape Puma port
30
+
31
+ When `DECIDIM_TELEMETRY_MOUNT_EXPORTER=false`:
32
+
33
+ ```yaml
34
+ scrape_configs:
35
+ - job_name: decidim-puma
36
+ metrics_path: /metrics
37
+ scheme: http
38
+ static_configs:
39
+ - targets: ['decidim-web:9394']
40
+ ```
41
+
42
+ Expose port `9394` in your container or process supervisor if Prometheus runs outside the host network.
43
+
44
+ ## Basic auth
45
+
46
+ When credentials are set, add them to the scrape job:
47
+
48
+ ```yaml
49
+ scrape_configs:
50
+ - job_name: decidim
51
+ metrics_path: /metrics
52
+ basic_auth:
53
+ username: metrics
54
+ password_file: /etc/prometheus/secrets/decidim_metrics
55
+ static_configs:
56
+ - targets: ['decidim-web:3000']
57
+ ```
58
+
59
+ Auth applies to `/metrics` only. Health probes stay open.
60
+
61
+ ## What you will see
62
+
63
+ Besides custom Decidim counters (see [Metrics](./metrics.md)), Yabeda exports standard Rails, Puma, and ActiveJob metrics (`ruby_*`, `puma_*`, `activejob_*`, etc.).
64
+
65
+ ## See also
66
+
67
+ - [Endpoints](./endpoints.md)
68
+ - [Metrics reference](./metrics.md)
69
+ - [Security](./security.md)
@@ -0,0 +1,50 @@
1
+ ---
2
+ sidebar_position: 7
3
+ title: Security
4
+ description: Basic auth and network exposure for metrics
5
+ ---
6
+
7
+ # Security
8
+
9
+ How authentication and exposure work for observability endpoints.
10
+
11
+ **Prerequisite:** [Configuration](./configuration.md).
12
+
13
+ ## Basic authentication
14
+
15
+ Set both variables to protect `/metrics`:
16
+
17
+ ```bash
18
+ DECIDIM_TELEMETRY_USER=metrics
19
+ DECIDIM_TELEMETRY_PASSWORD=<secret>
20
+ ```
21
+
22
+ - Auth applies **only** to `GET /metrics`
23
+ - `/health`, `/health/live`, and `/health/ready` stay **unauthenticated** so load balancers and Kubernetes can probe without credentials
24
+ - Participant and admin traffic is **not** affected
25
+
26
+ Configure Prometheus with `basic_auth` — see [Prometheus](./prometheus.md).
27
+
28
+ ## Disable metrics export
29
+
30
+ ```bash
31
+ DECIDIM_TELEMETRY_ENABLED=false
32
+ ```
33
+
34
+ Stops `/metrics` on the Rails port and disables the auth middleware. Health endpoints remain available.
35
+
36
+ ## Network exposure
37
+
38
+ | Endpoint | Typical exposure |
39
+ |----------|------------------|
40
+ | `/health/*` | Load balancer, orchestrator (internal) |
41
+ | `/metrics` | Prometheus scraper (internal network or VPN) |
42
+ | Puma `:9394` | Internal only when using separate exporter port |
43
+
44
+ Restrict scrape targets with firewall rules or Kubernetes `NetworkPolicy` so `/metrics` is not reachable from the public internet.
45
+
46
+ ## See also
47
+
48
+ - [Endpoints](./endpoints.md)
49
+ - [Prometheus](./prometheus.md)
50
+ - [FAQ](./faq.md)
@@ -0,0 +1,88 @@
1
+ import {themes as prismThemes} from 'prism-react-renderer';
2
+ import type {Config} from '@docusaurus/types';
3
+ import type * as Preset from '@docusaurus/preset-classic';
4
+
5
+ const config: Config = {
6
+ title: 'Decidim Telemetry',
7
+ tagline: 'Prometheus metrics and health probes for Decidim',
8
+ favicon: 'img/logo.svg',
9
+
10
+ url: 'https://octree.ch',
11
+ baseUrl: '/decidim-telemetry/',
12
+ trailingSlash: false,
13
+
14
+ organizationName: 'octree-gva',
15
+ projectName: 'decidim-telemetry',
16
+
17
+ onBrokenLinks: 'throw',
18
+ onBrokenMarkdownLinks: 'warn',
19
+
20
+ i18n: {
21
+ defaultLocale: 'en',
22
+ locales: ['en'],
23
+ },
24
+
25
+ presets: [
26
+ [
27
+ 'classic',
28
+ {
29
+ docs: {
30
+ sidebarPath: './sidebars.ts',
31
+ routeBasePath: '/',
32
+ },
33
+ theme: {
34
+ customCss: './src/css/custom.css',
35
+ },
36
+ } satisfies Preset.Options,
37
+ ],
38
+ ],
39
+
40
+ themeConfig: {
41
+ navbar: {
42
+ title: 'Decidim Telemetry',
43
+ items: [
44
+ {
45
+ type: 'docSidebar',
46
+ sidebarId: 'tutorialSidebar',
47
+ position: 'left',
48
+ label: 'Documentation',
49
+ },
50
+ {
51
+ href: 'https://git.octree.ch/decidim/vocacity/decidim-modules/decidim-telemetry',
52
+ label: 'GitLab',
53
+ position: 'right',
54
+ },
55
+ ],
56
+ },
57
+ footer: {
58
+ style: 'dark',
59
+ links: [
60
+ {
61
+ title: 'Docs',
62
+ items: [
63
+ {label: 'Overview', to: '/'},
64
+ {label: 'Install', to: '/install'},
65
+ {label: 'Prometheus', to: '/prometheus'},
66
+ {label: 'Contribute', to: '/contributing'},
67
+ ],
68
+ },
69
+ {
70
+ title: 'More',
71
+ items: [
72
+ {
73
+ label: 'GitLab',
74
+ href: 'https://git.octree.ch/decidim/vocacity/decidim-modules/decidim-telemetry',
75
+ },
76
+ ],
77
+ },
78
+ ],
79
+ copyright: 'Built with Docusaurus. Powered by <a href="https://voca.city">Voca</a>.',
80
+ },
81
+ prism: {
82
+ theme: prismThemes.github,
83
+ darkTheme: prismThemes.dracula,
84
+ },
85
+ } satisfies Preset.ThemeConfig,
86
+ };
87
+
88
+ export default config;
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "decidim-telemetry-website",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "docusaurus": "docusaurus",
7
+ "start": "docusaurus start",
8
+ "build": "docusaurus build",
9
+ "clear": "docusaurus clear",
10
+ "serve": "docusaurus serve",
11
+ "typecheck": "tsc"
12
+ },
13
+ "dependencies": {
14
+ "@docusaurus/core": "3.5.2",
15
+ "@docusaurus/preset-classic": "3.5.2",
16
+ "@mdx-js/react": "^3.0.0",
17
+ "clsx": "^2.0.0",
18
+ "prism-react-renderer": "^2.3.0",
19
+ "react": "^18.0.0",
20
+ "react-dom": "^18.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@docusaurus/module-type-aliases": "3.5.2",
24
+ "@docusaurus/tsconfig": "3.5.2",
25
+ "@docusaurus/types": "3.5.2",
26
+ "typescript": "~5.5.2"
27
+ },
28
+ "engines": {
29
+ "node": ">=18.0"
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
2
+
3
+ const sidebars: SidebarsConfig = {
4
+ tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
5
+ };
6
+
7
+ export default sidebars;