influxdb的记录是以行协议存储的,行协议中包含measurement、tag set、field set和timestamp。
拿到measurement的数据以后,如何知道哪些是tag字段,哪些是field字段呢?
以下面的时序数据为例:
> select * from cpu_used_percent order by time limit 3
name: cpu_used_percent
time dstype endpoint step value
---- ------ -------- ---- -----
2021-07-13T08:42:00Z GAUGE dfe16db6-719f-4394-ad08-1bafd072576b 60 8.529119896523099
2021-07-13T08:42:00Z GAUGE dfe16db6-719f-4394-ad08-1bafd072576b 60 7.076256223852596
2021-07-13T08:42:00Z GAUGE dfe16db6-719f-4394-ad08-1bafd072576b 60 7.157941185740853
查询tag字段:
> show tag keys from cpu_used_percent;
name: cpu_used_percent
tagKey
------
dstype
endpoint
step
可以看到dsType/endpoint/step是tag字段,tag的value是string。
查询field字段:
> show field keys from cpu_used_percent;
name: cpu_used_percent
fieldKey fieldType
-------- ---------
value float
可以看到value是field字段,由于value可以是float/int/string/bool等类型,这里的value是float。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。