There are a few different ways to monitor your Firebase Realtime Database's
performance and spot potential problems in your app. Looking at your app's
incoming and outgoing bandwidth and load 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.

This page discusses Realtime Database performance monitoring. For usage
monitoring, see [Monitor Database Usage](https://firebase.google.com/docs/database/usage/monitor-usage.md.txt).

## Use Realtime Database monitoring tools

You can gather data about your Realtime Database's performance through a few
different tools, depending on the level of granularity you need.

### Use the Realtime Database profiler tool

The [Realtime Database profiler tool](https://firebase.google.com/docs/database/usage/profile.md.txt) provides a realtime overview of
read/write operations on your database. The report includes information about
the speed and payload size of each operation, in addition to unindexed queries.
It doesn't include historical information or any statistics about connection
overhead, however, and **should not be used to estimate billing costs**.

To learn more about using the profiler tool, see
[Profile your database](https://firebase.google.com/docs/database/usage/profile.md.txt).

### Use the Firebase console

The **Usage** tab in the
[Firebase console](https://console.firebase.google.com/project/_/database/usage/current-billing/bandwidth)
offers information about simultaneous connections to your database, how much
data you're storing, outgoing bandwidth (including protocol and encryption
overhead), and your database's load over 1-minute intervals. While the **Usage**
tab gives you a more accurate overview of your database's overall performance,
you might not be able to drill down enough to troubleshoot potential performance issues.

### Use Cloud Monitoring

With Cloud Monitoring from Google Cloud, you can use the Metrics
Explorer to see individual performance metrics, or create different dashboards
with charts that display various combinations of performance metrics over time.
The Realtime Database integration with Cloud Monitoring offers the deepest
level of granularity.

The steps for setting up Cloud Monitoring are described in [Monitor Database Usage](https://firebase.google.com/docs/database/usage/monitor-usage.md.txt#stackdriver-setup).

See the following sections for tips on using specific Cloud Monitoring
metrics to spot performance issues.

## Monitor performance in Cloud Monitoring

If you're experiencing issues with performance, including uptime or latency, you
might want to use Cloud Monitoring to monitor the following metrics.
Note all metric type names are prefixed with `firebasedatabase.googleapis.com/`.

| Metric Name | Description |
|---|---|
| Database Load | `io/database_load`. Use this metric to monitor how much of your available database bandwidth is in use processing requests over time. You might see performance issues as your database load approaches the total available bandwidth. You can also see which operation types are utilizing the most load, and troubleshoot accordingly. Reported load might exceed 100% on operations that take longer than a minute. This happens when the total bandwidth used across multiple minutes is condensed into the minute-long reporting interval after the operation has completed. |
| Network Disabled for Overages | `network/disabled_for_overages`. This metric reflects any outages that might have occurred if your Realtime Database exceeded any bandwidth or network limits. |
| Storage Disabled for Overages | `storage/disabled_for_overages`. This metric reflects any outages that might have occurred if your Realtime Database exceeded any storage limits. |

Combine metrics in charts on your dashboard for helpful insights and overviews.
For example, try the following combinations:

- **Operations:** Use the `io/database_load` metric to see how much of your total database load is used by each operation type. Make sure to group `io/database_load` by type to troubleshoot different operation types.
- **Storage:** Use the `storage/limit` and `storage/total_bytes` to monitor your storage utilization in relation to the Realtime Database storage limits. You can also add `storage/disabled_for_overages` to see if your app experienced any down time as a result of exceeded storage limits.
- **SSL overhead:** Use `network/https_requests_count` to monitor how many SSL connection requests your database received, and split out requests that reused an existing SSL session ticket with the `reused_ssl_session` filter. You can measure this against the `network/sent_bytes_count` and `network/sent_payload_and_protocol_bytes_count` to monitor whether or not your app is using SSL session tickets efficiently.

You can also set up [alerts](https://firebase.google.com/docs/database/usage/monitor-usage.md.txt#stackdriver-alert-setup) through
Cloud Monitoring and receive notifications based on Realtime Database metrics.
For example, you can choose to receive a notification if your `io/database_load`
is approaching a certain threshold.

See the [full list of Realtime Database metrics available through Cloud Monitoring](https://cloud.google.com/monitoring/api/metrics_gcp_d_h#gcp-firebasedatabase).

### Database Load Types

The `io/database_load` metric also provides a label of which operation type
caused the load. The following are the possible types of operations measured:

- `admin`: Admin operations like setting rules and reading project metadata.
- `auth`: Verifying authentication from service accounts or Firebase Authentication for a single client.
- `client_management`: Handling the addition and removal of concurrent connections this includes running disconnect operations on removal.
- `get_shallow`: Retrieving the data from a REST GET with `shallow=true`.
- `get`: Handling REST GET operations.
- `listen`: Retrieving the initial data for `on` and `once` operations from connected clients.
- `on_disconnect`: Registering on disconnect operations from clients.
- `put`: Handling `set` operations from clients or REST PUT operations.
- `transaction`: Performing transactions from conditional REST requests or a `transaction` operation from a client.
- `update`: Handling `update` operations or REST PATCH requests.

## Monitor Security Rules in Cloud Monitoring

You can also analyze evaluation of Security Rules. Note all metric type names
are prefixed with `firebasedatabase.googleapis.com/`.

| Metric Name | Description |
|---|---|
| Rule evaluations | `rules/evaluation_count`. The number of Realtime Database Rules evaluations performed in response to write or read requests. You can break this metric down by the result of the request (ALLOW, DENY, or ERROR). |

Tailor your Cloud Monitoring chart for Rules evaluations as needed, for
example by filtering on particular evaluation results, ALLOW, DENY, or ERROR.
Setting up and customizing charts is covered in
[Monitor Database Usage](https://firebase.google.com/docs/database/usage/monitor-usage.md.txt#stackdriver-add-chart).

See the [full list of Realtime Database metrics available through Cloud Monitoring](https://cloud.google.com/monitoring/api/metrics_gcp_d_h#gcp-firebasedatabase).