Query - Resource Get

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 https://api.loganalytics.io/v1/{resourceId}/query?query={query}
GET https://api.loganalytics.io/v1/{resourceId}/query?query={query}&timespan={timespan}

URI Parameters

Name In Required Type Description
resourceId
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

queryResults

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

simple-query

Sample request

GET 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

x-ms-request-id: 58a37988-2c05-427a-891f-5e0e1266fcc5
x-ms-correlation-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 table column.

errorDetail

Error details.

errorInfo

The code and message for an error.

errorResponse

Error details.

logsColumnType

The data type of this column.

queryResults

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

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

queryResults

A query response.

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.

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.