Cassandra 带标记的时间序列数据建模
我目前正在开发一个poc来模拟时间序列数据 初始数据点结构: -传感器的名称:192.168.1.1:readCount -时间戳 -价值 我使用传感器名称作为rowid,时间戳作为列id。这种方法工作得非常好 但是,我想添加标签以添加其他数据Cassandra 带标记的时间序列数据建模,cassandra,time-series,Cassandra,Time Series,我目前正在开发一个poc来模拟时间序列数据 初始数据点结构: -传感器的名称:192.168.1.1:readCount -时间戳 -价值 我使用传感器名称作为rowid,时间戳作为列id。这种方法工作得非常好 但是,我想添加标签以添加其他数据 public class Datapoint { public String metricName; public long timestampMs; public long value; public Map<String
public class Datapoint {
public String metricName;
public long timestampMs;
public long value;
public Map<String, String> tags = new HashMap<String, String>();
}
Datapoint datapoint = new Datapoint();
datapoint.metricName = "IMap.readCount";
datapoint.value = 10;
datapoint.timestampMs = System.currentTimeMillis();
datapoint.tags.put("cluster", "dev");
datapoint.tags.put("member", "192.168.1.1:5701");
datapoint.tags.put("id", "map1");
datapoint.tags.put("company", "Foobar");
公共类数据点{
公共字符串metricName;
公共长时码;
公共长期价值;
publicmap标记=newhashmap();
}
数据点数据点=新数据点();
datapoint.metricName=“IMap.readCount”;
datapoint.value=10;
datapoint.timestampMs=System.currentTimeMillis();
datapoint.tags.put(“集群”、“开发”);
datapoint.tags.put(“成员”,“192.168.1.1:5701”);
datapoint.tags.put(“id”,“map1”);
datapoint.tags.put(“公司”、“Foobar”);
我想用它来表示:
-聚合具有相同id的所有不同机器的所有指标。例如,如果机器1为mapx进行了10次写入,而机器2为mapx进行了20次写入,我想知道30次。
-所有映射的聚合度量:如果机器1在mapx上写了20次,在mapy上写了30次,我想知道总共50次
问题是我应该如何对此进行建模
我知道组合可以用于列id。因此理论上,我可以将每个标记添加为该组合中的一个元素。但是,当一个列在组合中具有可变数量的元素时,它能被有效地搜索吗
我知道我的问题有点模糊不清,但我认为这反映了我对卡桑德拉的理解,因为我刚开始问它。@pveentjer
“我知道组合可以用于列id。因此理论上,我可以将每个标记添加为该组合中的一个元素。但是,当组合中的元素数量可变时,可以有效地搜索列吗?”
使用多个复合材料时有一些规则和限制,请阅读和
对于CQL3,还有更多的限制,请阅读顺便说一句,我愿意放弃灵活的标签。拥有一堆固定的标签,如成员、集群、公司和id就足够了(我希望如此)。