在 Azure 中设计和生成管理解决方案(预览)Design and build a management solution in Azure (Preview)

备注

这是在 Azure 中创建管理解决方案(当前处于预览状态)的初步文档。This is preliminary documentation for creating management solutions in Azure which are currently in preview. 如下所述的全部架构均会有变动。Any schema described below is subject to change.

管理解决方案提供打包的管理方案,客户可将其添加到 Log Analytics 工作区。Management solutions provide packaged management scenarios that customers can add to their Log Analytics workspace. 本文提供了一个基本的流程,方便用户设计和生成符合最常见要求的管理解决方案。This article presents a basic process to design and build a management solution that is suitable for most common requirements. 如果不了解如何生成管理解决方案,则可一开始就使用此流程,并在要求提高以后利用相关概念生成更复杂的解决方案。If you are new to building management solutions then you can use this process as a starting point and then leverage the concepts for more complex solutions as your requirements evolve.

管理解决方案是什么?What is a management solution?

管理解决方案包含可协同工作以实现特定管理方案的 Azure 资源。Management solutions contain Azure resources that work together to achieve a particular management scenario. 并且可以作为资源管理模板来实现。此类模板包含说明,详述了在安装解决方案时如何安装和配置模板中包含的资源。They are implemented as Resource Management templates that contain details of how to install and configure their contained resources when the solution is installed.

基本策略是通过在 Azure 环境中生成各个组件来启动管理解决方案。The basic strategy is to start your management solution by building the individual components in your Azure environment. 功能正常以后,即可将其打包到管理解决方案文件中。Once you have the functionality working properly, then you can start packaging them into a management solution file.

设计解决方案Design your solution

管理解决方案的最常见模式如下图所示。The most common pattern for a management solution is shown in the following diagram. 下面介绍了此模式中的不同组件。The different components in this pattern are discussed in the below.

管理解决方案概述

数据源Data sources

设计解决方案的第一步是确定需要从 Log Analytics 存储库获取的数据。The first step in designing a solution is determining the data that you require from the Log Analytics repository. 可以通过数据源其他解决方案收集此类数据,否则就必须在解决方案中提供其收集过程。This data may be collected by a data source or another solution, or your solution may need to provide the process to collect it.

可以通过多种方式在 Log Analytics 存储库中收集数据源,详见 Log Analytics 中的数据源There are a number of ways data sources that can be collected in the Log Analytics repository as described in Data sources in Log Analytics. 可以收集 Windows 事件日志中的事件,或者收集由 Windows 和 Linux 客户端的 Syslog 和性能计数器生成的事件。This includes events in the Windows Event Log or generated by Syslog in addition to performance counters for both Windows and Linux clients. 此外,还可以收集通过 Azure Monitor 收集的 Azure 资源中的数据。You can also gather data from Azure resources collected by Azure Monitor.

如果所需数据无法通过任何可用的数据源进行访问,则可通过任何能够调用 REST API 的客户端,使用 HTTP 数据收集器 API 将数据写入 Log Analytics 存储库。If you require data that's not accessible through any of the available data sources, then you can use the HTTP Data Collector API which allows you to write data to the Log Analytics repository from any client that can call a REST API. 在管理解决方案中自定义数据收集时,最常见的方式是创建 Azure 自动化中的 runbook,以便从 Azure 或外部资源收集所需数据,并使用数据收集器 API 将数据写入存储库。The most common means of custom data collection in a management solution is to create a runbook in Azure Automation that collects the required data from Azure or external resources and uses the Data Collector API to write to the repository.

日志搜索Log searches

日志搜索用于提取和分析 Log Analytics 存储库中的数据。Log searches are used to extract and analyze data in the Log Analytics repository. 视图和警报可以使用日志搜索,用户也可以使用日志搜索对存储库中的数据进行临时分析。They are used by views and alerts in addition to allowing the user to perform ad hoc analysis of data in the repository.

如果认为某些查询对用户有用,则应定义这些查询,即使视图或警报不使用这些查询。You should define any queries that you think will be helpful to the user even if they aren't used by any views or alerts. 这些查询会在门户中以“保存的搜索”形式提供给用户,也可将其添加到自定义视图的“查询列表”可视化效果部件These will be available to them as Saved Searches in the portal, and you can also include them in a List of Queries visualization part in your custom view.

警报Alerts

Log Analytics 中的警报通过日志搜索来搜索存储库中的数据,从而确定问题。Alerts in Log Analytics identify issues through log searches against the data in the repository. 警报会通知用户,或者自动运行某个操作作为响应。They either notify the user or automatically run an action in response. 应该为应用程序确定不同的警报条件,并且让相应的警报规则包括在解决方案文件中。You should identify different alert conditions for your application and include corresponding alert rules in your solution file.

如果有可能通过自动化过程纠正问题,则通常应在 Azure 自动化中创建一个 runbook 来执行该纠正操作。If the issue can potentially be corrected with an automated process, then you'll typically create a runbook in Azure Automation to perform this remediation. 大多数 Azure 服务可以通过 cmdlet 进行管理,runbook 也可以利用后者来执行此类功能。Most Azure services can be managed with cmdlets which the runbook would leverage to perform such functionality.

如果解决方案需要外部功能来响应警报,则可使用 webhook 响应If your solution requires external functionality in response to an alert, then you can use a webhook response. 以便调用外部 Web 服务,发送警报中的信息。This allows you to call an external web service sending information from the alert.

视图Views

Log Analytics 中的视图用于可视化 Log Analytics 存储库中的数据。Views in Log Analytics are used to visualize data from the Log Analytics repository. 每个解决方案通常会包含一个视图,其中的磁贴会显示在用户的主仪表板上。Each solution will typically contain a single view with a tile that is displayed on the user's main dashboard. 该视图可以包含任意数目的可视化效果部件,为用户提供所收集数据的不同可视化效果。The view can contain any number of visualization parts to provide different visualizations of the collected data to the user.

可以使用视图设计器创建自定义视图,随后再导出这些视图,将其添加到解决方案文件中。You create custom views using the View Designer which you can later export for inclusion in your solution file.

创建解决方案文件Create solution file

配置并测试将要成为解决方案一部分的组件以后,即可创建解决方案文件Once you've configured and tested the components that will be part of your solution, you can create your solution file. 可在 Resource Manager 模板中实现解决方案组件。该模板包含一个与文件中的其他资源存在多项关系的解决方案资源You will implement the solution components in a Resource Manager template that includes a solution resource with relationships to the other resources in the file.

测试解决方案Test your solution

开发解决方案时,需将其安装在工作区并进行测试。While you are developing your solution, you will need to install and test it in your workspace. 为此,可以使用任何可用方法来测试和安装 Resource Manager 模板You can do this using any of the available methods to test and install Resource Manager templates.

发布解决方案Publish your solution

完成解决方案并进行测试以后,即可通过以下某种方式将其提供给客户。Once you have completed and tested your solution, you can make it available to customers through either the following sources.

  • Azure 快速入门模板Azure Quickstart templates. Azure 快速入门模板是一套 Resource Manager 模板,由社区通过 GitHub 提供。Azure Quickstart templates is a set of Resource Manager templates contributed by the community through GitHub. 可以按贡献指南中的说明提供解决方案。You can make your solution available by following information in the contribution guide.
  • Azure 市场Azure Marketplace. 可以通过 Azure 市场将解决方案分发和销售给其他开发人员、ISV 和 IT 专业人员。The Azure Marketplace allows you to distribute and sell your solution to other developers, ISVs, and IT professionals.

后续步骤Next steps