[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-21 UTC。"],[[["\u003cp\u003eThis guide explains how to use Cloud Monitoring to view Firestore in Datastore mode metrics through the Metrics explorer for chart creation.\u003c/p\u003e\n"],["\u003cp\u003eCustom dashboards in Cloud Monitoring can be configured to display specific performance metrics and alerting policies for projects in production environments.\u003c/p\u003e\n"],["\u003cp\u003eMonitoring error rates by calculating the ratio of error responses to total requests helps maintain the database's availability, as defined by the Firestore in Datastore mode SLA.\u003c/p\u003e\n"],["\u003cp\u003eCloud Monitoring enables the creation of alerting policies that send notifications when metric conditions change, such as setting an alert for when p99 latency exceeds 250ms over a 5-minute period.\u003c/p\u003e\n"],["\u003cp\u003eThe same latency alert policy can be created using either the console, or through the use of Monitoring Query Language (MQL).\u003c/p\u003e\n"]]],[],null,["# Use the Cloud Monitoring dashboard\n\nThis page describes how to use the Cloud Monitoring dashboard to view the available metrics, create a custom dashboard, and set alerts.\n\nView Firestore in Datastore mode metrics\n----------------------------------------\n\nTo view the different Firestore in Datastore mode metrics and create charts, use the Metrics explorer within Cloud Monitoring in Google Cloud console. For more information about creating charts, see [Create charts with Metrics Explorer](https://cloud.google.com/monitoring/charts/metrics-explorer).\n\nSet up a Cloud Monitoring dashboard\n-----------------------------------\n\nIn Cloud Monitoring, custom dashboards allow you to display information that is relevant to you in an organized way. For example, you might create a dashboard to display the performance metrics and alerting policies for your project in your production environment.\n\nFor more information about setting up a custom dashboard, see [Manage custom dashboard](https://cloud.google.com/monitoring/charts/dashboards) and [Add dashboard widgets](https://cloud.google.com/monitoring/charts).\n\n#### Monitor error rates\n\nYou can create a monitoring dashboard to monitor error rates and ensure availability of your database.\nAvailability refers to the rate at which your database responds within an expected timeframe with a successful status code. The [Firestore in Datastore mode SLA](https://cloud.google.com/firestore/sla) defines the specific details of what is classified as a valid request.\n\nThe error rate is determined by dividing the number of requests that resulted in an error response by the total number of requests sent.\n\nAn example dashboard for calculating error rates can be created by calculating the A/B ratio for `api/request_count` of valid requests with `4xx` or `5xx` error codes contrasted with the `api/request_count` of all valid requests.\n[](/static/firestore/native/docs/images/cloudmon-error-rate.png) **Figure 1.** Understand availability with error rate.\n\nIn figure 1, you can see how to visualize the error rate ratio using the **api/request_count** metrics in the Metrics explorer.\n\nCreate an alerting policy\n-------------------------\n\nCloud Monitoring lets you to create [alerts](https://cloud.google.com/monitoring/alerts) to notify you when a change in a metric condition occurs. You can use these alerts to be notified of potential problems before they impact your users.\n\nFor more information about creating alerts, see [Create metric-threshold alerting policies](https://cloud.google.com/monitoring/alerts/using-alerting-ui).\n\nConsider the following example where we create a latency alert policy. The\nalerting policy checks p99 latency over a 5 minute rolling window. If the p99 latency stays higher than 250ms for 5 minutes, the alert is triggered. \n\n### Console\n\n1. In the Google Cloud console, go to the **Monitoring** page then select\n *notifications* **Alerting**.\n\n [Go to Monitoring](https://console.cloud.google.com/monitoring/alerting)\n2. Select **Create policy**.\n\n3. Select the **Request Latencies** metric from the **Consumed API** resource.\n\n4. Add a service filter for `datastore.googleapis.com`. The `api/request_latencies` metric is monitored over the 5 min rolling window.\n\n [](/static/firestore/native/docs/images/cloudmon-dashboard-latencies.png) **Figure 2.** Select the api/request_latencies metric to create trigger.\n5. Click **Next** to configure the trigger.\n\n6. Select the **Condition Types** as **Threshold**.\n\n A threshold condition is set to a threshold value of 250ms. An alert is triggered when the p99 latency value stays the same for the entire period of the rolling window (5 min).\n [](/static/firestore/native/docs/images/cloudmon-dashboard-alerts.png) **Figure 3.** Add the threshold for the metric.\n7. Set the **Threshold value** as **250**.\n\n8. Click **Next** to configure notifications.\n\n9. Set the alert policy name and click **Next**.\n\n10. Review the alert configurations and click **Create Policy**.\n\n### MQL\n\nYou can implement the same latency alert policy using a Monitoring Query Language (MQL) query. For more examples of using MQL, see [Sample MQL queries](https://cloud.google.com/monitoring/mql/examples). \n\n fetch consumed_api\n | metric 'serviceruntime.googleapis.com/api/request_latencies'\n | filter (resource.service == 'firestore.googleapis.com')\n | group_by 5m,\n [value_request_latencies_percentile:\n percentile(value.request_latencies, 99)]\n | every 5m\n | condition val() \u003e 0.25 's'"]]