Log Analytics 与 Power BI 的集成Log Analytics integration with Power BI

本文重点介绍了如何将数据从 Log Analytics 馈送到 Power BI,以创建在视觉上更具吸引力的报表和仪表板。This article focuses on ways to feed data from Log Analytics into Power BI to create more visually appealing reports and dashboards.

背景Background

Azure Monitor 日志是为日志引入提供端到端解决方案的平台。Azure Monitor Logs is a platform that provides an end-to-end solution for ingesting logs. Azure Monitor Log Analytics 是用于查询这些日志的界面。Azure Monitor Log Analytics is the interface to query these logs. 若要详细了解包括 Log Analytics 在内的整个 Azure Monitor 数据平台,请参阅 Azure Monitor 数据平台For more information on the entire Azure Monitor data platform including Log Analytics, see Azure Monitor data platform.

Power BI 是 Microsoft 的数据可视化平台。Power BI is Microsoft’s data visualization platform. 有关如何入门的详细信息,请参阅 Power BI 的主页For more information on how to get started, see Power BI’s homepage.

通常,你可以使用免费的 Power BI 功能来集成和创建在视觉上具有吸引力的报表和仪表板。In general, you can use free Power BI features to integrate and create visually appealing reports and dashboards.

若要使用更高级的功能,可能需要购买 Power BI Pro 或高级帐户。More advanced features may require purchasing a Power BI Pro or premium account. 这些功能包括:These features include:

  • 共享你的工作sharing your work
  • 计划的刷新scheduled refreshes
  • Power BI 应用Power BI apps
  • 数据流和增量刷新dataflows and incremental refresh

有关详细信息,请参阅详细了解 Power BI 定价和功能For more information, see learn more about Power BI pricing and features

集成查询Integrating queries

Power BI 使用 M 查询语言作为其主要查询语言。Power BI uses the M query language as its main querying language.

Log Analytics 查询可以导出到 M 并直接在 Power BI 中使用。Log Analytics queries can be exported to M and used in Power BI directly. 运行成功的查询后,从 Log Analytics UI 顶部操作栏的“导出”按钮中选择“导出到 Power BI (M 查询)”。 After running a successful query, select the Export to Power BI (M query) from the Export button in Log Analytics UI top action bar.

显示了导出选项菜单下拉列表的 Log Analytics 查询

Log Analytics 会创建一个 .txt 文件,其中包含可以直接在 Power BI 中使用的 M 代码。Log Analytics creates a .txt file containing the M code that can be used directly in Power BI.

将日志连接到数据集Connecting your logs to a dataset

Power BI 数据集是已就绪的可用于报告和可视化效果的数据源。A Power BI dataset is a source of data ready for reporting and visualization. 若要将 Log Analytics 查询连接到数据集,请在 Power BI 中将从 Log Analytics 导出的 M 代码复制到空白查询中。To connect a Log Analytics query to a dataset, copy the M code exported from Log Analytics into a blank query in Power BI.

有关详细信息,请参阅了解 Power BI 数据集For more information, see Understanding Power BI datasets.

使用 Power BI 数据流收集数据Collect data with Power BI dataflows

Power BI 数据流还允许收集和存储数据。Power BI dataflows also allow you to collect and store data. 有关详细信息,请参阅 Power BI 数据流For more information, see Power BI Dataflows.

数据流是一种“云 ETL”,旨在帮助你收集和准备数据。A dataflow is a type of "cloud ETL" designed to help you collect and prep your data. 数据集是“模型”,旨在帮助你连接不同的实体并根据你的需求对其进行建模。A dataset is the "model" designed to help you connect different entities and model them for your needs.

增量刷新Incremental refresh

Power BI 数据集和 Power BI 数据流都有增量刷新选项。Both Power BI datasets and Power BI dataflows have an incremental refresh option. Power BI 数据流和 Power BI 数据集支持此功能,但你需要 Power BI Premium 才能使用此功能。Power BI dataflows and Power BI datasets support this feature, but you need Power BI Premium to use it.

增量刷新运行小型查询,每次运行只更新较少的数据量,而不是在运行查询时一次又一次引入所有数据。Incremental refresh runs small queries and updates smaller amounts of data per run instead of ingesting all of the data again and again when you run the query. 你可以选择保存大量数据,但每次运行查询时会添加新的增量数据。You have the option to save large amounts of data, but add a new increment of data every time the query is run. 此行为非常适合运行时间较长的报表。This behavior is ideal for longer running reports.

Power BI 增量刷新依赖于结果集中存在的日期/时间字段。Power BI incremental refresh relies on the existence of a datetime filed in the result set. 在配置增量刷新之前,请确保 Log Analytics 查询结果集包含至少一个日期/时间字段。Before configuring incremental refresh, make sure your Log Analytics query result set includes at least one datetime filed.

有关增量刷新配置方面的详细信息和具体方法,请参阅 Power BI 数据集和增量刷新Power BI 数据流和增量刷新To learn more and how to configure incremental refresh, see Power BI Datasets and Incremental refresh and Power BI dataflows and incremental refresh.

报表和仪表板卡Reports and dashboards

将数据发送到 Power BI 后,你可以继续使用 Power BI 来创建报表和仪表板。After your data is sent to Power BI, you can continue to use Power BI to create reports and dashboards.

有关详细信息,请参阅有关如何创建你的第一个 Power BI 模型和报表的此指南For more information, see this guide on how to create your first Power BI model and report.

Excel 集成Excel integration

你可以使用 Power BI 中使用的 M 集成来与 Excel 电子表格集成。You can use the same M integration used in Power BI to integrate with an Excel spreadsheet. 有关详细信息,请参阅有关如何与 Excel 集成的此指南,然后粘贴从 Log Analytics 导出的 M 查询。For more information, see this guide on how to integrate with excel and then paste the M query exported from Log Analytics.

有关其他信息,可参阅集成 Log Analytics 和 ExcelAdditional information can be found in Integrate Log Analytics and Excel

后续步骤Next steps

开始使用 Log Analytics 查询Get started with Log Analytics queries.