监视 Azure Cosmos DB 中的性能和存储指标Monitor performance and storage metrics in Azure Cosmos DB

可以在 Azure 门户中监视 Azure Cosmos DB 帐户。You can monitor your Azure Cosmos DB accounts in the Azure portal. 对于每个 Azure Cosmos DB 帐户,一整套指标可用于监视吞吐量、存储、可用性、延迟和一致性。For each Azure Cosmos DB account, a full suite of metrics is available to monitor throughput, storage, availability, latency, and consistency.

可在“帐户”页、新的“指标”页或 Azure Monitor.中查看指标。Metrics can be reviewed on the Account page, the new Metrics page, or in Azure Monitor.

在“指标”页上查看性能指标View performance metrics on the Metrics page

  1. Azure 门户中,单击“所有服务” ,滚动到“数据库” ,单击“Azure Cosmos DB” ,然后单击要查看其性能指标的 Azure Cosmos DB 帐户的名称。In the Azure portal, click All services, scroll to Databases, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to view performance metrics.

  2. 新页加载时,在资源菜单的“监视” 下,单击“指标” 。When the new page loads, in the resource menu, under Monitoring, click Metrics.

  3. “指标”页打开时,从“集合” 下拉列表中选择要查看的集合。When the Metrics page opens, select the collection to review from the Collection(s) drop-down.

    Azure 门户显示了一套可用的集合指标。The Azure portal displays the suite of collection metrics available. 请注意,吞吐量、存储、可用性、延迟和一致性指标在单独的选项卡上提供。Note that throughput, storage, availability, latency, and consistency metrics are provided on separate tabs. 若要获取有关所提供指标的更多详细信息,请单击每个指标窗格右上方的双箭头。To get additional detail on the metrics provided, click on the double-arrow in the top right of each metrics pane.

    显示指标套件的“监视”可重用功能区的屏幕截图

使用 Azure Monitor 查看性能指标View performance metrics by using Azure Monitoring

  1. Azure 门户中,单击左栏中的“监视” 。In the Azure portal, click Monitor on the left bar.
  2. 在资源菜单中,单击“指标” 。In the resource menu, click Metrics.
  3. 在“监视 - 指标” 窗口的“资源组” 下拉菜单中,选择与想要监视的 Azure Cosmos DB 帐户关联的资源组。In the Monitor - Metrics window, in the Resource group drop-down menu, select the resource group associated with the Azure Cosmos DB account that you'd like to monitor.
  4. 在“资源” 下拉菜单中,选择要监视的数据库帐户。In the Resource drop-down menu, select the database account to monitor.
  5. 在“可用指标” 列表中,选择要显示的指标。In the list of Available metrics, select the metrics to display. 使用 Ctrl 按钮进行多选。Use the CTRL button to multi-select.

在“帐户”页上查看性能指标View performance metrics on the account page

  1. Azure 门户中,单击“所有服务” ,滚动到“数据库” ,单击“Azure Cosmos DB” ,然后单击要查看其性能指标的 Azure Cosmos DB 帐户的名称。In the Azure portal, click All services, scroll to Databases, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to view performance metrics.

  2. 默认情况下,“监视”可重用功能区 显示以下磁贴:The Monitoring lens displays the following tiles by default:

    • 当天的请求总数。Total requests for the current day.
    • 使用的存储量。Storage used.

    “监视”可重用功能区的屏幕截图,其中显示请求数和存储使用情况

  3. 单击“请求” 磁贴右上角的双箭头将打开详细的“指标” 页。Clicking on the double-arrow in the top-right of the Requests tile opens a detailed Metric page.

  4. “指标”页显示有关请求总数的详细信息。The Metric page shows you details about the total requests.

在门户中设置警报Set up alerts in the portal

  1. Azure 门户中,依次单击“所有服务” 、“Azure Cosmos DB” ,并单击要设置性能指标警报的 Azure Cosmos DB 帐户的名称。In the Azure portal, click All services, click Azure Cosmos DB, and then click the name of the Azure Cosmos DB account for which you would like to set up performance metric alerts.

  2. 在资源菜单中,单击“警报规则” 打开“警报规则”页。In the resource menu, click Alert Rules to open the Alert rules page.
    所选的警报规则部件的屏幕截图Screenshot of the Alert rules part selected

  3. 在“警报规则” 页中,单击“添加警报” 。In the Alert rules page, click Add alert.
    “添加警报”按钮突出显示的“警报规则”页的屏幕截图Screenshot of the Alert Rules page, with the Add Alert button highlighted

  4. 在“添加警报规则” 页中,指定:In the Add an alert rule page, specify:

    • 正在设置的警报规则的名称。The name of the alert rule you are setting up.
    • 新的警报规则的说明。A description of the new alert rule.
    • 警报规则指标。The metric for the alert rule.
    • 确定何时激活警报的条件、阈值和时间段。The condition, threshold, and period that determine when the alert activates. 例如,在过去的 15 分钟服务器错误计数大于 5。For example, a server error count greater than 5 over the last 15 minutes.
    • 当警报触发时,服务管理员和协同管理员是否会通过电子邮件得到通知。Whether the service administrator and coadministrators are emailed when the alert fires.
    • 警报通知的其他电子邮件地址。Additional email addresses for alert notifications.
      “添加警报规则”页的屏幕截图

以编程方式监视 Azure Cosmos DBMonitor Azure Cosmos DB programmatically

门户中可用的帐户级别指标(如帐户存储使用情况和请求总数)不可通过 SQL API 使用。The account level metrics available in the portal, such as account storage usage and total requests, are not available via the SQL APIs. 但是,可以使用 SQL API 在集合级别检索使用情况数据。However, you can retrieve usage data at the collection level by using the SQL APIs. 若要检索集合级别的数据,请执行以下操作:To retrieve collection level data, do the following:

若要访问其他指标,请使用 Azure Monitor SDKTo access additional metrics, use the Azure Monitor SDK. 可以通过调用以下命令检索可用的指标定义:Available metric definitions can be retrieved by calling:

https://management.chinacloudapi.cn/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/{DocumentDBAccountName}/metricDefinitions?api-version=2015-04-08

用于检索各个指标的查询使用以下格式:Queries to retrieve individual metrics use the following format:

https://management.chinacloudapi.cn/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroup}/providers/Microsoft.DocumentDb/databaseAccounts/{DocumentDBAccountName}/metrics?api-version=2015-04-08&$filter=%28name.value%20eq%20%27Total%20Requests%27%29%20and%20timeGrain%20eq%20duration%27PT5M%27%20and%20startTime%20eq%202016-06-03T03%3A26%3A00.0000000Z%20and%20endTime%20eq%202016-06-10T03%3A26%3A00.0000000Z

有关详细信息,请参阅 通过 Azure Monitor REST API 检索资源指标For more information, see Retrieving Resource Metrics via the Azure Monitor REST API. 请注意,已将“Azure Insights”重命名为“Azure Monitor”。Note that "Azure Insights" was renamed "Azure Monitor". 本博客条目引用旧名称。This blog entry refers to the older name.

后续步骤Next steps

若要深入了解 Azure Cosmos DB 容量规划,请参阅 Azure Cosmos DB Capacity Planner 计算器To learn more about Azure Cosmos DB capacity planning, see the Azure Cosmos DB capacity planner calculator.