Query - Execute With Resource Id
Execute an Analytics query using resource ID
Executes an Analytics query for data in the context of a resource.
Here
is an example for using POST with an Analytics query.
POST {endpoint}/{apiVersion}/{resourceId}/query
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. |
|
resource
|
path | True |
string |
The identifier of the resource. |
Request Header
| Name | Required | Type | Description |
|---|---|---|---|
| Prefer |
string |
Optional. The prefer header to set server timeout, query statistics and visualization information. |
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| query | True |
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. |
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
Simple resource-centric POST query
Sample request
POST {endpoint}/{apiVersion}/subscriptions/fffa080af-c2d8-40ad-9cce-e1a450bawb57/resourceGroups/test-resourcegroup/providers/Microsoft.Storage/storageAccounts/storageaccountname/query
{
"query": "StorageBlobLogs | summarize count() by OperationName | top 10 by count_ desc",
"timespan": "PT24H"
}
Sample response
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "OperationName",
"type": "string"
},
{
"name": "count_",
"type": "long"
}
],
"rows": [
[
"operation1",
"10"
]
]
}
]
}
Definitions
| Name | Description |
|---|---|
| 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 |
|
Query |
Contains the tables, columns & rows resulting from a query. |
| Table |
Contains the columns and rows for one table in a query response. |
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. |
QueryResults
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. |
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. |