无法通过Shell脚本将数据写入InfluxDB

时间:2016-06-29 16:04:27

标签: shell udp influxdb

在/etc/influxdb/influxdb.conf中配置UDP端口8089:

[[udp]]
 enabled = true
 bind-address = "0.0.0.0:8089"
 database = "testdb"
 retention-policy = ""

使用端口8089启动InfluxDB

[udp] 2016/06/29 23:17:59 Started listening on UDP: 0.0.0.0:8089

尝试在Shell脚本中编写度量标准数据:

 HOST_OR_IP_OF_INFLUXDB_SERVER=my_ip
 PORT=8089

 # Refer to line protocol:
 # https://docs.influxdata.com/influxdb/v0.9/write_protocols/line/
 echo "temperature,machine=unit42,type=assembly internal=32 1434055562000000035" | nc -v -u -w 1 $HOST_OR_IP_OF_INFLUXDB_SERVER $PORT

InfluxDB服务器显示错误消息:

[udp] 2016/06/29 23:52:18 Failed to parse points: unable to parse 'X': missing fields
[udp] 2016/06/29 23:52:18 Failed to parse points: unable to parse 'X': missing fields
[udp] 2016/06/29 23:52:18 Failed to parse points: unable to parse 'X': missing fields
[udp] 2016/06/29 23:52:18 Failed to parse points: unable to parse 'X': missing fields

似乎发送到服务器的数据满足InfluxDB的线路协议,任何人都可以提出任何问题的线索吗?感谢。

1 个答案:

答案 0 :(得分:0)

在Bash中,您可以跳过nc

echo -n "temperature,machine=unit42,type=assembly internal=32 1434055562000000035" \
> /dev/udp/$HOST_OR_IP_OF_INFLUXDB_SERVER/$PORT