Machlake는 입력된 센서 tag데이터들을 자동으로 tag별, 시간별로 통계 데이터를 생성한다. 이렇게 생성한 통계데이터는 이 API를 통해서 검색할 수 있다. 이 API를 이용하면 대량의 센서 데이터를 연, 월, 일간 단위로 통계값을 얻어서 빠르게 차트를 생성하는 등의 연산이 가능하다.
자동으로 생성되는 통계데이터는 각 tag별 Min, Max, Sum, Count, Average이다.
HTTP Request
GET https://${CloudVendor}.${CountryCode}.machlake.com/lakes/${lake_id}/values/calculated Content-Type: application/json; charset=utf8 x-api-key: {API Key}
Parameters
Optional | Type | Description | Example |
---|---|---|---|
direction | int | ascend or descent by time | &direction=0 |
limit | int | count of display | &limit=1000 (default : Limited according to Lake tier) |
offset | int | count of skip | &offset=500 |
date_format | string | date format of select time | &date_format=YYYY-MM-DD HH24:MI:SS (default : YYYY-MM-DD HH24:MI:SS) |
interval_value | int | duration value | &interval_value=10 (default : 1) |
end_time | string | end time of select (MUST be more than start_time!)
| same as start_time |
calc_mode | string | min,max,cnt,avg,sum | &calc_mode=min (default : avg) |
value_return_form | int | result set format Optimized for various chart libraries and configured to return | 0 : separate standard (default) 1 : merged standard |
interval_type | string | sec,min,hour,day (or s,m,h,d) | &interval_type=hour (default : sec) |
separator | string | separator for tag_name, columns, and_condition | &separator=| (default : ,) |
start_time | string | start time of select (MUST be less than end_time!) type 1 : time string format
type 2 : timestamp (second or millisecond)
| &start_time=2018-01-16 14:40:05 000
|
tag_name | string | tag name with , separator | &tag_name=tag1,tag2,tag3 |
Request Example
GET https://aws1.us.machlake.com/lakes/xbacd1234/values/calculated?tag_name=tag_01,tag_02&value_return_form=0&start_time=2021-06-16 11:35:00&end_time=2021-07-06 12:12:28&calc_mode=avg&interval_type=min&limit=1000 Content-Type: application/json; charset=utf8 x-api-key: {API Key}
Response Example
Status 200 // return format = 0 { "status": "success", "data": { "calc_mode": "AVG", "columns": [ {"name": "TIME", "type": 5, "length": 4096}, {"name": "VALUE", "type": 20, "length": 17} ], "samples": [ { "tag_name": "tag_02", "data": [ {"TIME": "2021-06-16 11:36:00", "VALUE": 1524.3684}, {"TIME": "2021-06-16 11:37:00", "VALUE": 1490.107}, {"TIME": "2021-06-17 15:44:00", "VALUE": 1508.5176}, {"TIME": "2021-07-06 12:12:00", "VALUE": 1628} ] }, { "tag_name": "tag_01", "data": [ {"TIME": "2021-06-16 11:36:00", "VALUE": 1515.4806}, {"TIME": "2021-06-16 11:37:00", "VALUE": 1513.4624}, {"TIME": "2021-06-17 15:42:00", "VALUE": 1499.0289}, {"TIME": "2021-06-17 15:43:00", "VALUE": 1470.2225}, {"TIME": "2021-06-17 15:44:00", "VALUE": 1487.0528}, {"TIME": "2021-07-06 12:12:00", "VALUE": 1887.5} ] } ] } } // return format = 1 { "status": "success", "data": { "calc_mode": "AVG", "columns": [ {"name": "TIME", "type": 5, "length": 4096}, {"name": "VALUE", "type": 20, "length": 17} ], "samples": [ { "tag_name": "tag_02", "data": { "TIME": [ "2021-06-16 11:36:00", "2021-06-16 11:37:00", "2021-06-17 15:44:00", "2021-07-06 12:12:00" ], "VALUE": [ 1524.3684, 1490.107, 1508.5176, 1628 ] } }, { "tag_name": "tag_01", "data": { "TIME": [ "2021-06-16 11:36:00", "2021-06-16 11:37:00", "2021-06-17 15:42:00", "2021-06-17 15:43:00", "2021-06-17 15:44:00", "2021-07-06 12:12:00" ], "VALUE": [ 1515.4806, 1513.4624, 1499.0289, 1470.2225, 1487.0528, 1887.5 ] } } ] } }
Sample Code
Also this API has lots of parameters, but sample case contain few case, but should combine variety parameter combination from these example