【问题标题】:InfluxDB invalid field format error while using curl command使用 curl 命令时出现 InfluxDB 无效字段格式错误
【发布时间】:2020-09-02 07:55:56
【问题描述】:

我是 Influx DB 的新手

我必须使用 curl 命令将以下数据插入到我的本地涌入数据库中

test_aggregate,processor=name,env=test_env,workspace=test_job_name,area=test_area,test-suite=test_name,build-id=test_build_no,test-name=test_uc_no,step-index=1,step-execution-time=1,step-error-message=No message,test-result=1 1572915987025

我正在使用以下 curl 命令

curl -i -X POST "http://localhost:8086/write?db=test_db_local&precision=s" --header "Authorization: Token maha:jhdasdaak" --data-binary 'test_aggregate,processor=name,env=test_env,workspace=test_job_name,area=test_area,test-suite=test_name,build-id=test_build_no,test-name=test_uc_no,step-index=1,step-execution-time=1,step-error-message=No message,test-result=1 1572915987025'

但是当我执行上面的 curl 命令时,我得到以下错误

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: f9084cf7-ecf0-11ea-811c-000d3ab37764
X-Influxdb-Build: OSS
X-Influxdb-Error: unable to parse 'test_aggregate,processor=name,env=test_env,workspace=test_job_name,area=test_area,test-suite=test_name,build-id=test_build_no,test-name=test_uc_no,step-index=1,step-execution-time=1,step-error-message=No message,test-result=1 1572915987025': invalid field format
X-Influxdb-Version: 1.8.2
X-Request-Id: f9084cf7-ecf0-11ea-811c-000d3ab37764
Date: Wed, 02 Sep 2020 07:50:30 GMT
Content-Length: 315

我的语法哪里出错了?

提前致谢!

【问题讨论】:

    标签: curl influxdb


    【解决方案1】:

    是的,数据格式错误,

    数据应该是行格式, measure1,tag1=value1,tag2=value2 field1=value1, field2=value2 时间戳

    说明: measure_name 后跟逗号和标签列表(逗号分隔),然后是 空格,后跟字段(逗号分隔),然后是 空格,后跟正确精度的时间戳

    注意:空格充当标签、字段和时间戳之间的分隔符

    你的情况有几个错误,

    1. 您已将时间精度设置为 s(秒),但时间戳有 13 位,应该只有 10 位
    2. 应该至少存在一个字段,但您的数据没有字段
    3. step-error-message=没有消息 => 空格应该用反斜杠转义 (No\ Message)

    正确的 curl 命令如下所示

    curl -i -X POST "http://localhost:8086/write?db=test_db_local&precision=s" --header "Authorization: Token maha:jhda  sdaak" --data-binary 'test_aggregate,processor=name,env=test_env,workspace=test_job_name,area=test_area,test-suite=test_name,build-id=test_build_no,test-name=test_uc_no,step-index=1,step-execution-time=1,step-error-message=No\ message,test-result=1 field1=0 1572915987'
    

    例如,我给出了一个名为 field1 的虚拟字段,其值为 0,如果需要,您可以将一些标签移动到字段中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多