# 如何配置 Prometheus 对 discourse-prometheus 的监控

**URL:** <https://meta.discourse.org/t/how-to-configure-monitoring-of-discourse-prometheus-on-prometheus/221218>\
**Category:** Extras\
**Created:** [2022年三月17日 11:11 UTC](https://meta.discourse.org/t/how-to-configure-monitoring-of-discourse-prometheus-on-prometheus/221218 "2022-03-17T11:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingsd041](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kingsd041/32/253349_2.png) [@kingsd041](https://meta.discourse.org/u/kingsd041)\
**Post date:** [2022年三月17日 11:11 UTC](https://meta.discourse.org/t/how-to-configure-monitoring-of-discourse-prometheus-on-prometheus/221218/1 "2022-03-17T11:11:47Z")

</div>

我已安装 discourse 和 discourse-prometheus 插件，然后在 prometheus.yaml 中添加了以下配置：

```plaintext
- job_name: forums
  metrics_path: /metrics
  static_configs:
    - targets:
      - forums.kingsd.top
  scheme: https
  basic_auth:
    username: admin
    password: password

```

然后我发现 Prometheus 上相应 Endpoint 的状态一直是 `DOWN`，并出现了错误日志 `server returned HTTP status 404 Not Found`。

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/f/af3cbe94dcc5405f62d0c6b1dd646f130831f80a.png)

shared/standalone/log/rails/production.log 中不断出现以下错误日志：

```plaintext
Started GET "/metrics" for 123.184.31.122 at 2022-03-17 11:03:34 +0000
ActionController::RoutingError (No route matches [GET] "/metrics")
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:202:in `call'
  Rendered exceptions/not_found.html.erb within layouts/no_ember (Duration: 0.3ms | Allocations: 193)
  Rendered layout layouts/no_ember.html.erb (Duration: 4.1ms | Allocations: 2216)
  Rendered html template (Duration: 0.0ms | Allocations: 2)

```

我的配置有什么问题吗？请帮帮我。

---

<div class="post-metadata">

**Author:** ![kingsd041](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kingsd041/32/253349_2.png) [@kingsd041](https://meta.discourse.org/u/kingsd041)\
**Post date:** [2022年三月17日 12:06 UTC](https://meta.discourse.org/t/how-to-configure-monitoring-of-discourse-prometheus-on-prometheus/221218/2 "2022-03-17T12:06:14Z")

</div>

抱歉，我忘记配置 `DISCOURSE_PROMETHEUS_TRUSTED_IP_ALLOWLIST_REGEX`
