我有 300 万条记录,其中包含以下条目:
~/Abharthan/kairosdb$ head -10 export.txt
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"1","building_type":"ElementarySchool","meter_type":"temperature","unit":"F"},"value":"34.85"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"2","building_type":"Park","meter_type":"temperature","unit":"F"},"value":"0"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"3","building_type":"Industrial","meter_type":"temperature","unit":"F"},"value":"0.07"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"4","building_type":"RecreationCenter","meter_type":"temperature","unit":"F"},"value":"0"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"5","building_type":"Park","meter_type":"temperature","unit":"F"},"value":"2.2"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"6","building_type":"CommunityCenter","meter_type":"temperature","unit":"F"},"value":"31.41"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"7","building_type":"Office","meter_type":"temperature","unit":"F"},"value":"0"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"8","building_type":"ElementarySchool","meter_type":"temperature","unit":"F"},"value":"10.88"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"9","building_type":"ElementarySchool","meter_type":"temperature","unit":"F"},"value":"42.27"}
{"name": "meterreadings", "timestamp":"1359695700","tags": {"Building_id":"10","building_type":"ElementarySchool","meter_type":"temperature","unit":"F"},"value":"10.14"}
这些是每个建筑物的 1 年抄表读数,每小时收集一次 building_id。
我的起始数据时间戳为:1359695700,结束时间戳为:1422853200。我想查询此数据库以获得以下信息:
Query hourly average for one building(say building_id:100) for one year (output expected of 8760 points)
Query monthly sum for one building for one year (output expected of 12 points)
我编写了以下两个查询来获取上述两个查询的结果:
查询1:
{ "start_absolute":1359695700, "end_absolute":1422853200, "metrics":[{"tags":{"Building_id":["100"]},"name":"meterreadings","aggregators":[{"名称":"avg","align_sampling":true,"sampling":{"value":"1","unit":"hours"}}]}]}
响应:200 {"queries":[{"sample_size":70168,"results":[{"name":"meterreadings","group_by":[{"name":"type","type":"number "}],"tags":{"Building_id":["100"],"building_type":["MiddleSchool"],"meter_type":["temperature"],"unit":["F"]}, "values":[[1359695700,42.45377343113282],[1360800000,36.42662912912908],[1364400000,41.12510250000007],[1368000000,54.915547499999946],[1371600000,65.07990000000015],[1375200000,55.8904375],[1378800000,47.33335249999986],[1382400000, 38.952450000000034],[1386000000,41.99267000000001],[1389600000,41.28209500000009],[1393200000,40.31645895895911],[1396800000,40.758327499999915],[1400400000,54.05608750000002],[1404000000,63.410385],[1407600,000,65.38089749999993],[1411200000,45.99822500000001],[1414800000,39.669450137465724]
查询 2:
{ "start_absolute":1359695700, "end_absolute":1422853200, "metrics":[{"tags":{"Building_id":["100"]},"name":"meterreadings","aggregators":[{"名称":"sum","align_sampling":true,"sampling":{"value":"1","unit":"months"}}]}]}
响应:200 {"queries":[{"sample_size":70168,"results":[{"name":"meterreadings","group_by":[{"name":"type","type":"number "}],"tags":{"Building_id":["100"],"building_type":["MiddleSchool"],"meter_type":["temperature"],"unit":["F"]}, “价值观”:[[1359695700,3337957.570000005]]}]}]}
我没有得到我所期望的,我错过了什么。