Query - Execute

分析クエリを実行する
データに対して Analytics クエリを実行します。 分析 クエリで POST を使用する例を次に示します。

POST https://api.loganalytics.io/v1/workspaces/{workspaceId}/query

URI パラメーター

名前 / 必須 説明
workspaceId
path True

string

ワークスペースの ID。 これは、Azure portalの [プロパティ] ブレードのワークスペース ID です。

要求ヘッダー

名前 必須 説明
Prefer

string

省略可能。 サーバータイムアウト、クエリ統計、視覚化情報を設定するヘッダーを優先します。

要求本文

名前 必須 説明
query True

string

実行するクエリ。

timespan

string

省略可能。 データのクエリを実行する期間。 これは、ISO8601期間の値です。 この期間は、クエリ式で指定されているに加えて適用されます。

workspaces

string[]

クエリに含まれるワークスペースの一覧。

応答

名前 説明
200 OK

queryResults

OK です。 API 呼び出しが成功し、Analytics クエリの結果が応答ペイロードに含まれる

Other Status Codes

errorResponse

エラー応答オブジェクト。

セキュリティ

oauth2

Azure Active Directory OAuth2 フロー

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名前 説明
user_impersonation ユーザー アカウントの借用

cross-workspace
simple-query

cross-workspace

Sample Request

POST https://api.loganalytics.io/v1/workspaces/63613592-b6f7-4c3d-a390-22ba13102111/query

{
  "query": "union * | where TimeGenerated > ago(1h) | summarize count() by Type, TenantId",
  "workspaces": [
    "draft-test",
    "draft-test-2"
  ]
}

Sample Response

{
  "tables": [
    {
      "name": "PrimaryResult",
      "columns": [
        {
          "name": "Type",
          "type": "string"
        },
        {
          "name": "TenantId",
          "type": "string"
        },
        {
          "name": "count_",
          "type": "long"
        }
      ],
      "rows": [
        [
          "Usage",
          "63613592-b6f7-4c3d-a390-22ba13102111",
          "1"
        ],
        [
          "Usage",
          "d436f322-a9f4-4aad-9a7d-271fbf66001c",
          "1"
        ],
        [
          "BillingFact",
          "63613592-b6f7-4c3d-a390-22ba13102111",
          "1"
        ],
        [
          "BillingFact",
          "d436f322-a9f4-4aad-9a7d-271fbf66001c",
          "1"
        ],
        [
          "Operation",
          "63613592-b6f7-4c3d-a390-22ba13102111",
          "7"
        ],
        [
          "Operation",
          "d436f322-a9f4-4aad-9a7d-271fbf66001c",
          "5"
        ]
      ]
    }
  ]
}

simple-query

Sample Request

POST https://api.loganalytics.io/v1/workspaces/63613592-b6f7-4c3d-a390-22ba13102111/query

{
  "query": "Usage | take 10",
  "timespan": "PT12H"
}

Sample Response

