Skip to content

Event Multi Query

Nitish Goyal edited this page Apr 24, 2019 · 4 revisions

The multi_query_ analytics is used to filter and search for events. The request supports pagination. Multiple requests can be executed as part of one request

Parameters

  • opcode - multi_query (Required) - Operation code for this analytics
  • requests - Map of requests (Required). Key would be used as an identifier in response and value would be any other foxtrot request
  • table - table_name (Required) - Table on which analytics will be run
  • filters - Array of filters (Optional) (default - no filters)
  • sort - Field on which output will be sorted (Optional) (default: _timestamp, order - descending)
  • from - Starting record number (default: 0)
  • to - Number of records to fetch (default: 10)

Sample Request (With Filter)

The following will execute two queries within one request for two different time periods

{
  "opcode": "multi_query",
  "requests": {
    "Key1": {
      "opcode": "trend",
      "table": "test-app",
      "filters": [
        {
          "field": "_timestamp",
          "operator": "last",
          "duration": "15minutes",
          "currentTime": 1556087411377
        }
      ],
      "field": "eventType",
      "period": "minutes"
    },
    "Key2": {
      "opcode": "trend",
      "table": "test-app",
      "filters": [
        {
          "field": "_timestamp",
          "operator": "last",
          "duration": "15minutes",
          "currentTime": 1556086511377
        }
      ],
      "field": "eventType",
      "period": "minutes"
    }
  }
}

Sample Response

{
  "opcode": "multi_query",
  "responses": {
    "Key1": {
      "opcode": "trend",
      "trends": {
        "E1": [
          {
            "period": 1556087220000,
            "count": 1
          }
        ]
      }
    },
    "Key2": {
      "opcode": "trend",
      "trends": {
        "E3": [
          {
            "period": 1556085600000,
            "count": 196
          },
          {
            "period": 1556085660000,
            "count": 232
          },
          {
            "period": 1556085720000,
            "count": 253
          },
          {
            "period": 1556085780000,
            "count": 181
          },
          {
            "period": 1556085840000,
            "count": 256
          },
          {
            "period": 1556085900000,
            "count": 249
          },
          {
            "period": 1556085960000,
            "count": 244
          },
          {
            "period": 1556086020000,
            "count": 222
          },
          {
            "period": 1556086080000,
            "count": 223
          },
          {
            "period": 1556086140000,
            "count": 243
          },
          {
            "period": 1556086200000,
            "count": 231
          },
          {
            "period": 1556086260000,
            "count": 216
          },
          {
            "period": 1556086320000,
            "count": 232
          },
          {
            "period": 1556086380000,
            "count": 200
          },
          {
            "period": 1556086440000,
            "count": 256
          },
          {
            "period": 1556086500000,
            "count": 52
          }
        ]
      }
    }
  }
}