...
Code Block |
---|
POST /v3/metrics/query?tag=namespace:default&tag=app:PurchaseHistoryTracker&
groupBy=spark&metric=user.customers.count&start=now-2s&end=now
|
returns the user.customers.count metric in the context of the application PurchaseHistory of the default namespace, for the specified time range, and grouped by spark: PurchaseHistoryTracker (results reformatted to fit):
Code Block |
---|
{
"startTime": 1421188775,
"endTime": 1421188777,
"series": [
{
"metricName": "user.customers.count",
"grouping": { "spark": "PurchaseHistoryTracker" },
"data": [
{ "time": 1421188776, "value": 3 },
{ "time": 1421188777, "value": 2 }
]
},
{
"metricName": "user.customers.count",
"grouping": { "spark": "PurchaseAnalysisTracker" },
"data": [
{ "time": 1421188775, "value": 1 },
{ "time": 1421188777, "value": 2 }
]
}
]
}
|
Querying by a Time Range
The time range of a metric query can be specified in various ways: either aggregate=true
to retrieve the total aggregated since the application was deployed or, in the case of dataset metrics, since a dataset was created; or as a start
and end
to define a specific range and return a series of data points.
...
Code Block |
---|
POST /v3/metrics/query?tag=namespace:default&tag=app:CountRandom&
metric=system.process.events.processed&start=now-1h&end=now&resolution=1m
|
This will return the value of the metric system.process.events.processed for the last hour at one-minute intervals.
...
Code Block |
---|
POST /v3/metrics/query?tag=namespace:default&tag=app:CountRandom
&metric=system.process.events.processed&aggregate=true
|
If a metric is a gauge type, the aggregate will return the latest value set for the metric. For example, this request will retrieve the completion percentage for the map-stage of the MapReduce PurchaseHistoryBuilder
(reformatted to fit):
Code Block |
---|
POST /v3/metrics/query?tag=namespace:default&tag=app:PurchaseHistory
&tag=mapreduce:PurchaseHistoryBuilder&tage=tasktype:m&metric=system.process.completion&aggregate=true
{"startTime":0,"endTime":1429497700,"series":[{"metricName":"system.process.completion",
"grouping":{},"data":[{"time":0,"value":100}]}]}
|
Querying by Run-ID
Each execution of a program (MapReduce, Spark, service, worker) has an associated run-ID that uniquely identifies that program's run. We can query metrics for a program by its run-ID to retrieve the metrics for a particular run. Please see the Run Records and Schedule on retrieving active and historical program runs.
...
Code Block |
---|
...app:<app-id>&tag=<program-type>:<program-id>&tag=run:<run-id>
|
Examples of using a run-ID (with both commands and results reformatted to fit):
Code Block |
---|
POST /v3/metrics/query?tag=namespace:default&tag=app:PurchaseHistory&tag=mapreduce:
PurchaseHistoryBuilder&tag=run:453-454-447683&tag=tasktype:m&metric=system.process.completion
{"startTime":0,"endTime":1429498425,"series":[{"metricName":"system.process.completion",
"grouping":{},"data":[{"time":0,"value":100}]}]}
|
The last example will return (where "time"=0
means aggregated total number, and endTime
is the time of the query) something similar to:
Code Block |
---|
{"startTime":0,"endTime":1421188775,"series":[{"metricName":"system.process.events.processed",
"grouping":{},"data":[{"time":0,"value":11188}]}]}
|
Query Tips
User-defined metrics are always prefixed with the word
user
, and must be queried by using that prefix with the metric name.For example, to request the user-defined metric uploads.completed for the SportResults application's UploadService:
Code Block POST /v3/metrics/query?tag=namespace:default&tag=app:SportResults &tag=service:UploadService&metric=user.uploads.completed&aggregate=true