Set up advanced alerting to custom notification channels

Firebase offers two options for configuring alerts and sending them to custom notification channels.



(Recommended) Set up and send custom alerts to custom notification channels

Firebase offers default Crashlytics alerts (see the alerting overview page). However, these default alerts and their notification channels may not be sufficient for your needs.

In these cases, you can use Cloud Monitoring to send custom alerts to custom notification channels based on Crashlytics data (and optionally Firebase sessions data) that you've exported to Cloud Logging.

To use Cloud Monitoring for custom alerts, you set up an alerting policy, which describes the circumstances under which you want to be alerted and how you want to be notified.

For example, if your crash-free rate goes below a specific threshold, Cloud Monitoring can send a customized alert message to a specific email address or post it to a third-party service, like Discord, Slack, or Jira. You can also fully customize the information sent in the alert, like including helpful deep-links into the Firebase console or company-specific troubleshooting information.

In the Google Cloud documentation, learn more about Cloud Monitoring and alerts, including pricing.

Prerequisites

  1. Make sure your Firebase project is on the pay-as-you-go Blaze pricing plan.

  2. Set up export to Cloud Logging of Crashlytics data and (optionally) Firebase sessions data.

  3. Set up notification channels.

Set up an alerting policy

The following are high-level instructions; for detailed instructions, see the Google Cloud documentation (for example: Create metric-threshold alerting policies or Use PromQL to create alerting policies).

As part of running queries, you can set up either a log-based alert or a SQL-based alert:

  • Set up a log-based alert:

    1. Run a query in Logs Explorer.

    2. Click the Add alert button that appears.

    3. Follow the on-screen instructions to add a log-based alert.

  • Set up a SQL-based alert:

    1. Run a query in Logs Analytics.

    2. Click the Add alert button that appears.

    3. Follow the on-screen instructions to add a SQL-based alert.

Alternatively, you can set up alerts for your log-based metrics by using the policy configuration tool in the Google Cloud console, where you can choose one of the following options:

  • Builder: The console UI provides a guided workflow to build the alerting policy.

  • PromQL: You provide a PromQL query for your alerting policy



Send default Crashlytics alerts to custom notification channels

Firebase offers default Crashlytics alerts (see the list on the alerting options overview page). However, the information in these default alerts and their notification channels may not be sufficient for your needs.

In these cases, you can use Cloud Functions for Firebase to send these default Crashlytics alerts to custom notification channels. For example, you can write a function that captures an alert event for velocity alerts and posts the alert information to a third-party service, like Discord, Slack, or Jira.

With this advanced alerting mechanism, you can also customize the information sent to the third-party service. For example, in addition to the default information provided by Firebase, you can also include helpful deep-links into the Firebase console or company-specific troubleshooting information.

To set up advanced alerting capabilities using Cloud Functions for Firebase, follow these steps:

  1. Set up Cloud Functions for Firebase, which includes the following tasks:

    1. Set up a development environment for Node.js or Python.
    2. Install and sign into the Firebase CLI.
    3. Initialize Cloud Functions for Firebase using the Firebase CLI.
  2. Write and deploy a function that captures an alert event from Crashlytics and handles the event payload (for example, posts the alert information in a message on Discord).

To learn about all the Crashlytics alert events that you can capture, go to the reference documentation for Crashlytics alerts.

Learn more about handling Crashlytics alerts using Cloud Functions for Firebase