使用 Linux Azure 诊断聚合和收集事件Event aggregation and collection using Linux Azure Diagnostics

当你运行 Azure Service Fabric 群集时,最好是从一个中心位置的所有节点中收集日志。When you're running an Azure Service Fabric cluster, it's a good idea to collect the logs from all the nodes in a central location. 将日志放在中心位置可帮助分析和排查群集中的问题,或该群集中运行的应用程序与服务的问题。Having the logs in a central location helps you analyze and troubleshoot issues in your cluster, or issues in the applications and services running in that cluster.

上传和收集日志的方式之一是使用 Linux Azure 诊断 (LAD) 扩展,它可将日志上传到 Azure 存储,并且还提供了将日志发送到事件中心的选项。One way to upload and collect logs is to use the Linux Azure Diagnostics (LAD) extension, which uploads logs to Azure Storage, and also has the option to send logs to Event Hubs.

日志和事件源Log and event sources

Service Fabric 平台事件Service Fabric platform events

Service Fabric 通过 LTTng 发出几个现成可用的日志,包括操作事件或运行时事件。Service Fabric emits a few out-of-the-box logs via LTTng, including operational events or runtime events. 这些日志存储在群集的资源管理器模板指定的位置。These logs are stored in the location that the cluster's Resource Manager template specifies. 若要获取或设置存储帐户详细信息,请搜索 AzureTableWinFabETWQueryable 标记,然后查找 StoreConnectionString 。To get or set the storage account details, search for the tag AzureTableWinFabETWQueryable and look for StoreConnectionString.

应用程序事件Application events

检测软件时,事件按指定从应用程序和服务的代码中发出。Events emitted from your applications' and services' code as specified by you when instrumenting your software. 可以使用任何能够写入基于文本的日志的日志记录解决方案,例如 LTTng。You can use any logging solution that writes text-based log files--for example, LTTng. 有关详细信息,请参阅有关跟踪应用程序的 LTTng 文档。For more information, see the LTTng documentation on tracing your application.

在本地计算机开发安装过程中监视和诊断服务Monitor and diagnose services in a local machine development setup.

部署诊断扩展Deploy the Diagnostics extension

收集日志的第一个步骤是将诊断扩展部署在 Service Fabric 群集的每个 VM 上。The first step in collecting logs is to deploy the Diagnostics extension on each of the VMs in the Service Fabric cluster. 诊断扩展将收集每个 VM 上的日志,并将它们上传到指定的存储帐户。The Diagnostics extension collects logs on each VM and uploads them to the storage account that you specify.

要在创建群集期间将诊断扩展部署到群集中的 VM,请将“诊断”设置为“打开”。To deploy the Diagnostics extension to the VMs in the cluster as part of cluster creation, set Diagnostics to On. 创建群集后,无法使用门户更改此设置,因此,必须在资源管理器模板中进行相应更改。After you create the cluster, you can't change this setting by using the portal, so you will have to make the appropriate changes in the Resource Manager template.

这将配置 LAD 代理来监视指定的日志文件。This configures the LAD agent to monitor specified log files. 每当在文件中追加新行时,该代理都会创建一个 syslog 条目并将其发送到指定的存储(表)。Whenever a new line is appended to the file, it creates a syslog entry that is sent to the storage (table) that you specified.

后续步骤Next steps

  1. 若要更详细了解在排查问题时应检查哪些事件,请参阅 LTTng 文档使用 LADTo understand in more detail what events you should examine while troubleshooting issues, see LTTng documentation and Using LAD.