监视 Azure 认知搜索的操作和活动Monitor operations and activity of Azure Cognitive Search

本文概述了针对 Azure 认知搜索的监视概念和工具。This article is an overview of monitoring concepts and tools for Azure Cognitive Search. 若要进行全面的监视,可以将内置功能和 Azure Monitor 等附加服务结合使用。For holistic monitoring, you can use a combination of built-in functionality and add-on services like Azure Monitor.

总的来说,你可以跟踪以下内容:Altogether, you can track the following:

  • 服务:运行状况/可用性和对服务配置的更改。Service: health/availability and changes to service configuration.
  • 存储:已用和可用空间,包含每种内容类型相对于服务层允许的配额的计数。Storage: both used and available, with counts for each content type relative to the quota allowed for the service tier.
  • 查询活动:查询量、延迟和受限或已删除的查询。Query activity: volume, latency, and throttled or dropped queries. 记录的查询请求需要使用 Azure MonitorLogged query requests require Azure Monitor.
  • 索引活动:需要使用 Azure Monitor 进行诊断日志记录Indexing activity: requires diagnostic logging with Azure Monitor.

搜索服务不支持按用户进行身份验证,因此在日志中找不到标识信息。A search service does not support per-user authentication, so no identity information will be found in the logs.

内置监视Built-in monitoring

内置监视是指由搜索服务记录的活动。Built-in monitoring refers to activities that are logged by a search service. 除了诊断外,此监视级别无需进行任何配置。With the exception of diagnostics, no configuration is required for this level of monitoring.

Azure 认知搜索按照连续 30 天的计划维护内部数据,以便报告服务运行状况和查询指标,你可以在门户中或通过这些 REST API 找到相关信息。Azure Cognitive Search maintains internal data on a rolling 30-day schedule for reporting on service health and query metrics, which you can find in the portal or through these REST APIs.

以下屏幕截图可帮助你在门户中找到监视信息。The following screenshot helps you locate monitoring information in the portal. 开始使用服务后,数据便可供使用。Data becomes available as soon as you start using the service. 门户页面每隔几分钟刷新一次。Portal pages are refreshed every few minutes.

  • 主概述页上的“监视”选项卡显示查询量、延迟以及服务是否面临压力。Monitoring tab, on the main Overview page, shows query volume, latency, and whether the service is under pressure.
  • 左侧导航窗格中的“活动日志”已连接到 Azure 资源管理器。Activity log, in the left navigation pane, is connected to Azure Resource Manager. 活动日志报告资源管理器未执行的操作:服务可用性和状态、对容量(副本和分区)的更改以及与 API 密钥相关的活动。The activity log reports on actions undertaken by Resource Manager: service availability and status, changes to capacity (replicas and partitions), and API key-related activities.
  • 下方的“监视”设置提供可配置的警报、指标和诊断日志。Monitoring settings, further down, provides configurable alerts, metrics, and diagnostic logs. 可按需创建这些内容。Create these when you need them. 收集并存储数据后,可以查询或可视化信息以获取见解。Once data is collected and stored, you can query or visualize the information for insights.

搜索服务中的 Azure Monitor 集成Azure Monitor integration in a search service

备注

由于门户页面每隔几分钟便会刷新一次,门户中报告的数字是近似值,旨在让你大致了解系统为请求提供服务时的表现。Because portal pages are refreshed every few minutes, the numbers reported are approximate, intended to give you a general sense of how well your system is servicing requests. 实际指标(例如每秒查询数 (QPS))可能高于或低于页面上显示的数字。Actual metrics, such as queries per second (QPS) may be higher or lower than the number shown on the page. 如果要求精度,请考虑使用 API。If precision is a requirement, consider using APIs.

有助于进行监视的 APIAPIs useful for monitoring

可以使用以下 API 检索门户中的“监视”和“使用情况”选项卡中找到的相同信息。You can use the following APIs to retrieve the same information found in the Monitoring and Usage tabs in the portal.

活动日志和服务运行状况Activity logs and service health

门户中的“活动日志”页从 Azure 资源管理器收集信息,并报告服务运行状况的更改。The Activity log page in the portal collects information from Azure Resource Manager and reports on changes to service health. 可以监视活动日志来了解服务运行状况相关的严重、错误和警告状态。You can monitor the activity log for critical, error, and warning conditions related to service health.

常见条目包括对 API 密钥的引用 - 一般信息通知,如“获取管理密钥”和“获取查询密钥” 。Common entries include references to API keys - generic informational notifications like Get Admin Key and Get Query keys. 这些活动指示使用管理密钥(创建或删除对象)或查询密钥发出的请求,但不显示请求本身。These activities indicate requests that were made using the admin key (create or delete objects) or query key, but do not show the request itself. 如需这种粒度的信息,必须配置诊断日志记录。For information of this grain, you must configure diagnostic logging.

可以通过左侧导航窗格、顶部窗口命令栏中的“通知”或者“诊断并解决问题”页访问活动日志You can access the Activity log from the left-navigation pane, or from Notifications in the top window command bar, or from the Diagnose and solve problems page.

