...
Code Block |
---|
namespace:default app:PurchaseHistory spark:PurchaseTracker
|
is a context that identifies a Spark program. It has a parent context, namespace:default app:PurchaseHistory
, which identifies the parent application.
...
Code Block |
---|
POST /v3/metrics/search?target=tag[&tag=<context>]
|
The optional <context>
defines a metrics context to search within. If it is not provided, the search is performed across all data. The available contexts that are returned can be used to query for a lower-level of contexts.
...
Code Block |
---|
POST /v3/metrics/search?target=metric&tag=<context>
|
Parameter | Description |
---|---|
| Metrics context to search within. Consists of a collection of tags. |
...
Code Block |
---|
POST /v3/metrics/query?tag=<context>&metric=<metric>&<time-range>[&groupBy=<tags>]
|
Parameter | Description |
---|---|
| Metrics context to search within, a collection of tags |
| Metric(s) being queried, a collection of metric names |
| A time range or |
| Tag list by which to group results (optional) |
...
Code Block |
---|
{"startTime":<start-time>, "endTime":<end-time>, "series":<series-array>}
|
Name | Description |
---|---|
| Start time, in seconds, with 0 being from the beginning of the query records |
| End time, in seconds |
| An array of metric results, which can be one series, a multiple time series, or none (an empty array) |
...
Code Block |
---|
{"startTime":0,"endTime":1429475995,"series":[]}
|
You can also receive such a result from querying a metric that does not exist, either because it does not exist at the context given or if the query is incorrectly formulated:
Code Block |
---|
...metric=user.names.bytes?aggregate=true
|
will return the empty result, as the metric name will be interpreted as "user.names.bytes?aggregate=true"
instead of "user.names.bytes"
.
...
Code Block |
---|
POST /v3/metrics/query?tag=app:CountRandom&metric=system.process.events.processed
&metric=system.dataset.store.bytes&start=now-5s&count=5
|
The result (pretty-printed to fit) would be:
Code Block |
---|
{
"startTime": 1429487786,
"endTime": 1429487791,
"series": [
{
"metricName": "system.process.events.processed",
"grouping": {},
"data": [
{"time": 1429487786, "value": 1268},
{"time": 1429487787, "value": 1324},
{"time": 1429487788, "value": 1206},
{"time": 1429487789, "value": 1125},
{"time": 1429487790, "value": 1035}
]
},
{
"metricName": "system.dataset.store.bytes",
"grouping": {},
"data": [
{"time": 1429487786,"value": 15600},
{"time": 1429487787, "value": 14998},
{"time": 1429487788, "value": 13712},
{"time": 1429487789, "value": 12246},
{"time": 1429487790, "value": 9924}
]
}
]
}
|
Multiple Metrics with Different Contexts
...
Code Block |
---|
POST /v3/metrics/query
|
with the arguments as a JSON string in the body. The format of the JSON follows this structure (pretty-printed):
Code Block |
---|
{ "query1": {
"tags": {"namespace": "default", "app": "PurchaseHistory"},
"metrics": ["metric1", "metric2"],
"groupBy": ["app", "dataset"],
"timeRange": {"aggregate": "true"}
},
"query2": {
"tags": {"namespace": "default"},
"metrics": ["metric1", "metric2"],
"timeRange": {"start": "now-2s", "end": "now"}
}
}
|
Queries are identified by a <query-id>
(in the example above, query1, query2; in the example below, eventsIn, eventsOut). The <query-id>
is then used in the returned result to identify the series.
...
Code Block |
---|
$ curl -w'\n' -X POST 'http://localhost:11015/v3/metrics/query' -H 'Content-Type: application/json' \
-d '{"eventsIn":{"tags": {“app”: “CountRandom”}, "metrics": ["system.process.events.in"],
"timeRange": {"start":"now-5s", "count":"5"} },
"eventsOut":{"tags": {“app”: “CountRandom”}, "metrics": ["system.process.events.out"],
"timeRange": {"start":"now-5s", "count":"5"} }
}'
{"eventsIn":{"startTime":1429593961,"endTime":1429593966,
"series":[{"metricName":"system.process.events.in","grouping":{},
"data":[{"time":1429593961,"value":2828},
{"time":1429593962,"value":3218},
{"time":1429593963,"value":3419},
{"time":1429593964,"value":3593},
{"time":1429593965,"value":3990}]
}]
},
"eventsOut":{"startTime":1429593961,"endTime":1429593966,
"series":[{"metricName":"system.process.events.out","grouping":{},
"data":[{"time":1429593961,"value":3211},
{"time":1429593962,"value":3865},
{"time":1429593963,"value":3919},
{"time":1429593964,"value":3906},
{"time":1429593965,"value":3993}]
}]
}
}
|
If the context of the requested metric or metric itself doesn't exist, the system returns a status 200 (OK) with JSON formed following the above description, with an empty series
for values:
Code Block |
---|
{"query1":{"startTime":1429486465,"endTime":1429486470,"series":[]}}
|
Querying for Multiple Time Series
...