3 InfluxDB 基础使用
douxu edited this page 2024-08-15 15:19:42 +08:00

InfluxDB UI Dashboard使用

InfluxDB 启动

使用 docker start -d --name influxdb -p 27017:27017 influxdb:2.7.8启动InfluxDB 容器

Influxdb UI

使用 variables 配置 Dashboard

创建 Dashboard query statment

from(bucket: v.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == v.measurement)

创建 bucket variables

buckets() |> filter(fn: (r) => r.name !~ /^_/) |> rename(columns: {name: "_value"}) |> keep(columns: ["_value"])

创建 measurement variables

import "influxdata/influxdb/schema" schema.measurements(bucket: v.bucket)

InfluxDB 认证

使用influx auth create [permission-flags]命令创建令牌。

创建令牌

  1. influx auth create --all-access创建 All-access令牌
  2. influx auth create --read-bucket bucketID --write-bucket bucketID 创建指定桶 ID 的读写权限令牌

查看令牌

使用influx auth list 命令来查看相关令牌详情

激活令牌

使用influx auth active --ID xxxxxxxxxxxxxxxx 激活令牌

删除令牌

使用influx auth inactive --ID xxxxxxxxxxxxxxxx 停用令牌

401 Unauthorized认证解决方案

使用influx config create --config-name CONFIG_NAME --host_url HOST_URL --org ORG --token API_TOKEN --active创建认证配置