共用方式為


使用 Power BI 建立自訂報告

注意事項

如果您是美國政府客戶,請使用 適用於端點的 Microsoft Defender for US Government 客戶中列出的 URI。

提示

為了提升效能,請使用離地理位置較近的伺服器:

  • us.api.security.microsoft.com
  • eu.api.security.microsoft.com
  • uk.api.security.microsoft.com
  • au.api.security.microsoft.com
  • swa.api.security.microsoft.com
  • ina.api.security.microsoft.com
  • aea.api.security.microsoft.com

在本節中,你會學習如何在 Defender for Endpoint API 之上建立 Power BI 報告。

第一個範例示範如何將 Power BI 連接到 Advanced Hunting API,第二個範例則展示與我們的 OData API,如機器動作或警示的連結。

將 Power BI 連接到進階狩獵 API

  1. 開啟 Microsoft Power BI。

  2. 選擇 「取得資料>空白查詢」。

    在「取得資料」選單項目下的空白查詢選項

  3. 選擇進階編輯器

    進階編輯器選單項目

  4. 複製下面的程式碼片段並貼上到編輯器中:

        let
            AdvancedHuntingQuery = "DeviceEvents | where ActionType contains 'Anti' | limit 20",
    
            HuntingUrl = "https://api.securitycenter.microsoft.com/api/advancedqueries",
    
            Response = Json.Document(Web.Contents(HuntingUrl, [Query=[key=AdvancedHuntingQuery]])),
    
            TypeMap = #table(
                { "Type", "PowerBiType" },
                {
                    { "Double",   Double.Type },
                    { "Int64",    Int64.Type },
                    { "Int32",    Int32.Type },
                    { "Int16",    Int16.Type },
                    { "UInt64",   Number.Type },
                    { "UInt32",   Number.Type },
                    { "UInt16",   Number.Type },
                    { "Byte",     Byte.Type },
                    { "Single",   Single.Type },
                    { "Decimal",  Decimal.Type },
                    { "TimeSpan", Duration.Type },
                    { "DateTime", DateTimeZone.Type },
                    { "String",   Text.Type },
                    { "Boolean",  Logical.Type },
                    { "SByte",    Logical.Type },
                    { "Guid",     Text.Type }
                }),
    
            Schema = Table.FromRecords(Response[Schema]),
            TypedSchema = Table.Join(Table.SelectColumns(Schema, {"Name", "Type"}), {"Type"}, TypeMap , {"Type"}),
            Results = Response[Results],
            Rows = Table.FromRecords(Results, Schema[Name]),
            Table = Table.TransformColumnTypes(Rows, Table.ToList(TypedSchema, (c) => {c{0}, c{2}}))
    
        in Table
    
  5. 選取 [完成]

  6. 選擇 編輯憑證

    編輯憑證選單項目

  7. 選擇 組織帳戶>登入

    組織帳戶選單中的登入選項

  8. 輸入你的憑證,等待登入。

  9. 選擇 「連接」。

    組織帳戶選單項目中的登入確認訊息

現在你的查詢結果會以表格形式呈現,你可以開始在上面建立視覺化! 你可以複製這個資料表,重新命名,並編輯裡面的進階狩獵查詢,取得你想要的資料。

Connect Power BI 與 OData API

與前一個範例和這個範例唯一的差別是編輯器內部的查詢。

  1. 開啟 Microsoft Power BI。

  2. 選擇 「取得資料>空白查詢」。

    在「取得資料」選單項目下的空白查詢選項

  3. 選擇進階編輯器

    進階編輯器選單項目

  4. 複製以下程式碼,並貼上到編輯器中,即可從你的組織中拉取所有 機器動作

        let
    
            Query = "MachineActions",
    
            Source = OData.Feed("https://api.securitycenter.microsoft.com/api/" & Query, null, [Implementation="2.0", MoreColumns=true])
        in
            Source
    

    你也可以對 警報機器做同樣的事。 你也可以用 OData 查詢來做查詢篩選。 參見 使用 OData 查詢

GitHub 上的 Power BI 儀表板範例

請參閱 Power BI 報告範本