【问题标题】:Prometheus error " server returned HTTP status 401 Unauthorized" for remote_write and remote_read远程写入和远程读取的 Prometheus 错误“服务器返回 HTTP 状态 401 未授权”
【发布时间】:2020-07-03 13:14:01
【问题描述】:

我已经在 Kubernetes 中安装了 Prometheus,我正在尝试对 InfluxDB 使用 remote_write 和 remote_read 选项。我也在数据库中创建了一个具有读写权限的用户。但我收到这样的错误

http://url:port/api/v1/prom/write?db=dbname&u=xxx&p=yyy msg=non-recoverable error" count=100 err="server returned HTTP status 401 Unauthorized: {\"error\":\"authorization failed\"}"

而我对prometheus的配置是

 prometheus.yml: |-
global:
  scrape_interval: 5s
  evaluation_interval: 5s
rule_files:
  - /etc/prometheus/prometheus.rules
remote_write:
  - url: "http://url:port/api/v1/prom/write?db=dbname&u=xxxx&p=yyy"
  
remote_read:
  - url: "http://url:port/api/v1/prom/read?db=dbname&u=xxx&p=yyy"

【问题讨论】:

  • 你在哪里为 prometheus 定义了你的自动化块?
  • 我已经定义了这个配置 config-map.yaml 并使用 kubectl apply -f config-map.yaml 应用。在 prometheus.yml: |- 我的 yaml 部分我已经定义了这个。当我在 InfluxDB 中禁用 Http auth-enabled 时,它正在工作,但在启用它时会抛出此错误。
  • 您必须在 prometheus 配置中使用该 secret/configMap。

标签: kubernetes google-kubernetes-engine prometheus influxdb


【解决方案1】:

您可以将您的秘密定义为卷:

 volumeMounts:
    - name: prometheus-secret
      readOnly: true
      mountPath: "/etc/prometheus-secret"

then use it in your prometheus yaml config as:

basic_auth:
   password_file: "/etc/prometheus-secret"

【讨论】:

    猜你喜欢
    • 2012-04-29
    • 1970-01-01
    • 2012-02-23
    • 2016-01-17
    • 2012-03-14
    • 2018-12-13
    • 1970-01-01
    • 2020-03-28
    相关资源
    最近更新 更多