首页 > 解决方案 > data modelling in influxdb

问题描述

I would like to take your suggestion on data modelling in influxdb. I have vehicles which are producing a lot of values like soc, odometer, lat, lon etc. I have 2 options that I see as modeling this data in influx

1) Create a single measurement as 'x' with tag as vehicle_id and various fields for this measurement like soc, odometer, lat, lon

2) Create multiple measurement as soc, odometer, lat, lon ... each as a tab vehicle_id

Which one would you prefer and why. I am using first one which seems to be a more natural approach.

标签: data-modelinginfluxdb

解决方案


根据他们的官方文档,测量在概念上是一个表格。字段更像是单一度量下的属性。因为 influxdb 是一个列式数据库,所以记录/点以系列结构组织,其中每个系列都属于一组 db、一个测量值和一个或多个字段,其中一个或多个字段作为标识符。

要回答您的问题,如果您想join查询多个功能,您应该将它们作为一个或多个字段放在一个单独的度量下;如果它们没有任何互连,那么将它们作为单独的测量值将更易于人类阅读。

此外,理论上,您实际上可以将所有内容放在一个包含数百个字段的单个测量中,并仅使用相关字段进行查询。但这会产生高基数,这会给读/写过程带来压力。您需要通过 influxdb 配置上的批处理和缓存来处理高基数。因此,使用尽可能少的字段会提高读写效率。


推荐阅读