Query - Resource Execute
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 https://api.loganalytics.io/v1/{resourceId}/query
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
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 that are included in the query. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
OK. The API call succeeded and the Analytics query result is in the response payload |
|
Other Status Codes |
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
simple-query
Sample request
POST https://api.loganalytics.io/v1//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 table column. |
error |
Error details. |
error |
The code and message for an error. |
error |
Error details. |
logs |
The data type of this column. |
query |
The Analytics query. Learn more about the Analytics query syntax |
query |
A query response. |
Render |
Visualization data in JSON format. |
Statistics |
Statistics represented in JSON format. |
table |
A query response table. |
column
A table column.
Name | Type | Description |
---|---|---|
name |
string |
The name of this column. |
type |
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 |
error details. |
|
innererror |
The code and message for an error. |
|
message |
string |
A human readable error message. |
errorResponse
Error details.
Name | Type | Description |
---|---|---|
error |
The code and message for an error. |
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 |
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. |
queryResults
A query response.
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 list of tables, columns and rows. |
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. |