在“使用情况”选项卡中监视存储Monitor storage in the Usage tab

门户中的“使用情况”选项卡相对于服务层级施加的当前限制显示资源可用性让你直观地进行监视。For visual monitoring in the portal, the Usage tab shows you resource availability relative to current limits imposed by the service tier. 对于将哪个层用于生产工作负荷或是否要调整活动副本和分区的数目这样的问题,可以根据这些指标进行最终决策,因为这些指标会显示资源的消耗速度,以及当前配置处理现有负载的有效程度。If you are finalizing decisions about which tier to use for production workloads, or whether to adjust the number of active replicas and partitions, these metrics can help you with those decisions by showing you how quickly resources are consumed and how well the current configuration handles the existing load.

下图描述免费服务的情况,该服务的上限是每个类型 3 个对象,最大存储为 50 MB。The following illustration is for the free service, which is capped at 3 objects of each type and 50 MB of storage. “基本”或“标准”服务的限制更高,在增加分区计数的情况下,最大存储会按比例增大。A Basic or Standard service has higher limits, and if you increase the partition counts, maximum storage goes up proportionally.

相对于层级限制的使用状态Usage status relative to tier limits

备注

目前不提供存储相关的警报;存储消耗量不会聚合或记录到 Azure Monitor 的 AzureMetrics 表中。Alerts related to storage are not currently available; storage consumption is not aggregated or logged into the AzureMetrics table in Azure Monitor. 要获取存储警告,需要生成自定义解决方案,用于发出资源相关的通知,代码可在其中检查存储大小并处理响应。To get storage alerts, you would need to build a custom solution that emits resource-related notifications, where your code checks for storage size and handles the response.

使用 Azure Monitor 进行更多监视Add-on monitoring with Azure Monitor

许多服务(包括 Azure 认知搜索)通过与 Azure Monitor 集成来提供更多警报、指标和日志记录诊断数据。Many services, including Azure Cognitive Search, integrate with Azure Monitor for additional alerts, metrics, and logging diagnostic data.

若要控制数据收集和存储,请为搜索服务启用诊断日志记录Enable diagnostic logging for a search service if you want control over data collection and storage. Azure Monitor 捕获的已记录事件存储在 AzureDiagnostics 表中,其中包含与查询和编制索引相关的操作数据。Logged events captured by Azure Monitor are stored in the AzureDiagnostics table and consists of operational data related to queries and indexing.

Azure Monitor 提供多个存储选项,你的选择将决定你如何使用数据:Azure Monitor provides several storage options, and your choice determines how you can consume the data:

  • 如果想要通过 Kusto 查询浏览数据,请选择“Log Analytics”。Choose Log Analytics if you want to explore data through Kusto queries.

Azure Monitor 具有其自己的计费结构,此部分中引用的诊断日志具有相关的成本。Azure Monitor has its own billing structure and the diagnostic logs referenced in this section have an associated cost. 有关详细信息,请参阅在 Azure Monitor 中监视使用情况和预估成本For more information, see Usage and estimated costs in Azure Monitor.

监视用户的访问Monitor user access

由于搜索索引是较大客户端应用程序的一个组件,因此,没有任何内置方法可用于控制或监视每个用户对索引的访问。Because search indexes are a component of a larger client application, there is no built-in methodology for controlling or monitoring per-user access to an index. 对于管理请求或查询请求,假设请求来自客户端应用程序。Requests are assumed to come from a client application, for either admin or query requests. 管理读写操作包括在整个服务中创建、更新和删除对象。Admin read-write operations include creating, updating, deleting objects across the entire service. 只读操作是针对文档集合运行的查询,范围限定为单个索引。Read-only operations are queries against the documents collection, scoped to a single index.

因此,活动日志中显示的内容是对使用管理密钥或查询密钥的调用的引用。As such, what you'll see in the activity logs are references to calls using admin keys or query keys. 相应的密钥包含在源自客户端代码的请求中。The appropriate key is included in requests originating from client code. 服务中未配备用于处理标识令牌或模拟的功能。The service is not equipped to handle identity tokens or impersonation.

确实存在按用户授权的业务要求时,建议与 Azure Active Directory 集成。When business requirements do exist for per-user authorization, the recommendation is integration with Azure Active Directory. 可以使用 $filter 和用户标识来修整用户不应看到的文档的搜索结果。You can use $filter and user identities to trim search results of documents that a user should not see.

无法单独从包含 $filter 参数的查询字符串记录此信息。There is no way to log this information separately from the query string that includes the $filter parameter. 有关报告查询字符串的详细信息,请参阅监视查询See Monitor queries for details on reporting query strings.

后续步骤Next steps

熟练运用 Azure Monitor 是监督任何 Azure 服务(包括 Azure 认知搜索等资源)的关键所在。Fluency with Azure Monitor is essential for oversight of any Azure service, including resources like Azure Cognitive Search. 如果你不熟悉 Azure Monitor,请花些时间阅读资源相关的文章。If you are not familiar with Azure Monitor, take the time to review articles related to resources. 除教程以外,以下文章也是不错的入门资源。In addition to tutorials, the following article is a good place to start.