Query - Get With Resource Id
Execute an Analytics query using resource URI
Executes an Analytics query for data in the context of a resource.
Here
is an example for using POST with an Analytics query.
GET {endpoint}/{apiVersion}/{resourceId}/query?query={query}
GET {endpoint}/{apiVersion}/{resourceId}/query?query={query}×pan={timespan}
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. |
|
query
|
query | True |
string |
The Analytics query. Learn more about the Analytics query syntax |
|
timespan
|
query |
string (duration) |
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. |
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 GET query
Sample request
GET {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×pan=PT24H
Sample response
x-ms-correlation-request-id: 58a37988-2c05-427a-891f-5e0e1266fcc5
x-ms-request-id: 58a37988-2c05-427a-891f-5e0e1266fcc5
{
"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 |
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. |
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. |