{
  "tables": [
    {
      "name": "PrimaryResult",
      "columns": [
        {
          "name": "TenantId",
          "type": "string"
        },
        {
          "name": "Computer",
          "type": "string"
        },
        {
          "name": "TimeGenerated",
          "type": "datetime"
        },
        {
          "name": "SourceSystem",
          "type": "string"
        },
        {
          "name": "StartTime",
          "type": "datetime"
        },
        {
          "name": "EndTime",
          "type": "datetime"
        },
        {
          "name": "ResourceUri",
          "type": "string"
        },
        {
          "name": "LinkedResourceUri",
          "type": "string"
        },
        {
          "name": "DataType",
          "type": "string"
        },
        {
          "name": "Solution",
          "type": "string"
        },
        {
          "name": "BatchesWithinSla",
          "type": "long"
        },
        {
          "name": "BatchesOutsideSla",
          "type": "long"
        },
        {
          "name": "BatchesCapped",
          "type": "long"
        },
        {
          "name": "TotalBatches",
          "type": "long"
        },
        {
          "name": "AvgLatencyInSeconds",
          "type": "real"
        },
        {
          "name": "Quantity",
          "type": "real"
        },
        {
          "name": "QuantityUnit",
          "type": "string"
        },
        {
          "name": "IsBillable",
          "type": "bool"
        },
        {
          "name": "MeterId",
          "type": "string"
        },
        {
          "name": "LinkedMeterId",
          "type": "string"
        },
        {
          "name": "Type",
          "type": "string"
        }
      ],
      "rows": [
        [
          "b438b4f6-912a-46d5-9cb1-b44069212abc",
          "ContosoSQLSrv1",
          "2017-08-24T06:59:59Z",
          "OMS",
          "2017-08-24T06:00:00Z",
          "2017-08-24T06:59:59Z",
          "/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoazurehq/providers/microsoft.operationalinsights/workspaces/contosoretail-it",
          null,
          "Perf",
          "LogManagement",
          "1",
          "0",
          "0",
          "1",
          "1.286",
          "0.076408",
          "MBytes",
          "true",
          "a4e29a95-5b4c-408b-80e3-113f9410566e",
          "00000000-0000-0000-0000-000000000000",
          "Usage"
        ],
        [
          "b438b4f6-912a-46d5-9cb1-b44069212abc",
          "Store010Web3",
          "2017-08-24T06:59:59Z",
          "OMS",
          "2017-08-24T06:00:00Z",
          "2017-08-24T06:59:59Z",
          "/subscriptions/e4272367-5645-4c4e-9c67-3b74b59a6982/resourcegroups/contosoazurehq/providers/microsoft.operationalinsights/workspaces/contosoretail-it",
          null,
          "Perf",
          "LogManagement",
          "1",
          "0",
          "0",
          "1",
          "1.7",
          "0.106767",
          "MBytes",
          "true",
          "a4e29a95-5b4c-408b-80e3-113f9410566e",
          "00000000-0000-0000-0000-000000000000",
          "Usage"
        ]
      ]
    }
  ]
}

定義

名前 説明
column

テーブル列。

errorDetail

エラーの詳細。

errorInfo

エラーのコードとメッセージ。

errorResponse

エラーの詳細。

logsColumnType

この列のデータ型。

queryBody

分析クエリ。 Analytics クエリ構文の詳細を確認する

queryResults

クエリ応答。

Render

JSON 形式の視覚化データ。

Statistics

JSON 形式で表される統計。

table

クエリ応答テーブル。

column

テーブル列。

名前 説明
name

string

この列の名前。

type

logsColumnType

この列のデータ型。

errorDetail

エラーの詳細。

名前 説明
additionalProperties

object

エラー詳細オブジェクトで指定できる追加のプロパティ

code

string

エラーのコード。

message

string

人間が判読できるエラー メッセージ。

resources

string[]

エラーの原因となったリソースを示します。

target

string

要求のどのプロパティがエラーの原因であるかを示します。

value

string

"target" のどの値がエラーの原因であるかを示します。

errorInfo

エラーのコードとメッセージ。

名前 説明
additionalProperties

object

エラー情報オブジェクトで指定できる追加のプロパティ

code

string

コンピューターで読み取り可能なエラー コード。

details

errorDetail[]

エラーの詳細。

innererror

errorInfo

エラーのコードとメッセージ。
内部エラーの詳細 (存在する場合)。

message

string

人間が判読できるエラー メッセージ。

errorResponse

エラーの詳細。

名前 説明
error

errorInfo

エラーのコードとメッセージ。
エラーの詳細です。

logsColumnType

この列のデータ型。

名前 説明
bool

string

datetime

string

decimal

string

dynamic

string

guid

string

int

string

long

string

real

string

string

string

timespan

string

queryBody

分析クエリ。 Analytics クエリ構文の詳細を確認する

名前 説明
query

string

実行するクエリ。

timespan

string

省略可能。 データのクエリを実行する期間。 これは、ISO8601期間の値です。 この期間は、クエリ式で指定されているに加えて適用されます。

workspaces

string[]

クエリに含まれるワークスペースの一覧。

queryResults

クエリ応答。

名前 説明
error

errorInfo

エラーのコードとメッセージ。

render

Render

JSON 形式の視覚化データ。

statistics

Statistics

JSON 形式で表される統計。

tables

table[]

テーブル、列、行の一覧。

Render

JSON 形式の視覚化データ。

Statistics

JSON 形式で表される統計。

table

クエリ応答テーブル。

名前 説明
columns

column[]

このテーブル内の列の一覧。

name

string

テーブルの名前。

rows

object[]

このクエリの結果の行。