Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Genkit
GitHubDiscord

Get started with Genkit Monitoring

This quickstart guide describes how to set up Genkit Monitoring foryour deployed Genkit features, so that you can collect and view real-timetelemetry data. With Genkit Monitoring, you get visibility into howyour Genkit features are performing in production.

Key capabilities of Genkit Monitoring include:

Setting up Genkit Monitoring requires completing tasks in both your codebaseand on the Google Cloud Console.

  1. If you haven’t already, create a Firebase project.

    In theFirebase console, clickAdd a project, then follow the on-screen instructions. You cancreate a new project or add Firebase services to an already-existing Google Cloud project.

  2. Ensure your project is on theBlaze pricing plan.

    Genkit Monitoring relies on telemetry data written to Google CloudLogging, Metrics, and Trace, which are paid services. View theGoogle Cloud Observability pricing page for pricing details and to learn about free-of-charge tier limits.

  3. Write a Genkit feature by following theGet Started Guide, and prepare your code for deployment by using one of the following guides:

Install the@genkit-ai/firebase plugin in your project:

Terminal window
npminstall@genkit-ai/firebase

If you intend to use the default configuration for Firebase GenkitMonitoring, you can enable telemetry by setting theENABLE_FIREBASE_MONITORING environment variable in your deploymentenvironment.

Terminal window
export ENABLE_FIREBASE_MONITORING=true

This will use default configuration values. Tooverride configuration options, use “Programmatic configuration”.

You can also enable Firebase Genkit Monitoring in code. This is usefulif you want to tweak any configuration settings like the metric exportinterval or to set up your local environment to export telemetry data.

ImportenableFirebaseTelemetry into your Genkit configuration file (thefile wheregenkit(...) is initalized), and call it:

import { enableFirebaseTelemetry }from'@genkit-ai/firebase';
enableFirebaseTelemetry();

You can also enable Firebase Genkit Monitoring in code. This is usefulif you want to tweak any configuration settings like the metric exportinterval or to set up your local environment to export telemetry data.

packagemain
import (
"context"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/firebase"
)
funcmain() {
ctx:= context.Background()
firebase.EnableFirebaseTelemetry(nil)
g:= genkit.Init(ctx,nil)
}

Make sure that the following APIs are enabled for your Google Cloud project:

These APIs should be listed in theAPI dashboard for yourproject.

The Firebase plugin needs to use aservice account to authenticate withGoogle Cloud Logging, Metrics, and Trace services.

Grant the following roles to whichever service account is configured to run your code within theGoogle Cloud IAM Console. For Cloud Functions for Firebase and Cloud Run, that’s typically the default compute service account.

  • Monitoring Metric Writer (roles/monitoring.metricWriter)
  • Cloud Trace Agent (roles/cloudtrace.agent)
  • Logs Writer (roles/logging.logWriter)

Step 4. (Optional) Test your configuration locally

Section titled “Step 4. (Optional) Test your configuration locally”

Before deploying, you can run your Genkit code locally to confirm thattelemetry data is being collected, and is viewable in the Genkit Monitoringdashboard.

  1. In your Genkit code, setforceDevExport totrue to send telemetry fromyour local environment.
  1. In your Genkit code, setForceDevExport totrue to send telemetry fromyour local environment.
  1. Use your service account to authenticate and test your configuration.

    With theGoogle Cloud CLI tool,authenticate using the service account:

    Terminal window
    gcloudauthapplication-defaultlogin--impersonate-service-accountSERVICE_ACCT_EMAIL
  2. Run and invoke your Genkit feature, and then view metrics on theGenkit Monitoring dashboard.Allow for up to 5 minutes to collect the first metric. You can reduce thisdelay by settingmetricExportIntervalMillis in the telemetry configuration.

  3. If metrics are not appearing in the Genkit Monitoring dashboard, view theTroubleshooting guide for stepsto debug.

Re-build, deploy, and invoke your Genkit feature to start collecting data.After Genkit Monitoring receives your metrics, you can view them byvisiting theGenkit Monitoring dashboard


[8]
ページ先頭

©2009-2025 Movatter.jp