influx write dryrun
influx write dryrun
命令将写入输出打印到标准输出,而不是写入到 InfluxDB。使用此命令测试写入数据。
支持 Line Protocol、带注释的 CSV 和 扩展的带注释的 CSV。输出始终为 Line Protocol。
用法
influx write dryrun [flags]
标志
标志 | 描述 | 输入类型 | 映射到 ? | |
---|---|---|---|---|
-c | --active-config | 用于命令的 CLI 配置 | string | |
-b | --bucket | 存储桶名称(与 --bucket-id 互斥) | string | INFLUX_BUCKET_NAME |
--bucket-id | 存储桶 ID(与 --bucket 互斥) | string | INFLUX_BUCKET_ID | |
--configs-path | influx CLI 配置的路径(默认为 ~/.influxdbv2/configs ) | string | INFLUX_CONFIGS_PATH | |
--debug | 将错误输出到标准错误输出 | |||
--encoding | 输入的字符编码(默认为 UTF-8 ) | string | ||
--errors-file | 用于记录拒绝的行错误的文件路径 | string | ||
-f | --file | 要导入的文件 | stringArray | |
--format | 输入格式 (lp 或 csv ,默认为 lp ) | string | ||
--header | 将标头行添加到 CSV 输入数据 | string | ||
-h | --help | dryrun 命令的帮助 | ||
--host | InfluxDB 的 HTTP 地址(默认为 http://localhost:9999 ) | string | INFLUX_HOST | |
--max-line-length | 单行可以读取的最大字节数(默认为 16000000 ) | integer | ||
-o | --org | 组织名称(与 --org-id 互斥) | string | INFLUX_ORG |
--org-id | 组织 ID(与 --org 互斥) | string | INFLUX_ORG_ID | |
-p | --precision | 时间戳的精度(默认为 ns ) | string | INFLUX_PRECISION |
--rate-limit | 限制写入速率(示例:5MB/5min 或 1MB/s )。 | string | ||
--skip-verify | 跳过 TLS 证书验证 | INFLUX_SKIP_VERIFY | ||
--skipHeader | 跳过输入数据的前 n 行 | integer | ||
--skipRowOnError | 将 CSV 错误输出到标准错误输出,但继续处理 | |||
-t | --token | API 令牌 | string | INFLUX_TOKEN |
-u | --url | 从中导入数据的 URL | stringArray |
示例
身份验证凭据
以下示例假定您的 InfluxDB 主机、组织和 令牌 由 活动的 influx
CLI 配置 或环境变量(INFLUX_HOST
、INFLUX_ORG
和 INFLUX_TOKEN
)提供。如果您没有设置 CLI 配置或环境变量,请为每个命令包含以下必需的凭据标志
--host
: InfluxDB 主机-o, --org
或--org-id
: InfluxDB 组织名称或 ID-t, --token
: InfluxDB API 令牌
Line Protocol
Dry run 通过标准输入写入 Line Protocol
influx write --bucket example-bucket "
m,host=host1 field1=1.2
m,host=host2 field1=2.4
m,host=host1 field2=5i
m,host=host2 field2=3i
"
Dry run 从文件写入 Line Protocol
influx write dryrun \
--bucket example-bucket \
--file path/to/line-protocol.txt
Dry run 从多个文件写入 Line Protocol
influx write dryrun \
--bucket example-bucket \
--file path/to/line-protocol-1.txt \
--file path/to/line-protocol-2.txt
Dry run 从 URL 写入 Line Protocol
influx write dryrun \
--bucket example-bucket \
--url https://example.com/line-protocol.txt
Dry run 从多个 URL 写入 Line Protocol
influx write dryrun \
--bucket example-bucket \
--url https://example.com/line-protocol-1.txt \
--url https://example.com/line-protocol-2.txt
Dry run 从多个源写入 Line Protocol
influx write dryrun \
--bucket example-bucket \
--file path/to/line-protocol-1.txt \
--url https://example.com/line-protocol-2.txt
CSV
Dry run 通过标准输入写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--format csv \
"#datatype measurement,tag,tag,field,field,ignored,time
m,cpu,host,time_steal,usage_user,nothing,time
cpu,cpu1,host1,0,2.7,a,1482669077000000000
cpu,cpu1,host2,0,2.2,b,1482669087000000000
"
Dry run 从文件写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--file path/to/data.csv
Dry run 从多个文件写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--file path/to/data-1.csv \
--file path/to/data-2.csv
Dry run 从 URL 写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--url https://example.com/data.csv
Dry run 从多个 URL 写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--url https://example.com/data-1.csv \
--url https://example.com/data-2.csv
Dry run 从多个源写入带注释的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--file path/to/data-1.csv \
--url https://example.com/data-2.csv
Dry run 预先添加带有注释标头的 CSV 数据
influx write dryrun \
--bucket example-bucket \
--header "#constant measurement,birds" \
--header "#datatype dataTime:2006-01-02,long,tag" \
--file path/to/data.csv
此页面是否对您有帮助?
感谢您的反馈!