This page describes how you can monitor your Cloud Storage for Firebase 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 storage bucket's operations (for example, by monitoring evaluation of Storage Security Rules) can be a helpful for troubleshooting.
The Firebase console includes a usage dashboard that shows Storage Bytes stored, object count, bandwidth, and download requests over time.
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 storage usage information including Bytes stored, object counts, bandwidth used, and download requests.
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 Security Rules-related Cloud Storage metrics:
|Rule evaluations||The number of Cloud Storage 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) or the bucket name.|
- Sampling rate
- The Cloud Storage metrics are sampled every 60 seconds, but updates may take up to 4 minutes to show up in your dashboards.
Using these metrics, you can set up a Cloud Storage dashboard like the following:
Complete the steps below to start monitoring Cloud Storage with Stackdriver Monitoring.
Create a Stackdriver workspace
To monitor a Cloud Storage for Firebase Bucket 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.
Enter your GCP project ID and click Create workspace.
Optionally, select additional projects to monitor in the same workspace. Click Continue.
Skip the steps to Add AWS accounts and Install Stackdriver agents. These steps are not required to monitor Cloud Storage. Click Continue.
Configure your preference for email reports. Click Continue.
Click Launch Monitoring.
Create a dashboard and add a chart
Display the Cloud Storage metrics collected from Stackdriver Monitoring in your own charts and dashboards. Before you proceed, make sure your project is part of a Stackdriver workspace.
- In the Stackdriver Console, open your workspace and go to Dashboards > Create dashboard. Go to the Create Dashboard page
- In the upper-right hand corner, click Add Chart.
- In the Add Chart window, click the Metric tab.
- In the Find resource type and metric field, enter GCS Bucket. From the auto-populated dropdown, select one of the available metrics, for instance, Rule evaluations.
- To add more metrics to the same chart, click Add Metric and repeat the previous step.
- Tailor your chart as needed. For example, in the Filter field, click + Add a filter. Scroll down, then select
resultand the Rules evaluation result (ALLOW, DENY, or ERROR) you wish to filter the chart on.
- 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 Storage metrics. Follow the steps below can create an alerting policy that emails you whenever a specific Storage metric meets a certain threshold. Before you proceed, make sure your project is part of a Stackdriver workspace.
- In the Stackdriver Console, open your workspace and go to Alerting > Create a Policy. Go to the Create New Alerting Policy page
- Add an alerting condition based on one of the Storage metrics. Click Add Condition
- Select a Target metric. In the Find resource type and metric field, enter GCS Bucket. From the auto-populated dropdown, select one of the metrics.
- Under Configuration, use the dropdown fields to define your alerting condition.
- Click Save.
- Add a notification channel to your alerting policy. Under Notifications, select Email from the Notification Channel Type.
- Enter your email in the Email address field. Click Add Notification Channel.
- Optionally, fill out the documentation field to include additional information in your email notification.
- Under Name this policy, enter a name for your alerting policy.
- Click Save.
If your Storage Bucket usage exceeds the configured threshold, you will receive an email alert. For more on alerting policies, see Introduction to alerting.