Query - Batch

Execute a batch of Analytics queries
Executes a batch of Analytics queries for data. Here is an example for using POST with an Analytics query.

POST https://api.loganalytics.io/v1/$batch

Request Body

Name Required Type Description
requests True

batchQueryRequest[]

An single request in a batch.

Responses

Name Type Description
200 OK

batchResponse

OK. The API call succeeded and the Analytics query result is in the response payload

Other Status Codes

errorResponse

An error response object.

Security

oauth2

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

metadataPost

Sample request

POST https://api.loganalytics.io/v1/$batch

{
  "requests": [
    {
      "id": "1",
      "body": {
        "query": "AppRequests | take 2"
      },
      "path": "/query",
      "method": "POST",
      "workspace": "d2d0e126-fa1e-4b0a-b647-250cdd471e68"
    },
    {
      "id": "2",
      "body": {
        "query": "AppRequests | take 3"
      },
      "path": "/query",
      "method": "POST",
      "workspace": "d2d0e126-fa1e-4b0a-b647-250cdd471e68"
    }
  ]
}

Sample response

{
  "responses": [
    {
      "id": "1",
      "status": 200,
      "body": {
        "tables": [
          {
            "name": "PrimaryResult",
            "columns": [
              {
                "name": "TenantId",
                "type": "string"
              },
              {
                "name": "TimeGenerated",
                "type": "datetime"
              },
              {
                "name": "Id",
                "type": "string"
              },
              {
                "name": "Source",
                "type": "string"
              },
              {
                "name": "Name",
                "type": "string"
              },
              {
                "name": "Url",
                "type": "string"
              },
              {
                "name": "Success",
                "type": "bool"
              },
              {
                "name": "ResultCode",
                "type": "string"
              },
              {
                "name": "DurationMs",
                "type": "real"
              },
              {
                "name": "PerformanceBucket",
                "type": "string"
              },
              {
                "name": "Properties",
                "type": "dynamic"
              },
              {
                "name": "Measurements",
                "type": "dynamic"
              },
              {
                "name": "OperationName",
                "type": "string"
              },
              {
                "name": "OperationId",
                "type": "string"
              },
              {
                "name": "OperationLinks",
                "type": "dynamic"
              },
              {
                "name": "ParentId",
                "type": "string"
              },
              {
                "name": "SyntheticSource",
                "type": "string"
              },
              {
                "name": "SessionId",
                "type": "string"
              },
              {
                "name": "UserId",
                "type": "string"
              },
              {
                "name": "UserAuthenticatedId",
                "type": "string"
              },
              {
                "name": "UserAccountId",
                "type": "string"
              },
              {
                "name": "AppVersion",
                "type": "string"
              },
              {
                "name": "AppRoleName",
                "type": "string"
              },
              {
                "name": "AppRoleInstance",
                "type": "string"
              },
              {
                "name": "ClientType",
                "type": "string"
              },
              {
                "name": "ClientModel",
                "type": "string"
              },
              {
                "name": "ClientOS",
                "type": "string"
              },
              {
                "name": "ClientIP",
                "type": "string"
              },
              {
                "name": "ClientCity",
                "type": "string"
              },
              {
                "name": "ClientStateOrProvince",
                "type": "string"
              },
              {
                "name": "ClientCountryOrRegion",
                "type": "string"
              },
              {
                "name": "ClientBrowser",
                "type": "string"
              },
              {
                "name": "ResourceGUID",
                "type": "string"
              },
              {
                "name": "IKey",
                "type": "string"
              },
              {
                "name": "SDKVersion",
                "type": "string"
              },
              {
                "name": "ItemCount",
                "type": "int"
              },
              {
                "name": "ReferencedItemId",
                "type": "string"
              },
              {
                "name": "ReferencedType",
                "type": "string"
              },
              {
                "name": "SourceSystem",
                "type": "string"
              },
              {
                "name": "Type",
                "type": "string"
              },
              {
                "name": "_ResourceId",
                "type": "string"
              }
            ],
            "rows": [
              [
                "d2d0e126-fa1e-4b0a-b647-250cdd471e68",
                "2021-06-02T00:18:13.317Z",
                "a3273b160f86b5c4",
                "",
                "ServiceBus.process",
                "",
                true,
                "200",
                0,
                "<250ms",
                "{\"x-opt-enqueued-time\":\"1622593091\"}",
                null,
                "ServiceBus.process",
                "e5d21caf619d4ef564a4b5920cadce47",
                null,
                "c6864f9d3649f302",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "srikanta",
                "PC",
                "",
                "",
                "0.0.0.0",
                "Edmonds",
                "Washington",
                "United States",
                "",
                "fc5f5a5d-d6d1-47f9-be1b-aa57185ec6be",
                "b4f83947-968d-4e2f-82ad-804be07697ae",
                "java:3.1.1-BETA.2",
                1,
                "",
                "",
                "Azure",
                "AppRequests",
                "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourcegroups/srnagar-azuresdkgroup/providers/microsoft.insights/components/srnagarappinsights"
              ],
              [
                "d2d0e126-fa1e-4b0a-b647-250cdd471e68",
                "2021-06-02T00:19:13.44Z",
                "bebb49e7a1344c07",
                "",
                "ServiceBus.process",
                "",
                true,
                "200",
                0,
                "<250ms",
                "{\"x-opt-enqueued-time\":\"1622593091\"}",
                null,
                "ServiceBus.process",
                "d76c6dec50d2c12267d7d3a246a0c237",
                null,
                "b68fff4775c77214",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "srikanta",
                "PC",
                "",
                "",
                "0.0.0.0",
                "Edmonds",
                "Washington",
                "United States",
                "",
                "fc5f5a5d-d6d1-47f9-be1b-aa57185ec6be",
                "b4f83947-968d-4e2f-82ad-804be07697ae",
                "java:3.1.1-BETA.2",
                1,
                "",
                "",
                "Azure",
                "AppRequests",
                "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourcegroups/srnagar-azuresdkgroup/providers/microsoft.insights/components/srnagarappinsights"
              ]
            ]
          }
        ]
      }
    },
    {
      "id": "2",
      "status": 200,
      "body": {
        "tables": [
          {
            "name": "PrimaryResult",
            "columns": [
              {
                "name": "TenantId",
                "type": "string"
              },
              {
                "name": "TimeGenerated",
                "type": "datetime"
              },
              {
                "name": "Id",
                "type": "string"
              },
              {
                "name": "Source",
                "type": "string"
              },
              {
                "name": "Name",
                "type": "string"
              },
              {
                "name": "Url",
                "type": "string"
              },
              {
                "name": "Success",
                "type": "bool"
              },
              {
                "name": "ResultCode",
                "type": "string"
              },
              {
                "name": "DurationMs",
                "type": "real"
              },
              {
                "name": "PerformanceBucket",
                "type": "string"
              },
              {
                "name": "Properties",
                "type": "dynamic"
              },
              {
                "name": "Measurements",
                "type": "dynamic"
              },
              {
                "name": "OperationName",
                "type": "string"
              },
              {
                "name": "OperationId",
                "type": "string"
              },
              {
                "name": "OperationLinks",
                "type": "dynamic"
              },
              {
                "name": "ParentId",
                "type": "string"
              },
              {
                "name": "SyntheticSource",
                "type": "string"
              },
              {
                "name": "SessionId",
                "type": "string"
              },
              {
                "name": "UserId",
                "type": "string"
              },
              {
                "name": "UserAuthenticatedId",
                "type": "string"
              },
              {
                "name": "UserAccountId",
                "type": "string"
              },
              {
                "name": "AppVersion",
                "type": "string"
              },
              {
                "name": "AppRoleName",
                "type": "string"
              },
              {
                "name": "AppRoleInstance",
                "type": "string"
              },
              {
                "name": "ClientType",
                "type": "string"
              },
              {
                "name": "ClientModel",
                "type": "string"
              },
              {
                "name": "ClientOS",
                "type": "string"
              },
              {
                "name": "ClientIP",
                "type": "string"
              },
              {
                "name": "ClientCity",
                "type": "string"
              },
              {
                "name": "ClientStateOrProvince",
                "type": "string"
              },
              {
                "name": "ClientCountryOrRegion",
                "type": "string"
              },
              {
                "name": "ClientBrowser",
                "type": "string"
              },
              {
                "name": "ResourceGUID",
                "type": "string"
              },
              {
                "name": "IKey",
                "type": "string"
              },
              {
                "name": "SDKVersion",
                "type": "string"
              },
              {
                "name": "ItemCount",
                "type": "int"
              },
              {
                "name": "ReferencedItemId",
                "type": "string"
              },
              {
                "name": "ReferencedType",
                "type": "string"
              },
              {
                "name": "SourceSystem",
                "type": "string"
              },
              {
                "name": "Type",
                "type": "string"
              },
              {
                "name": "_ResourceId",
                "type": "string"
              }
            ],
            "rows": [
              [
                "d2d0e126-fa1e-4b0a-b647-250cdd471e68",
                "2021-06-02T16:31:25.383Z",
                "08bf242cdc68504c",
                "",
                "ServiceBus.process",
                "",
                true,
                "200",
                0,
                "<250ms",
                "{\"x-opt-enqueued-time\":\"1622651483\"}",
                null,
                "ServiceBus.process",
                "65d9eb1ccf85b1b7ed1e2ea6bb72f563",
                null,
                "146140ce8493a6ed",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "srikanta",
                "PC",
                "",
                "",
                "0.0.0.0",
                "Edmonds",
                "Washington",
                "United States",
                "",
                "fc5f5a5d-d6d1-47f9-be1b-aa57185ec6be",
                "b4f83947-968d-4e2f-82ad-804be07697ae",
                "java:3.1.1-BETA.2",
                1,
                "",
                "",
                "Azure",
                "AppRequests",
                "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourcegroups/srnagar-azuresdkgroup/providers/microsoft.insights/components/srnagarappinsights"
              ],
              [
                "d2d0e126-fa1e-4b0a-b647-250cdd471e68",
                "2021-06-02T16:32:25.492Z",
                "9f4cd78c10d57b4f",
                "",
                "ServiceBus.process",
                "",
                true,
                "200",
                0,
                "<250ms",
                "{\"x-opt-enqueued-time\":\"1622651483\"}",
                null,
                "ServiceBus.process",
                "ae054fe7b7ac3adf8b841ebbe1ecb912",
                null,
                "14eab103a1969665",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "srikanta",
                "PC",
                "",
                "",
                "0.0.0.0",
                "Edmonds",
                "Washington",
                "United States",
                "",
                "fc5f5a5d-d6d1-47f9-be1b-aa57185ec6be",
                "b4f83947-968d-4e2f-82ad-804be07697ae",
                "java:3.1.1-BETA.2",
                1,
                "",
                "",
                "Azure",
                "AppRequests",
                "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourcegroups/srnagar-azuresdkgroup/providers/microsoft.insights/components/srnagarappinsights"
              ],
              [
                "d2d0e126-fa1e-4b0a-b647-250cdd471e68",
                "2021-06-02T16:33:25.585Z",
                "ea7e09d4baa4e4ce",
                "",
                "ServiceBus.process",
                "",
                true,
                "200",
                0,
                "<250ms",
                "{\"x-opt-enqueued-time\":\"1622651483\"}",
                null,
                "ServiceBus.process",
                "ba6162e3ccd803086944750b82600a3a",
                null,
                "b60455183860caaf",
                "",
                "",
                "",
                "",
                "",
                "",
                "",
                "srikanta",
                "PC",
                "",
                "",
                "0.0.0.0",
                "Edmonds",
                "Washington",
                "United States",
                "",
                "fc5f5a5d-d6d1-47f9-be1b-aa57185ec6be",
                "b4f83947-968d-4e2f-82ad-804be07697ae",
                "java:3.1.1-BETA.2",
                1,
                "",
                "",
                "Azure",
                "AppRequests",
                "/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourcegroups/srnagar-azuresdkgroup/providers/microsoft.insights/components/srnagarappinsights"
              ]
            ]
          }
        ]
      }
    }
  ]
}

