Prometheus 正在抛出 "bad response status 401 Unauthorized" - 即使在指定正确的配置后 "basic_auth_users"

Prometheus is throwing "bad response status 401 Unauthorized" - Even afer specificying right configs "basic_auth_users"

我已经配置了 user & prod ("basic_auth_users") 并传递了文档中提到的那些参数: --web.config.file

能够独立访问 Prometheus UI 和 Alert Manager UI(使用提供的凭据),但我在 Prometheus 日志中看到以下错误,因此警报不会发出。

level=error ts=2021-08-16T07:00:53.337Z caller=notifier.go:527 component=notifier alertmanager=http://pronode1:9093/api/v1/alerts count=1 msg="Error sending alert" err="bad response status 401 Unauthorized"

理想情况下 alertmanager=http://pronode1:9093/api/v1/alerts 需要用户名和密码才能获得结果,但为什么它不能从我提供的 --web.config.file 文件中获取。

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - pronode1:9093

我是否缺少任何其他配置?

请帮助我。

使用的版本:

 Prometheus: prometheus-2.25.2.linux-amd64 
 AlertManager: alertmanager-0.22.2.linux-amd64

您是否希望 Prometheus 获取用户名和密码以用于它从 web.config.file 向 Alertmanager 发出的请求?我不认为这是一个功能:当作为 HTTP 服务器 时使用该配置,而不是当作为 HTTP 客户端 时使用。它怎么知道选择哪个用户名?

(更不用说 web.config.file 中的密码是经过哈希处理的,因此即使在理论上也不可能使用它们来发出请求。)

<alertmanager_config> 部分有一个 basic_auth 块,您可以使用该块为传出请求配置用户名和密码。它看起来像:

alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - pronode1:9093
    basic_auth:
      username: foo
      password: bar

(如果您不想在同一配置文件中使用 password_file 而不是 password。)