Prometheus error " server returned HTTP status 401 Unauthorized" for remote_write and remote_read

Viewed 2678

I have installed Prometheus in Kubernetes and I am trying to use remote_write and remote_read option to InfluxDB. I have created a user in DB with read and write privilege also. But I am receiving an error like this

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\"}"

and my configuration for prometheus is

 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 Answers

You could define your secret as volume:

 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"
Related