Monitoring usage

This page describes how you can monitor your Cloud Firestore usage and spot potential problems in your app. Looking at your app's usage can also give you an idea of what to expect on your bill. Additionally, if something seems off, getting a clear picture of your database's operations can be a helpful troubleshooting tool.

Firebase console

The Firebase console includes a usage dashboard that shows Cloud Firestore reads, writes, and deletes over time.

Go to the Usage page

The Cloud Firestore usage dashboard in the Firebase console.

Google Cloud Platform Console

When you create a Firebase project, you're also creating a project in the Google Cloud Platform (GCP). The App Engine Quotas page in the GCP Console tracks daily Cloud Firestore usage information including reads, writes, index writes, deletes, stored data, and network egress.

Go to the Quotas page

Cloud Firestore usage in the App Engine Quotas page.

Stackdriver Monitoring

Stackdriver Monitoring collects metrics, events, and metadata from GCP products that you can use to create dashboards, charts, and alerts.

Stackdriver Monitoring includes the following Cloud Firestore metrics:

Metric Name Description
Document Reads

The number of successful document reads. You can break this metric down by the type of read: LOOKUP or QUERY.

This metric does not include reads from managed export operations.

Document Writes

The number of successful document writes. You can break the metric down by the type of write: CREATE or UPDATE.

This metric does not include writes from managed import operations.

Document Deletes The number of successful document deletes.
Active Connections

The number of active connections to your database.

Each active mobile and web SDK maintains a single connection, which can be shared across multiple snapshot listeners. The server client libraries create one connection per snapshot listener.

Snapshot Listeners

The number of snapshot listeners across all active connections.

Realtime updates usage

Use the active connections and snapshot listeners metrics to measure your usage of realtime updates.

Let's say a user opens your app on their phone. The app then connects to Cloud Firestore and subscribes to 10 queries. This increases your metrics by 1 active connection and 10 snapshot listeners.

Sampling rate

The Cloud Firestore metrics are sampled every minute, but updates may take up to 4 minutes to show up in your dashboards.

Using these metrics, you can set up a Cloud Firestore dashboard like the following:

Cloud Firestore usage in a Stackdriver Monitoring dashboard.

Complete the steps below to start monitoring Cloud Firestore with Stackdriver Monitoring.

Create a Stackdriver workspace

To monitor Cloud Firestore with Stackdriver Monitoring, you must set up a Stackdriver workspace for your project. A workspace organizes monitoring information from one or more projects. After setting up a workspace, you can create custom dashboards and alerting policies.

Skip these steps if your project is already part of a workspace.

  1. Create a Workspace from the Stackdriver Console

    Enter your GCP project ID and click Create workspace.

  2. Optionally, select additional projects to monitor in the same workspace. Click Continue.

  3. Skip the steps to Add AWS accounts and Install Stackdriver agents. These steps are not required to monitor Cloud Firestore. Click Continue.

  4. Configure your preference for email reports. Click Continue.

  5. Click Launch Monitoring.

Create a dashboard and add a chart

Display the Cloud Firestore metrics collected from Stackdriver Monitoring in your own charts and dashboards.

Before you proceed, make sure your project is part of a Stackdriver workspace.

  1. In the Stackdriver Console, open your workspace and go to Dashboards > Create dashboard.

    Go to the Create Dashboard page

  2. In the upper-right hand corner, click Add Chart.

  3. In the Add Chart window, click the Metric tab.

  4. In the Find resource type and metric field, enter Firestore. From the auto-populated dropdown, select one of the Cloud Firestore metrics.

  5. To add more Cloud Firestore metrics to the same chart, click Add Metric and repeat the previous step.

  6. Click Save.

For more on Stackdriver Monitoring charts, see Working with charts.

Create an alerting policy

You can create an alerting policy based on the Cloud Firestore metrics. Follow the steps below can create an alerting policy that emails you whenever a specific Cloud Firestore metric meets a certain threshold.

Before you proceed, make sure your project is part of a Stackdriver workspace.

  1. In the Stackdriver Console, open your workspace and go to Alerting > Create a Policy.

    Go to the Create New Alerting Policy page

  2. Add an alerting condition based on one of the Cloud Firestore metrics. Click Add Condition

  3. Select a Target metric. In the Find resource type and metric field, enter Firestore. From the auto-populated dropdown, select one of the Cloud Firestore metrics.

  4. Under Configuration, use the dropdown fields to define your alerting condition.

  5. Click Save.

  6. Add a notification channel to your alerting policy. Under Notifications, select Email from the Notification Channel Type.

  7. Enter your email in the Email address field. Click Add Notification Channel.

  8. Optionally, fill out the documentation field to include additional information in your email notification.

  9. Under Name this policy, enter a name for your alerting policy.

  10. Click Save.

If your Cloud Firestore usage exceeds the configured threshold, you will receive an email alert:

An example Cloud Firestore alert email.

For more on alerting policies, see Introduction to alerting.

What's next

¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...