View Source

Grid measurements can be fetched from REST API.

h2. Support Functions
The base URI for grid measuremetns REST API is:
{code}
/rest/measurements
{code}

The support functions are:

||URI||Description||Params||
|/rest/grid/measurements/help|Get help for all available functions|NO PARAMS|
|/rest/grid/measurements/version|Get current version for the measurements related REST API|NO PARAMS|
|/rest/grid/measurements|Query for the measurements you want|* source - *QUERY_PARAM*
Specify the node you want to query. If not specifed, then all nodes will be used.
* period - *QUERY_PARAM*
Specify the time range you want to query. by default, period is LAST_HOUR, this param can be one of: LAST_HOUR, LAST_2_HOURS, LAST_4_HOURS, LAST_DAY, LAST_WEEK, LAST_MONTH
* start_time - *QUERY_PARAM*
Specify the start time you want to query. If not specified, then an hour ago of to_date will be used.
* end_time - *QUERY_PARAM*
Specify the end time you want to query. If not specified, then current time will be used.
* metric - *QUERY_PARAM*
Specify the metric name you want to query. See below section for all available metric names
* date_pattern - *QUERY_PARAM*
Specify the date pattern you are using for from_date and to_date. By default, ISO 8601 is used.|

Below, we'd like to give some examples for how to query the measurements:

h3. With no params
If you call below query, QuickBuild will return all measurements collected from all nodes in the last one hour.
{code}
/rest/grid/measurements
{code}

h3. Query for a specified node
Below query will return all measurements from _myagent:8811_ in the last one hour.
{code}
/rest/grid/measurements?source=myagent:8811
{code}

h3. Query for a specified metric
Below query will return measurements of _disk usage_ for all nodes in the last one hour.
{code}
/rest/grid/measurements?metric=disk.usage
{code}

h3. Query for a specific time range
Below query returns all measurements for all nodes in the last 2 hours.
{code}
/rest/grid/measurements?period=LAST_2_HOURS
{code}

Below query returns all measurements for all nodes from time: 2013-02-25T09:47:00+08:00, note by default, you need format your time in ISO8601 format, that is, in pattern: yyyy-MM-dd'T'HH:mm:ss.SSSZ, we will give a custom date pattern in later sample.

{code}
/rest/grid/measurements?start_time=2013-02-25T09:47:00.000%2B08:00
{code}

Below query returns all measurements for all nodes in a specified time range with a custom date format pattern:
{code}
/rest/grid/measurements?start_time=2013/02/25+09:47&end_time=2013/02/27+09:47&date_pattern=yyyy/MM/dd+HH:mm
{code}

h2. Example return result
For all query above, below is an example return result:
{code}
<list>
<com.pmease.quickbuild.model.MeasurementDataR00>
<id>350</id>
<timestamp>1361854800000</timestamp>
<source>Zhenyu-MBP.local:8811</source>
<metricName>memory.usage</metricName>
<value>0.743398666381836</value>
</com.pmease.quickbuild.model.MeasurementDataR00>
<com.pmease.quickbuild.model.MeasurementDataR00>
<id>335</id>
<timestamp>1361854800000</timestamp>
<source>Zhenyu-MBP.local:8810</source>
<metricName>web.rpc.oneMinuteRate</metricName>
<value>10.3903417298681</value>
</com.pmease.quickbuild.model.MeasurementDataR00>
<com.pmease.quickbuild.model.MeasurementDataR00>
<id>334</id>
<timestamp>1361854800000</timestamp>
<source>Zhenyu-MBP.local:8810</source>
<metricName>web.rpc.fiveMinuteRate</metricName>
<value>8.90793420070343</value>
</com.pmease.quickbuild.model.MeasurementDataR00>
</list>
{code}

Here, timestamp is the milli-seconds in Java time, you can simply create your own Date instance by _new Date(timestamp)_