共用方式為


在 Log Analytics 工作區中設定使用輔助方案的資料表 (預覽)

輔助資料表方案可讓您以低成本的方式在 Log Analytics 工作區中擷取和保留資料。 Azure 監視器記錄目前只會在以資料收集規則 (DCR) 為基礎的自訂資料表上支援輔助資料表方案,而您會將使用 Azure 監視器代理程式記錄擷取 API所收集到的資料傳送至這些自訂資料表。

本文說明如何在 Log Analytics 工作區中建立使用輔助方案的自訂資料表,並設定會將資料傳送至此資料表的資料收集規則。

以下影片說明輔助數據表方案的一些用途和優點:

重要

若要了解與輔助資料表和資料收集規則相關的支援區域和限制,請參閱公開預覽限制

必要條件

若要建立自訂資料表並收集記錄資料,您需要:

  • 您至少擁有 Log Analytics 工作區的參與者權限
  • 資料收集端點 (DCE)
  • 讓 Log Analytics 工作區中的所有資料表具有名為 TimeGenerated 的資料行。 如果您的原始記錄資料具有 TimeGenerated 屬性,Azure 監視器會使用此值來識別記錄的建立時間。 針對使用輔助方案的資料表,TimeGenerated 資料行目前僅支援 ISO8601 格式。 如需 TimeGenerated 格式的相關資訊,請參閱支援的 ISO 8601 日期時間格式

建立使用輔助方案的自訂資料表

若要建立自訂資料表,請使用下列命令呼叫資料表 - 建立或更新 API

https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.OperationalInsights/workspaces/{workspace_name}/tables/{table name_CL}?api-version=2023-01-01-preview

提供此承載 - 更新資料表名稱,並根據資料表的結構描述來調整資料行:

 {
    "properties": {
        "schema": {
            "name": "table_name_CL",
            "columns": [
                {
                    "name": "TimeGenerated",
                    "type": "datetime"
                },
                {
                    "name": "StringProperty",
                    "type": "string"
                },
                {
                    "name": "IntProperty",
                    "type": "int"
                },
                 {
                    "name": "LongProperty",
                    "type": "long"
                },
                 {
                    "name": "RealProperty",
                    "type": "real"
                },
                 {
                    "name": "BooleanProperty",
                    "type": "boolean"
                },
                 {
                    "name": "GuidProperty",
                    "type": "guid"
                },
                 {
                    "name": "DateTimeProperty",
                    "type": "datetime"
                }
            ]
        },
        "totalRetentionInDays": 365,
        "plan": "Auxiliary"
    }
}

將資料傳送至使用輔助方案的資料表

目前有兩種方式可將資料擷取至使用輔助方案的自訂資料表:

  • 使用 Azure 監視器代理程式從文字檔收集記錄 / 使用 Azure 監視器代理程式從 JSON 檔案收集記錄

    如果您使用此方法,您的自訂資料表必須只有兩個資料行 - TimeGeneratedRawData (類型為 string)。 資料收集規則會將您收集的每個記錄項目完整傳送至 RawData 資料行,而 Azure 監視器記錄會自動在 TimeGenerated 資料行內填入記錄的擷取時間。

  • 使用記錄擷取 API 將資料傳送至 Azure 監視器。

    若要使用此方法:

    1. 建立使用輔助方案的自訂資料表,如本文所述。

    2. 遵循教學課程:使用記錄擷取 API 將資料傳送至 Azure 監視器中所述的步驟:

      1. 建立 Microsoft Entra 應用程式
      2. 使用此 ARM 範本建立資料收集規則
      {
          "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
              "dataCollectionRuleName": {
                  "type": "string",
                  "metadata": {
                      "description": "Specifies the name of the data collection rule to create."
                  }
              },
              "location": {
                  "type": "string",
                  "metadata": {
                      "description": "Specifies the region in which to create the data collection rule. The must be the same region as the destination Log Analytics workspace."
                  }
              },
              "workspaceResourceId": {
                  "type": "string",
                  "metadata": {
                      "description": "The Azure resource ID of the Log Analytics workspace in which you created a custom table with the Auxiliary plan."
                  }
              }
          },
          "resources": [
              {
                  "type": "Microsoft.Insights/dataCollectionRules",
                  "name": "[parameters('dataCollectionRuleName')]",
                  "location": "[parameters('location')]",
                  "apiVersion": "2023-03-11",
                  "kind": "Direct",
                  "properties": {
                      "streamDeclarations": {
                          "Custom-table_name_CL": {
                              "columns": [
                                  {
                                      "name": "TimeGenerated",
                                      "type": "datetime"
                                  },
                                  {
                                      "name": "StringProperty",
                                      "type": "string"
                                  },
                                  {
                                      "name": "IntProperty",
                                      "type": "int"
                                  },
                                  {
                                      "name": "LongProperty",
                                      "type": "long"
                                  },
                                  {
                                      "name": "RealProperty",
                                      "type": "real"
                                  },
                                  {
                                      "name": "BooleanProperty",
                                      "type": "boolean"
                                  },
                                  {
                                      "name": "GuidProperty",
                                      "type": "guid"
                                  },
                                  {
                                      "name": "DateTimeProperty",
                                      "type": "datetime"
                                  }
                                      }
                                  },
                      "destinations": {
                          "logAnalytics": [
                              {
                                  "workspaceResourceId": "[parameters('workspaceResourceId')]",
                                  "name": "myworkspace"
                              }
                          ]
                      },
                      "dataFlows": [
                          {
                              "streams": [
                                  "Custom-table_name_CL"
                              ],
                              "destinations": [
                                  "myworkspace"
                              ]
                          }
                      ]
                  }
              }
          ],
          "outputs": {
              "dataCollectionRuleId": {
                  "type": "string",
                  "value": "[resourceId('Microsoft.Insights/dataCollectionRules', parameters('dataCollectionRuleName'))]"
              }
          }
      }
      

      其中:

    3. 授與您的應用程式使用 DCR 的權限

公開預覽限制

公開預覽期間有以下限制:

  • 輔助方案會逐漸推出至所有區域,目前支援的地區如下:

    區域 位置
    美洲 加拿大中部
    美國中部
    美國東部
    美國東部 2
    美國西部
    美國中南部
    美國中北部
    亞太地區 澳大利亞東部
    澳大利亞東南部
    歐洲 東亞
    歐洲北部
    英國南部
    德國中西部
    瑞士北部
    法國中部
    中東 以色列中部
  • 您只能在使用資料表 - 建立或更新 API所建立、以資料收集規則為基礎的自訂資料表上設定輔助方案。

  • 使用輔助方案的資料表:

    • 目前不會計費。 擷取、查詢、搜尋作業和長期保留期間目前不收費。
    • 不支援具有動態資料的資料行。
    • 總保留期間固定為 365 天。
    • 僅支援 ISO 8601 日期時間格式。
  • 將資料傳送至使用輔助方案之資料表的資料收集規則:

    • 只能將資料傳送至單一資料表。
    • 不能包含轉換
  • Azure 監視器記錄使用量資料表目前無法擷取輔助資料表的資料。 若要估計資料擷取量,您可以使用下列查詢來計算輔助資料表中的記錄數目:

    MyTable_CL
    | summarize count()
    

下一步

深入了解: