Genkit Monitoring: Troubleshooting

The following sections detail solutions to common issues that developers run into when using Firebase Genkit Monitoring.

I can't see traces or metrics in Firebase Genkit Monitoring

  1. Ensure that the following APIs are enabled for your underlying Google Cloud project:
  2. Ensure that the following roles are applied to the service account that is running your code (or service account that has been configured as part of the plugin options) in Cloud IAM.
    • Monitoring Metric Writer (roles/monitoring.metricWriter)
    • Cloud Trace Agent (roles/cloudtrace.agent)
    • Logs Writer (roles/logging.logWriter)
  3. Inspect the application logs for errors writing to Cloud Logging, Cloud Trace, and Cloud Monitoring. On Google Cloud infrastructure such as Firebase Functions and Cloud Run, even when telemetry is misconfigured, logs to stdout/stderr are automatically ingested by the Cloud Logging Agent, allowing you to diagnose issues in the in the Cloud Logging Console.

  4. Debug locally:

    Enable dev export:

    enableFirebaseTelemetry({
      forceDevExport: true
    });
    

    To test with your personal user credentials, use the gcloud CLI to authenticate with Google Cloud. Doing so can help diagnose enabled or disabled APIs, but does not test the gcloud auth application-default login.

    Alternatively, impersonating the service account lets you test production-like access. You must have the roles/iam. serviceAccountTokenCreator IAM role applied to your user account in order to impersonate service accounts:

    gcloud auth application-default login --impersonate-service-account <SERVICE_ACCT_EMAIL>

    See the ADC documentation for more information.

Telemetry upload reliability in Firebase Functions / Cloud Run

When Genkit is hosted in Google Cloud Run (including Cloud Functions for Firebase), telemetry-data upload may be less reliable as the container switches to the "idle" lifecycle state. If higher reliability is important to you, consider changing CPU allocation to always allocated in the Google Cloud Console.