Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

context

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

context

Metrics context to search within, a collection of tags

metric

Metric(s) being queried, a collection of metric names

time-range

A time range or aggregate=true for all since the application was deployed

tags (optional)

Tag list by which to group results (optional)

...

Code Block
{"startTime":<start-time>, "endTime":<end-time>, "series":<series-array>}

Name

Description

start-time

Start time, in seconds, with 0 being from the beginning of the query records

metric

End time, in seconds

series-array

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, query1query2; in the example below, eventsIneventsOut). 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

...