Share via


Query - Execute

Analiz sorgusu yürütme
Veriler için bir Analiz sorgusu yürütür. Aşağıda Post'un Analiz sorgusuyla kullanılmasına yönelik bir örnek verilmiştir.

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

URI Parametreleri

Name İçinde Gerekli Tür Description
workspaceId
path True

string

Çalışma alanının kimliği. Bu, Azure portal Özellikler dikey penceresindeki Çalışma Alanı Kimliği'dir.

İstek Başlığı

Name Gerekli Tür Description
Prefer

string

İsteğe bağlı. Sunucu zaman aşımını, sorgu istatistiklerini ve görselleştirme bilgilerini ayarlamak için tercih üst bilgisi.

İstek Gövdesi

Name Gerekli Tür Description
query True

string

Yürütülecek sorgu.

timespan

string

İsteğe bağlı. Verilerin sorgulandığı zaman aralığı. Bu ISO8601 zaman aralığı değeridir. Bu zaman aralığı, sorgu ifadesinde belirtilenlere ek olarak uygulanır.

workspaces

string[]

Sorguya dahil edilen çalışma alanlarının listesi.

Yanıtlar

Name Tür Description
200 OK

queryResults

Tamam ögesini seçin. API çağrısı başarılı oldu ve Analytics sorgu sonucu yanıt yükünde

Other Status Codes

errorResponse

Hata yanıtı nesnesi.

Güvenlik

oauth2

Azure Active Directory OAuth2 Flow

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

Scopes

Name Description
user_impersonation kullanıcı hesabınızın kimliğine bürünme

Örnekler

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"
        ]
      ]
    }
  ]
}

Tanımlar

Name Description
column

Tablo sütunu.

errorDetail

Hata ayrıntıları.

errorInfo

Hatanın kodu ve iletisi.

errorResponse

Hata ayrıntıları.

logsColumnType

Bu sütunun veri türü.

queryBody

Analiz sorgusu. Analiz sorgusu söz dizimi hakkında daha fazla bilgi edinin

queryResults

Sorgu yanıtı.

Render

JSON biçiminde görselleştirme verileri.

Statistics

JSON biçiminde temsil edilen istatistikler.

table

Sorgu yanıt tablosu.

column

Tablo sütunu.

Name Tür Description
name

string

Bu sütunun adı.

type

logsColumnType

Bu sütunun veri türü.

errorDetail

Hata ayrıntıları.

Name Tür Description
additionalProperties

object

Hata ayrıntıları nesnesinde sağlanabilir ek özellikler

code

string

Hatanın kodu.

message

string

okunabilir bir hata iletisi.

resources

string[]

Hatadan sorumlu kaynakları gösterir.

target

string

İstekteki hangi özelliğin hatadan sorumlu olduğunu gösterir.

value

string

Hatadan 'target' içindeki hangi değerin sorumlu olduğunu gösterir.

errorInfo

Hatanın kodu ve iletisi.

Name Tür Description
additionalProperties

object

Hata bilgisi nesnesinde sağlanabilir ek özellikler

code

string

Makine tarafından okunabilir bir hata kodu.

details

errorDetail[]

hata ayrıntıları.

innererror

errorInfo

Hatanın kodu ve iletisi.
İç hata ayrıntıları varsa.

message

string

okunabilir bir hata iletisi.

errorResponse

Hata ayrıntıları.

Name Tür Description
error

errorInfo

Hatanın kodu ve iletisi.
Hata ayrıntıları.

logsColumnType

Bu sütunun veri türü.

Name Tür Description
bool

string

datetime

string

decimal

string

dynamic

string

guid

string

int

string

long

string

real

string

string

string

timespan

string

queryBody

Analiz sorgusu. Analiz sorgusu söz dizimi hakkında daha fazla bilgi edinin

Name Tür Description
query

string

Yürütülecek sorgu.

timespan

string

İsteğe bağlı. Verilerin sorgulandığı zaman aralığı. Bu ISO8601 zaman aralığı değeridir. Bu zaman aralığı, sorgu ifadesinde belirtilenlere ek olarak uygulanır.

workspaces

string[]

Sorguya dahil edilen çalışma alanlarının listesi.

queryResults

Sorgu yanıtı.

Name Tür Description
error

errorInfo

Hatanın kodu ve iletisi.

render

Render

JSON biçiminde görselleştirme verileri.

statistics

Statistics

JSON biçiminde temsil edilen istatistikler.

tables

table[]

Tablo, sütun ve satır listesi.

Render

JSON biçiminde görselleştirme verileri.

Statistics

JSON biçiminde temsil edilen istatistikler.

table

Sorgu yanıt tablosu.

Name Tür Description
columns

column[]

Bu tablodaki sütunların listesi.

name

string

Tablonun adı.

rows

object[]

Bu sorgudan elde edilen satırlar.