POST: /query/metrics

Query and aggregate metrics.

application/json

Structure
Field Type Purpose
range  required QueryDateRange The range in time for which to query
filter  Filter

A statement used to filter down the selected time series. Each individual filtering field (filter, key, tags, and hasTags) may be empty. At least one must be specified to make up a valid filter.

See filtering for details on how to build a filter.

aggregation  Aggregation Aggregation to use when down-sampling.
features  [<string>, ...] Enable or disable a feature on a per-query basis. See Features Configuration for more details.

Example Request


          {
  "range": {"type": "relative", "unit": "HOURS", "value": 2},
  "filter": ["and", ["key", "foo"], ["=", "foo", "bar"], ["+", "role"]],
  "aggregation": {
    "type": "group",
    "of": ["site"],
    "each": {
      "type": "sum"
    }
  }
}

      

Example Curl


          $ curl -XPOST -H "Content-Type: application/json" http://localhost:8080/query/metrics \
          -d '{ "range": {"type": "relative", "unit": "HOURS", "value": 2}, "filter": ["and", ["key", "foo"], ["=", "foo", "bar"], ["+", "role"]], "aggregation": { "type": "group", "of": ["site"], "each": { "type": "sum" } } }'
      

Example 200 Response

Status: 200, Content-Type: application/json

Structure
Field Type Purpose
range  {start: <number>, end: <number>} The range in time for which to query
errors  RequestError Potential errors returned either from different shards or for specific time series. The presence of an error does not cause the entire query to fail, instead it is up to the client to use this information to decide if the response is reliable enough.
result  [ShardedResultGroup, ...] An array of result groups.
statistics  Statistics Statistics about the current query. This field should be inspected for errors which will have caused the result to be inconsistent.

          {
  "errors": [
    {
      "type": "node",
      "nodeId": "abcd-efgh",
      "nodeUri": "http://example.com",
      "tags": {"site": "lon"},
      "error": "Connection refused",
      "internal": true
    },
    {
      "type": "series",
      "tags": {"site": "lon"},
      "error": "Aggregation too heavy, too many rows from the database would have to be fetched to satisfy the request!",
      "internal": true
    }
  ],
  "result": [
    {
      "hash": "deadbeef",
      "tags": {"foo": "bar"},
      "values": [[1300000000000, 42.0]]
    },
    {
      "hash": "beefdead",
      "tags": {"foo": "baz"},
      "values": [[1300000000000, 42.0]]
    }
  ],
  "range": {
    "end": 1469816790000,
    "start": 1469809590000
  },
  "statistics": {}
}