Definitions

Name Description
batchQueryRequest

An single request in a batch.

batchQueryResponse
batchQueryResults

A query response for a single query in a batch.

batchRequest

An array of requests.

batchResponse

Response to a batch query.

column

A table column.

errorDetail

Error details.

errorInfo

The code and message for an error.

errorResponse

Error details.

logsColumnType

The data type of this column.

methodType
path
queryBody

The Analytics query. Learn more about the Analytics query syntax

Render

Visualization data in JSON format.

Statistics

Statistics represented in JSON format.

table

A query response table.

batchQueryRequest

An single request in a batch.

Name Type Description
body

queryBody

The Analytics query. Learn more about the Analytics query syntax

headers

object

id

string

The error details.

method

methodType

path

path

workspace

string

Workspace Id to be included in the query

batchQueryResponse

Name Type Description
body

batchQueryResults

A query response for a single query in a batch.
Contains the tables, columns & rows resulting from a query.

headers

object

id

string

status

integer

batchQueryResults

A query response for a single query in a batch.

Name Type Description
error

errorInfo

The code and message for an error.

render

Render

Visualization data in JSON format.

statistics

Statistics

Statistics represented in JSON format.

tables

table[]

The list of tables, columns and rows.

batchRequest

An array of requests.

Name Type Description
requests

