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 {endpoint}/{apiVersion}/$batch
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
api
|
path | True |
string |
The service API version. |
|
endpoint
|
path | True |
string (uri) |
The Log Analytics service endpoint. |
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| requests | True |
An single request in a batch. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
The request has succeeded. |
|
| Other Status Codes |
An unexpected error response. |
Security
OAuth2Auth
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name | Description |
|---|---|
| https://api.loganalytics.io/.default |
Examples
A batch query
Sample request
POST {endpoint}/{apiVersion}/$batch
{
"requests": [
{
"path": "/query",
"method": "POST",
"body": {
"query": "AppRequests | take 2"
},
"id": "1",
"workspace": "d2d0e126-fa1e-4b0a-b647-250cdd471e68"
},
{
"path": "/query",
"method": "POST",
"body": {
"query": "AppRequests | take 3"
},
"id": "2",
"workspace": "d2d0e126-fa1e-4b0a-b647-250cdd471e68"
}
]
}
Sample response
{
"responses": [
{
"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": "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-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"
]
]
}
]
},
"id": "2",
"status": 200
}
]
}
Definitions
| Name | Description |
|---|---|
|
Batch |
A single request in a batch. |
|
Batch |
Contains the batch query response and the headers, id, and status of the request |
|
Batch |
Contains the tables, columns & rows resulting from a query. |
|
Batch |
An array of requests. |
|
Batch |
Response to a batch query. |
| Column |
A column in a table. |
|
Column |
The data type of a column. |
|
Error |
Error details. |
|
Error |
The code and message for an error. |
|
Error |
Contains details when the response code indicates an error. |
|
Query |
The Analytics query. Learn more about the Analytics query syntax |
| Table |
Contains the columns and rows for one table in a query response. |
BatchQueryRequest
A single request in a batch.
| Name | Type | Default value | Description |
|---|---|---|---|
| body |
The Analytics query. Learn more about the Analytics query syntax |
||
| headers |
object |
Headers of the request. Can use prefer header to set server timeout and to query statistics and visualization information. |
|
| id |
string |
Unique ID corresponding to each request in the batch. |
|
| method |
string |
GET |
The method of a single request in a batch, defaults to GET |
| path |
string |
The query path of a single request in a batch. |
|
| workspace |
string |
Primary Workspace ID of the query. This is the Workspace ID from the Properties blade in the Azure portal. |
BatchQueryResponse
Contains the batch query response and the headers, id, and status of the request
| Name | Type | Description |
|---|---|---|
| body |
Contains the tables, columns & rows resulting from a query. |
|
| headers |
object |
Dictionary of <string> |
| id |
string |
Unique ID corresponding to each request in the batch. |
| status |
integer (int32) |
The HTTP status code of the response. |
BatchQueryResults
Contains the tables, columns & rows resulting from a query.
| Name | Type | Description |
|---|---|---|
| error |
The code and message for an error. |
|
| render |
|
Visualization data in JSON format. |
| statistics |
|
Statistics represented in JSON format. |
| tables |
Table[] |
The results of the query in tabular format. |
BatchRequest
An array of requests.
| Name | Type | Description |
|---|---|---|
| requests |
An single request in a batch. |
BatchResponse
Response to a batch query.
| Name | Type | Description |
|---|---|---|
| responses |
An array of responses corresponding to each individual request in a batch. |
Column
A column in a table.
| Name | Type | Description |
|---|---|---|
| name |
string |
The name of this column. |
| type |
The data type of this column. |
ColumnDataType
The data type of a column.
| Value | Description |
|---|---|
| bool |
Boolean data type |
| datetime |
DateTime data type |
| dynamic |
Dynamic data type |
| int |
Integer data type |
| long |
Long integer data type |
| real |
Real/floating point data type |
| string |
String data type |
| guid |
GUID data type |
| decimal |
Decimal data type |
| timespan |
Timespan data type |
ErrorDetail
Error details.
| Name | Type | Description |
|---|---|---|
| additionalProperties |
|
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 |
|
Additional properties that can be provided on the error info object |
| code |
string |
A machine readable error code. |
| details |
error details. |
|
| innererror |
Inner error details if they exist. |
|
| message |
string |
A human readable error message. |
ErrorResponse
Contains details when the response code indicates an error.
| Name | Type | Description |
|---|---|---|
| error |
The error details. |
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 to query in addition to the primary workspace. |
Table
Contains the columns and rows for one table in a query response.
| Name | Type | Description |
|---|---|---|
| columns |
Column[] |
The list of columns in this table. |
| name |
string |
The name of the table. |
| rows |
Rows[] |
The resulting rows from this query. |