【问题标题】:Grafana/Influx Db Authentication to data source failedGrafana/Influx Db 对数据源的身份验证失败
【发布时间】:2021-07-30 11:43:08
【问题描述】:

我正在尝试集成 grafana 和 influxdb 以获得一些指标。但不确定当我尝试对其进行测试时,对数据源的身份验证失败。请帮我解决这个问题。

这是下面的 yaml 和 conf 文件。

Docker 编写文件

version: "3"
services:
  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    ports:
      - 3000:3000
    networks:
      - monitoring
    volumes:
      - grafana-volume:/vol01/Docker/monitoring
    environment:
      - GF_LOG_LEVEL=debug
      - GF_DATAPROXY_LOGGING=true
      - GF_DATAPROXY_TIMEOUT=60

  influxdb:
    image: influxdb
    container_name: influxdb
    restart: always
    ports:
      - 8086:8086
    networks:
      - monitoring
    volumes:
      - influxdb-volume:/vol01/Docker/monitoring
    environment:
      - INFLUXDB_DB=telegraf
      - INFLUXDB_USER=telegraf
      - INFLUXDB_ADMIN_ENABLED=true
      - INFLUXDB_HTTP_AUTH_ENABLED=false
      - INFLUXDB_ADMIN_USER=admin
      - INFLUXDB_ADMIN_PASSWORD=Welcome1
      - GF_LOG_LEVEL=debug
      - GF_DATAPROXY_LOGGING=true

  telegraf:
    image: telegraf
    container_name: telegraf
    restart: always
    extra_hosts:
     - "influxdb:18.216.224.127"
    environment:
      ST_PROC: /rootfs/proc
      HOST_SYS: /rootfs/sys
      HOST_ETC: /rootfs/etc


    volumes:
     - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
     - /var/run/docker.sock:/var/run/docker.sock:ro
     - /sys:/rootfs/sys:ro
     - /proc:/rootfs/proc:ro
     - /etc:/rootfs/etc:ro
networks:
  monitoring:
volumes:
  grafana-volume:

配置文件

[global_tags]

[agent]
  interval = "60s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  hostname = "18.216.224.127"
  omit_hostname = false

[[outputs.influxdb]]
urls = ["http://18.216.224.127:8086"]
database = "telegraf"
timeout = "5s"
username = "telegraf"
password = "Welcome1"


[[inputs.ping]]
interval = "5s"
urls = ["192.168.0.44", "192.168.0.131", "192.168.0.130", "google.com", "amazon.com", "github.com"]
count = 4
ping_interval = 1.0
timeout = 2.0


[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false


[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]

[[inputs.diskio]]

[[inputs.kernel]]

[[inputs.mem]]

[[inputs.processes]]

[[inputs.swap]]

[[inputs.system]]
                                                                                                                                                                                             

错误

t=2021-05-08T11:02:29+0000 lvl=info msg="对数据源的身份验证失败" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources /proxy/1/query remote_addr=108.237.178.97 referer=http://18.216.224.127:3000/datasources/edit/1/body="{"code":"unauthorized","message":"Unauthorized"}"状态码=401 t=2

【问题讨论】:

  • 你发现了吗?我也有类似的问题。

标签: grafana influxdb


【解决方案1】:

在使用 InfluxQL 语言时遇到了同样的问题。使用 Flux 解决了这个问题。由于最新的 influxdb 映像 - 2.x,使用一组略有不同的 envvar,您必须更改它们。根据https://github.com/docker-library/docs/blob/master/influxdb/README.md#automated-setup,您需要将现有的envvars更改为:

  • DOCKER_INFLUXDB_INIT_USERNAME
  • DOCKER_INFLUXDB_INIT_PASSWORD
  • DOCKER_INFLUXDB_INIT_ORG

而且要使用 Flux,您还必须添加 DOCKER_INFLUXDB_INIT_ADMIN_TOKEN 环境变量。以下是“influxdb”服务的 docker-compose 部分示例:

environment:
  - INFLUXDB_DB=telegraf
  - DOCKER_INFLUXDB_INIT_MODE=setup
  - DOCKER_INFLUXDB_INIT_USERNAME=admin
  - DOCKER_INFLUXDB_INIT_PASSWORD=Welcome1
  - DOCKER_INFLUXDB_INIT_ORG=telegraf_org
  - DOCKER_INFLUXDB_INIT_BUCKET=telegraf_bucket
  - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=admin_token

在 Grafana 用户界面中:

  • 将 InfluxQL 更改为 Flux
  • 将 *_ORG、*_BUCKET 和 *_ADMIN_TOKEN envvars 值放入“InfluxDB 详细信息”部分的相应输入中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-15
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    • 2018-12-04
    相关资源
    最近更新 更多