將資料從 Windows Azure 診斷延伸模組傳送至 Azure 事件中樞

Azure 診斷擴充功能是 Azure 監視器中的代理程式,可收集來自客體作業系統的監視資料,以及 Azure 虛擬機器和其他計算資源的工作負載。 本文說明如何將資料從 Windows Azure 診斷延伸模組 (WAD) 傳送至 Azure 事件中樞,以便轉送至 Azure 外部位置。

支援的資料

從客體作業系統收集的資料可以傳送至事件中樞,包括下列內容。 WAD 收集的其他資料來源 (包括 IIS 記錄和損毀傾印) 無法傳送至事件中樞。

  • Windows 事件追蹤 (ETW) 事件
  • 效能計數器
  • Windows 事件記錄檔,包括 Windows 事件記錄檔中的應用程式記錄檔
  • Azure 診斷基礎結構記錄

必要條件

設定結構描述

針對啟用和設定診斷延伸模組的不同選項,請參閱安裝和設定 Windows Azure 診斷延伸模組 (WAD),而針對設定結構描述的參考,則請參閱 Azure 診斷設定結構描述。 本文的其餘部分將說明如何使用此設定將資料傳送至事件中樞。

Azure 診斷一律會將記錄和計量傳送至 Azure 儲存體帳戶。 您可以設定一或多個將資料傳送至其他位置的「資料接收器」。 每個接收器都會在公用設定的 SinksConfig 元素中定義,並在私人設定中使用敏感性資訊。 此事件中樞的設定會使用下表中的值。

屬性 描述
Name 接收器的描述性名稱。 在設定中,用於指定要傳送至接收器的資料來源。
Url 事件中樞的 URL,格式為 <event-hubs-namespace>.servicebus.windows.net/<event-hub-name>。
SharedAccessKeyName 至少具有傳送授權單位事件中樞的共用存取原則名稱。
SharedAccessKey 來自事件中樞其共用存取原則的主要或次要金鑰。

公用和私人設定範例如下所示。 這是具有單一效能計數器和事件記錄檔的最低設定,說明如何設定及使用事件中樞資料接收器。 如需更複雜的範例,請參閱 Azure 診斷設定結構描述

公用組態

{
    "WadCfg": {
        "DiagnosticMonitorConfiguration": {
            "overallQuotaInMB": 5120,
            "PerformanceCounters": {
                "scheduledTransferPeriod": "PT1M",
                "sinks": "myEventHub",
                "PerformanceCounterConfiguration": [
                    {
                        "counterSpecifier": "\\Processor(_Total)\\% Processor Time",
                        "sampleRate": "PT3M"
                    }
                ]
            },
            "WindowsEventLog": {
                "scheduledTransferPeriod": "PT1M",
                "sinks": "myEventHub",
                    "DataSource": [
                    {
                        "name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
                    }
                ]
            }
        },
        "SinksConfig": {
            "Sink": [
                {
                    "name": "myEventHub",
                    "EventHub": {
                        "Url": "https://diags-mycompany-ns.servicebus.windows.net/diageventhub",
                        "SharedAccessKeyName": "SendRule"
                    }
                }
            ]
        }
    },
    "StorageAccount": "mystorageaccount",
}

私人組態

{
    "storageAccountName": "mystorageaccount",
    "storageAccountKey": "{base64 encoded key}",
    "storageAccountEndPoint": "https://core.windows.net",
    "EventHub": {
        "Url": "https://diags-mycompany-ns.servicebus.windows.net/diageventhub",
        "SharedAccessKeyName": "SendRule",
        "SharedAccessKey": "{base64 encoded key}"
    }
}

設定選項

若要將資料傳送至資料接收器,您可以在資料來源的節點上指定接收器屬性。 指派範圍會由放置接收器屬性的位置決定。 在下列範例中,接收器屬性會定義至 PerformanceCounters 節點,這會導致所有子效能計數器傳送至事件中樞。

"PerformanceCounters": {
    "scheduledTransferPeriod": "PT1M",
    "sinks": "MyEventHub",
    "PerformanceCounterConfiguration": [
        {
            "counterSpecifier": "\\Processor(_Total)\\% Processor Time",
            "sampleRate": "PT3M"
        },
        {
            "counterSpecifier": "\\Memory\\Available MBytes",
            "sampleRate": "PT3M"
        },
        {
            "counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
            "sampleRate": "PT3M"
        }
    ]
}

在下列範例中,接收器屬性會直接套用至三個計數器,導致只將這些效能計數器傳送至事件中樞。

"PerformanceCounters": {
    "scheduledTransferPeriod": "PT1M",
    "PerformanceCounterConfiguration": [
        {
            "counterSpecifier": "\\Processor(_Total)\\% Processor Time",
            "sampleRate": "PT3M",
            "sinks": "MyEventHub"
        },
        {
            "counterSpecifier": "\\Memory\\Available MBytes",
            "sampleRate": "PT3M"
        },
        {
            "counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
            "sampleRate": "PT3M"
        },
        {
            "counterSpecifier": "\\ASP.NET\\Requests Rejected",
            "sampleRate": "PT3M",
            "sinks": "MyEventHub"
        },
        {
            "counterSpecifier": "\\ASP.NET\\Requests Queued",
            "sampleRate": "PT3M",
            "sinks": "MyEventHub"
        }
    ]
}

正在驗證設定

您可以使用各種方法來驗證資料是否傳送至事件中樞。 有個簡單的方法便是使用事件中樞擷取,如透過 Azure Blob 儲存體或 Azure Data Lake Storage 的 Azure 事件中樞擷取事件中所述。

針對事件中樞接收進行疑難排解

  • 請查看 Azure 儲存體資料表 WADDiagnosticInfrastructureLogsTable,其中包含記錄和 Azure 診斷本身的錯誤。 其中一個選項是使用類似 Azure 儲存體總管 的工具連接到此儲存體帳戶、檢視此資料表,並且新增過去 24 小時內時間戳記的查詢。 您可以使用此工具來匯出 .csv 檔案,並在 Microsoft Excel 之類的應用程式中開啟。 Excel 能輕鬆地搜尋電話卡字串 (如 EventHubs),以便查看系統回報了哪些錯誤。

  • 檢查已成功佈建您的事件中樞。 設定中 PrivateConfig 區段的所有連接資訊必須符合在入口網站中所示的資源值。 請確定您已在入口網站中定義 SAS 原則 (此範例中為 SendRule),且對其授與「傳送」權限。

下一步