batchQueryRequest[]

An single request in a batch.

batchResponse

Response to a batch query.

Name Type Description
responses

batchQueryResponse[]

An array of responses corresponding to each individual request in a batch.

column

A table column.

Name Type Description
name

string

The name of this column.

type

logsColumnType

The data type of this column.

errorDetail

Error details.

Name Type Description
additionalProperties

object

Additional properties that can be provided on the error details object

code

string

The error's code.

message

string

A human readable error message.

resources

string[]

Indicates resources which were responsible for the error.

target

string

Indicates which property in the request is responsible for the error.

value

string

Indicates which value in 'target' is responsible for the error.

errorInfo

The code and message for an error.

Name Type Description
additionalProperties

object

Additional properties that can be provided on the error info object

code

string

A machine readable error code.

details

errorDetail[]

error details.

innererror

errorInfo

The code and message for an error.
Inner error details if they exist.

message

string

A human readable error message.

errorResponse

Error details.

Name Type Description
error

errorInfo

The code and message for an error.
The error details.

logsColumnType

The data type of this column.

Name Type Description
bool

string

datetime

string

decimal

string

dynamic

string

guid

string

int

string

long

string

real

string

string

string

timespan

string

methodType

Name Type Description
POST

string

path

Name Type Description
/query

string

queryBody

The Analytics query. Learn more about the Analytics query syntax

Name Type Description
query

string

The query to execute.

timespan

string

Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression.

workspaces

string[]

A list of workspaces that are included in the query.

Render

Visualization data in JSON format.

Statistics

Statistics represented in JSON format.

table

A query response table.

Name Type Description
columns

column[]

The list of columns in this table.

name

string

The name of the table.

rows

object[]

The resulting rows from this query.