Prometheus错误“ remote_write和remote_read的服务器返回HTTP状态401未经授权”

时间:2020-07-03 13:14:01

标签: kubernetes google-kubernetes-engine prometheus influxdb

我已经在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.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"

1 个答案:

答案 0 :(得分: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"