@pitrix/data-convertor
v1.2.3
Published
translate monitor data from api into readable, uncompressed and structured data
Downloads
3
Keywords
Readme
A data convertor that translate data from QingCloud monitor api, ie. GetMonitor/GetLoadBalancerMonitor/GetRDBMonitor, etc. into chart understandable data. For chart.js or Mobile chart modules.
Requirements: underscore.js
Usage: var resp = { "action":"GetMonitorResponse", "meter_set": [{"data": [...]}, {"data": [...]}]}, "ret_code":0, "resource_id":"rtr-ptyat1bp" }; var opts = { step: '5m', subtype: "http", // optional chart_options: { // optional dateFormat: 'timestamp' } }; var convertor = new Convertor(resp, opts); var data = convertor.toLineData();
Data structure:
instance/disk/eip/router [ { "meter_id": "vxnet-0", "meter_type": "vxnet", "unit": 'bps', "data": { "labels": ["2015-03-26T03:15:00.000Z", "2015-03-26T03:30:00.000Z", ...] "datasets": [ { "label": "inbound", "data": [104, 96, 96, 104, ...] }, { "label": "outbound", "data": [104, 96, 96, 104, ...] } ] } }, {...} ]
loadbalancer { "eip-afq3xxxx": { [ "meter_id": "latency", "unit": "ms", "data": { "labels": ["2015-03-26T03:15:00.000Z", "2015-03-26T03:30:00.000Z", ...] "datasets": [ { "label": "lat_max", "data": [104, 96, 96, 104, ...] }, { "label": "lat_min", "data": [104, 96, 96, 104, ...] }, { "label": "lat_avg", "data": [104, 96, 96, 104, ...] } ] } ], [ "meter_id": "reqest_and_correct_response", ... ] }, "eip-afq4xxxx": { ... } }