If you are using sinks to export trace data to BigQuery, then this document applies to you. The usage of sinks to export trace data is no longer recommended. Instead, we recommend that you use Log Analytics, which supports the same SQL query language as BigQuery. This document describes how to migrate from a sink-based solution to one that uses Log Analytics. It also includes information about how to query your trace data by using BigQuery services.
To get started with Log Analytics, see Query and analyze traces.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Observability API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Observability API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
To get the permissions that you need to load the Log Analytics page, run queries, and create a linked dataset, ask your administrator to grant you the following IAM roles on your project:
-
Cloud Trace Admin (
roles/cloudtrace.admin) -
Observability Editor (
roles/observability.editor) -
BigQuery User (
roles/bigquery.user)
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
-
Cloud Trace Admin (
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Migrate to Log Analytics
Completed the actions listed in the Before you begin section of this document. Those actions include enabling the Observability API.
Verify that you have access to your trace data by using Log Analytics:
-
In the Google Cloud console, go to the manage_search Log Analytics page:
If you use the search bar to find this page, then select the result whose subheading is Logging.
In the Views menu, go to the
Traces section, and then select
_Trace.Spans._AllSpans.The Schema pane is updated and displays the schema.
If you don't see a view named
_Trace.Spans._AllSpans, then your Google Cloud project doesn't contain a observability bucket named_Trace. For information about how to resolve this situation, see Trace storage initialization fails.In the Schema pane, select Query.
The query editor field is updated. The
FROMclause lists an entry similar to the following:`PROJECT_ID.us._Trace.Spans._AllSpans`In the toolbar, select Run Query.
If the toolbar displays Run in BigQuery, then click settings Settings, and select Analytics (default).
You have verified that you can query your trace data by using the Log Analytics page.
-
Optional: If you want to join your trace data with other business data that is available to BigQuery, then create a linked BigQuery dataset. For more information, see Query a linked BigQuery dataset.
Delete trace sinks and unnecessary datasets:
To list existing trace sinks, execute the
gcloud alpha trace sinks listcommand:gcloud alpha trace sinks listFor each sink, execute the
gcloud alpha trace sinks deletecommand:gcloud alpha trace sinks delete SINK_NAMEOptional: Delete any unnecessary BigQuery datasets. For information about how to delete a BigQuery dataset, see Delete datasets.
Schema comparison
This section provides information about the differences between Log Analytics and sink-based export schemas.
| Name | Analytics | Legacy |
|---|---|---|
| Trace ID | trace_id |
extendedFields.traceId |
| Span ID | span_id |
span.spanId |
| Parent span ID | parent_span_id |
span.parentSpanId |
| Span name | name |
span.displayName.value |
| Span kind | kindFor values, see OpenTelemetry: SpanKind.
|
span.spanKindFor values, see the Cloud Trace API reference SpanKind page. |
| Span start time | start_time |
span.startTime |
| Span end time | end_time |
span.endTime |
| Attributes | Span, resource, and instrumentation attributes each have a unique format. These fields have the BigQuery JSON data type. Examples:
|
All attributes use the same format:
Examples:
|