POST: /query/batch

Run multiple metrics query in a batch.

This accepts a JSON document where all keys are expected to map up to a Query.

Note that the x-client-id: my_app_name header must be supplied since anonymous requests are not permitted.

application/json

Structure
Field Type Purpose
*  required Query Queries to run.

Example Request


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

      

Example Curl


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

Example 200 Response

Status: 200, Content-Type: application/json

Structure
Field Type Purpose
*  QueryResponse Responses to each query run.

          {
  "a": {
    "errors": [],
    "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": {}
  },
  "b": {
    "errors": [],
    "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": {}
  }
}