The Discourse Prometheus plugin is an official exporter that collects key metrics from Discourse and exposes them at the /metrics endpoint for consumption by Prometheus. As detailed in the introduction, the plugin aggregates data from all forked unicorn processes into a single endpoint. It tracks various metrics including median and 99th percentile response times for pages, execution time breakdowns (SQL/Redis/App), page views, error tracking, Ruby object space statistics, V8 memory stats, and Sidekiq job durations. A sample Grafana dashboard is available on Grafana.com.
Access control is managed via the prometheus_trusted_ip_allowlist_regex global setting (or DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX environment variable). pfaffman clarified that this setting must be configured in app.yml, addressing confusion from inlann. This allows users to define trusted IP addresses for the metrics endpoint, which is particularly useful for dynamic IPs.
Several users raised specific questions and issues:
Mudit_Maheshwari asked if metrics aggregate across multiple Kubernetes pods and questioned why only specific controller action timings are observed. (Note: The original post suggests it aggregates per instance, but cross-pod aggregation typically requires service discovery in Prometheus).
DevTeVe reported integration failures with Grafana, showing errors in /metrics/api/v1/query_range requests. They later found a solution in a separate thread regarding 404 errors.
lavamind asked if the plugin exports a metric for available Discourse upgrades. NateDhaliwal confirmed this is handled by the Docker Manager plugin, not Prometheus. Nate subsequently shared a workflow using the workflows plugin to notify users of updates.
Scheduled Job Queue and Sidekiq job durations and executions.
To see a full list of metrics available, install the plugin and visit SITENAME/metrics as an admin.
Out of the box we allow the metrics route to admins and private ips.
Discourse Prometheus is smart enough to aggregate data for all forked unicorn processes and present it as cohesive metrics on a single endpoint. We use it internally to keep track of our sites.
Sample dashboard at:
Discourse global setting called prometheus_trusted_ip_allowlist_regex (env: DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX) is allowing to set Prometheus’s trusted IP addresses. The setting accepts regular expression to set advanced IP ranges. This is useful in a case when Prometheus IP address is dynamic.
I’m currently managing discourse on Kubernetes, running on multiple app and sidekiq pods. I have a couple of questions regarding the plugin:
Does the plugin aggregate metrics from all the app pods? I’m assuming it does aggregate metrics for unicorn processes running on a single instance/pod.
Not sure what’s happening but this integration is not working anymore. I couldn’t get the dashboard in grafana to display anything… the /metrics does return something but anything beyond that does not really work
Many errors like the one below
Started GET "/metrics/api/v1/label/instance/values?limit=40000&start=1760980620&end=1760982480&match%5B%5D=discourse_page_views" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started GET "/metrics/api/v1/label/job/values?limit=40000&start=1760980620&end=1760982480&match%5B%5D=discourse_page_views%7B%7D" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Rendered layout layouts/no_ember.html.erb (Duration: 21.1ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 26.0ms | GC: 0.0ms)
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Rendered layout layouts/no_ember.html.erb (Duration: 19.8ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 28.2ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 34.6ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 44.4ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 41.7ms | GC: 0.0ms)
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:07 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:08 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:08 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:08 +0000
Rendered layout layouts/no_ember.html.erb (Duration: 23.6ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 24.9ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 19.9ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 21.6ms | GC: 0.0ms)
Started GET "/metrics/api/v1/label/job/values?limit=40000&start=1760980620&end=1760982480&match%5B%5D=discourse_page_views%7B%7D" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Started GET "/metrics/api/v1/label/instance/values?limit=40000&start=1760980620&end=1760982480&match%5B%5D=discourse_page_views" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Rendered layout layouts/no_ember.html.erb (Duration: 19.5ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 20.9ms | GC: 0.0ms)
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Started POST "/metrics/api/v1/query_range" for 16.63.57.20 at 2025-10-20 17:47:37 +0000
Rendered layout layouts/no_ember.html.erb (Duration: 22.4ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 22.0ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 40.0ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 37.0ms | GC: 0.0ms)
Rendered layout layouts/no_ember.html.erb (Duration: 24.8ms | GC: 1.6ms)