Insert line in InfluxDB using CURL

前端 未结 2 1193
臣服心动
臣服心动 2021-01-06 19:24

I have the following POST request which is done from C#:

POST http://192.168.123.27:8086/write?db=HWDB HTTP/1.1
Content-Type: text/plain; charset=utf-8
Host:         


        
相关标签:
2条回答
  • 2021-01-06 19:57

    Regarding the data.txt file, Windows is the key factor here. It is almost certainly introducing a CRLF rather than just a linefeed at the end of the lines. See the InfluxDB docs for more.

    As for the direct example at the top of your post:

    curl -i -XPOST http://192.168.123.27:8086/write?db=HWDB --data-binary "HARDWARE,CPU="1" value=91, CPU="2" value=92 1422568543702900257"
    

    the content is not valid line protocol format and can never work. Each point must be on a new line, and values cannot be shared between points. Stripping out the curl syntax, this is the attempted write:

    HARDWARE,CPU="1" value=91, CPU="2" value=92 1422568543702900257
    

    And this is the actual valid syntax:

    HARDWARE,CPU="1" value=91 1422568543702900257
    HARDWARE,CPU="2" value=92 1422568543702900257
    
    0 讨论(0)
  • 2021-01-06 20:06

    https://docs.influxdata.com/influxdb/v1.6/write_protocols/line_protocol_reference/

    <measurement>[,<tag_key>=<tag_value>[,<tag_key>=<tag_value>]] <field_key>=<field_value>[,<field_key>=<field_value>] [<timestamp>]
    
    0 讨论(0)
提交回复
热议问题