This document describes how to run the [Google-Built OpenTelemetry Collector](https://docs.cloud.google.com/stackdriver/docs/instrumentation/google-built-otel.md.txt)
on Container-Optimized OS to collect OTLP logs, metrics, and traces
from instrumented applications and then export that data to Google Cloud.

## Before you begin

Running the OpenTelemetry Collector requires the following resources:

1. A Container-Optimized OS virtual machine (VM). If you don't have a Container-Optimized OS VM, then follow the instructions at [Creating
   and configuring instances](https://docs.cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance).
2. An installation of `gcloud`. For information about installing `gcloud`, see [Install the Google Cloud CLI](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt).

## Configure permissions for the Collector

By default, Container-Optimized OS VMs use the
[Compute Engine default service account](https://docs.cloud.google.com/compute/docs/access/service-accounts.md.txt#default_service_account),
`PROJECT_NUMBER-compute@developer.gserviceaccount.com`.
This service account usually has the Identity and Access Management (IAM) roles
necessary to write the telemetry described in this document:

- [Monitoring Metric Writer (`roles/monitoring.metricWriter`)](https://docs.cloud.google.com/iam/docs/roles-permissions/monitoring.md.txt#monitoring.metricWriter)
- [Logs Writer (`roles/logging.logWriter`)](https://docs.cloud.google.com/iam/docs/roles-permissions/logging.md.txt#logging.logWriter)
- [Cloud Trace Agent](https://docs.cloud.google.com/iam/docs/roles-permissions/cloudtrace.md.txt#cloudtrace.agent)

If you are configuring a custom service account for your instance, see
[Manage access to service accounts](https://docs.cloud.google.com/iam/docs/manage-access-service-accounts.md.txt#grant-single-role).

## Deploy the Collector

To run Google-Built OpenTelemetry Collector, you need to provide a configuration file for your
Container-Optimized OS VM. You can
use the [`cloud-init` tool](https://docs.cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance.md.txt#using_cloud-init_with_the_cloud_config_format)
to write a configuration file. The following is a recommended
`cloud-init` file for using the Google-built Collector:

```yaml
write_files:
- path: /etc/config/config.yaml
  permissions: 0644
  owner: root
  content: |
    receivers:
      # Open two OTLP servers:
      # - On port 4317, open an OTLP GRPC server
      # - On port 4318, open an OTLP HTTP server
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver
      otlp:
        protocols:
          grpc:
            endpoint: localhost:4317
          http:
            cors:
              # This effectively allows any origin
              # to make requests to the HTTP server.
              allowed_origins:
              - http://*
              - https://*
            endpoint: localhost:4318

    processors:
      # The batch processor is in place to regulate both the number of requests
      # being made and the size of those requests.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor
      batch:
        send_batch_max_size: 200
        send_batch_size: 200
        timeout: 5s

      # The memorylimiter will check the memory usage of the collector process.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/memorylimiterprocessor
      memory_limiter:
        check_interval: 1s
        limit_percentage: 65
        spike_limit_percentage: 20

      # The resourcedetection processor is configured to detect GCP resources.
      # Resource attributes that represent the GCP resource the collector is
      # running on will be attached to all telemetry that goes through this
      # processor.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor
      # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor#gcp-metadata
      resourcedetection:
        detectors: [gcp]
        timeout: 10s

      # The resource/gcp_project_id processor sets the GCP project ID attribute on telemetry data exported via OTLP.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor
      resource/gcp_project_id:
        attributes:
        - action: insert
          key: gcp.project_id
          value: ${GOOGLE_CLOUD_PROJECT}

      # The metricstarttime processor sets start time on delta metrics for OTLP export.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstarttimeprocessor
      metricstarttime:
        strategy: subtract_initial_point

      transform/collision:
        metric_statements:
        - context: datapoint
          statements:
          - set(attributes["exported_location"], attributes["location"])
          - delete_key(attributes, "location")
          - set(attributes["exported_cluster"], attributes["cluster"])
          - delete_key(attributes, "cluster")
          - set(attributes["exported_namespace"], attributes["namespace"])
          - delete_key(attributes, "namespace")
          - set(attributes["exported_job"], attributes["job"])
          - delete_key(attributes, "job")
          - set(attributes["exported_instance"], attributes["instance"])
          - delete_key(attributes, "instance")
          - set(attributes["exported_project_id"], attributes["project_id"])
          - delete_key(attributes, "project_id")

      # For each Prometheus unknown-typed metric, which is a gauge, create a counter that is an exact copy of this metric.
      # The GCP OTLP endpoint will add appropriate suffixes for the counter and gauge.
      transform/prometheus_unknown_types:
        error_mode: ignore
        metric_statements:
        - context: metric
          statements:
          - copy_metric(Concat([metric.name, "unknowncounter"], ":")) where metric.metadata["prometheus.type"] == "unknown" and not HasSuffix(metric.name, ":unknowncounter")
          - convert_gauge_to_sum("cumulative", true) where HasSuffix(metric.name, ":unknowncounter")
          - set(metric.name, Substring(metric.name, 0, Len(metric.name)-Len(":unknowncounter"))) where HasSuffix(metric.name, ":unknowncounter")

      transform/otlp_grpc/preserve_instrumentation_source_version:
        error_mode: ignore
        log_statements:
        - context: log
          statements:
          - set(attributes["instrumentation_source"], instrumentation_scope.name) where instrumentation_scope.name != ""
          - set(attributes["instrumentation_version"], instrumentation_scope.version) where instrumentation_scope.version != ""

      transform/otlp_grpc/copy_service_resource_labels:
        error_mode: ignore
        log_statements:
        - context: log
          statements:
          - set(attributes["service.name"], resource.attributes["service.name"]) where resource.attributes["service.name"] != nil
          - set(attributes["service.namespace"], resource.attributes["service.namespace"]) where resource.attributes["service.namespace"] != nil
          - set(attributes["service.instance.id"], resource.attributes["service.instance.id"]) where resource.attributes["service.instance.id"] != nil

    exporters:
      # The otlp_grpc exporter is used to send telemetry (logs, metrics, traces) to GCP Telemetry API using OTLP gRPC.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter
      otlp_grpc:
        endpoint: telemetry.googleapis.com:443
        balancer_name: pick_first
        auth:
          authenticator: googleclientauth

    extensions:
      googleclientauth:

    service:
      extensions:
      - googleclientauth
      pipelines:
        logs:
          receivers:
          - otlp
          processors:
          - resourcedetection
          - resource/gcp_project_id
          - transform/otlp_grpc/preserve_instrumentation_source_version
          - transform/otlp_grpc/copy_service_resource_labels
          - memory_limiter
          - batch
          exporters:
          - otlp_grpc
        metrics/otlp:
          receivers:
          - otlp
          processors:
          - resourcedetection
          - resource/gcp_project_id
          - transform/collision
          - transform/prometheus_unknown_types
          - metricstarttime
          - memory_limiter
          - batch
          exporters:
          - otlp_grpc
        traces:
          receivers:
          - otlp
          processors:
          - resourcedetection
          - resource/gcp_project_id
          - memory_limiter
          - batch
          exporters:
          - otlp_grpc
      # Internal telemetry for the collector supports both push and pull-based telemetry data transmission.
      # Leveraging the pre-configured OTLP receiver eliminates the need for an additional port.
      #
      # Docs:
      # https://opentelemetry.io/docs/collector/internal-telemetry/
      telemetry:
        metrics:
          readers:
            - periodic:
                exporter:
                  otlp:
                    protocol: grpc
                    endpoint: http://localhost:4317
                    insecure: true
```

We recommend that you create a Docker `bridge` network to facilitate
communication between the Collector container and any other container on
the system that will be sending telemetry. To create the network,
run the following command:

```
docker network create -d bridge otel
```

Run the Collector container with the following command:

```yaml
docker run -d \
    --network otel \
    --name opentelemetry-collector \
    -v /etc/config:/etc/config \
    us-docker.pkg.dev/cloud-ops-agents-artifacts/google-cloud-opentelemetry-collector/otelcol-google:0.164.0 \
    --config=/etc/config/config.yaml
```

The previous command does the following:

- Runs the Collector container in the background.
- Attaches the Collector container to the previously created <var label="bridge network name" translate="no">otel</var> bridge network. Other containers can be connected to the bridge to send telemetry.
- Mounts your configuration file on the container so the file can be accessed to configure the Collector.

> [!NOTE]
> **Note:** The value of the `--name` option, `opentelemetry-collector`, is used in the subsequent [Generate telemetry](https://docs.cloud.google.com/stackdriver/docs/instrumentation/opentelemetry-collector-cos.md.txt#generate-telemetry) section. If you change the value in this command, then use your value when setting the <var label="container name" translate="no">opentelemetry-collector</var> placeholder in that section.

## Configure the Collector

We provide an OpenTelemetry Collector configuration for you to use with the
Google-built Collector. This configuration is designed to deliver high
volumes of OTLP metrics, logs, and
traces.
This configuration is also designed to prevent common ingestion
issues. You can add to the configuration, but we strongly recommend that you
don't remove elements.

This section describes the provided configuration, the key components
like exporters, processors, receivers, and other available components.

### Provided Collector configuration

You can find the Collector configuration in the `google-built-opentelemetry-collector` directory on the [`opentelemetry-operations-collector` repository](https://github.com/GoogleCloudPlatform/opentelemetry-operations-collector/tree/v0.164.0/google-built-opentelemetry-collector/docs/examples/configuration/config-standard.yaml):

<br />


```yaml
receivers:
  # Open two OTLP servers:
  # - On port 4317, open an OTLP GRPC server
  # - On port 4318, open an OTLP HTTP server
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver
  otlp:
    protocols:
      grpc:
        endpoint: localhost:4317
      http:
        cors:
          # This effectively allows any origin
          # to make requests to the HTTP server.
          allowed_origins:
          - http://*
          - https://*
        endpoint: localhost:4318

processors:
  # The batch processor is in place to regulate both the number of requests
  # being made and the size of those requests.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor
  batch:
    send_batch_max_size: 200
    send_batch_size: 200
    timeout: 5s

  # The memorylimiter will check the memory usage of the collector process.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/memorylimiterprocessor
  memory_limiter:
    check_interval: 1s
    limit_percentage: 65
    spike_limit_percentage: 20

  # The resourcedetection processor is configured to detect GCP resources.
  # Resource attributes that represent the GCP resource the collector is
  # running on will be attached to all telemetry that goes through this
  # processor.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor
  # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor#gcp-metadata
  resourcedetection:
    detectors: [gcp]
    timeout: 10s

  # The resource/gcp_project_id processor sets the GCP project ID attribute on telemetry data exported via OTLP.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourceprocessor
  resource/gcp_project_id:
    attributes:
    - action: insert
      key: gcp.project_id
      value: ${GOOGLE_CLOUD_PROJECT}

  # The metricstarttime processor sets start time on delta metrics for OTLP export.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstarttimeprocessor
  metricstarttime:
    strategy: subtract_initial_point

  transform/collision:
    metric_statements:
    - context: datapoint
      statements:
      - set(attributes["exported_location"], attributes["location"])
      - delete_key(attributes, "location")
      - set(attributes["exported_cluster"], attributes["cluster"])
      - delete_key(attributes, "cluster")
      - set(attributes["exported_namespace"], attributes["namespace"])
      - delete_key(attributes, "namespace")
      - set(attributes["exported_job"], attributes["job"])
      - delete_key(attributes, "job")
      - set(attributes["exported_instance"], attributes["instance"])
      - delete_key(attributes, "instance")
      - set(attributes["exported_project_id"], attributes["project_id"])
      - delete_key(attributes, "project_id")

  # For each Prometheus unknown-typed metric, which is a gauge, create a counter that is an exact copy of this metric.
  # The GCP OTLP endpoint will add appropriate suffixes for the counter and gauge.
  transform/prometheus_unknown_types:
    error_mode: ignore
    metric_statements:
    - context: metric
      statements:
      - copy_metric(Concat([metric.name, "unknowncounter"], ":")) where metric.metadata["prometheus.type"] == "unknown" and not HasSuffix(metric.name, ":unknowncounter")
      - convert_gauge_to_sum("cumulative", true) where HasSuffix(metric.name, ":unknowncounter")
      - set(metric.name, Substring(metric.name, 0, Len(metric.name)-Len(":unknowncounter"))) where HasSuffix(metric.name, ":unknowncounter")

  transform/otlp_grpc/preserve_instrumentation_source_version:
    error_mode: ignore
    log_statements:
    - context: log
      statements:
      - set(attributes["instrumentation_source"], instrumentation_scope.name) where instrumentation_scope.name != ""
      - set(attributes["instrumentation_version"], instrumentation_scope.version) where instrumentation_scope.version != ""

  transform/otlp_grpc/copy_service_resource_labels:
    error_mode: ignore
    log_statements:
    - context: log
      statements:
      - set(attributes["service.name"], resource.attributes["service.name"]) where resource.attributes["service.name"] != nil
      - set(attributes["service.namespace"], resource.attributes["service.namespace"]) where resource.attributes["service.namespace"] != nil
      - set(attributes["service.instance.id"], resource.attributes["service.instance.id"]) where resource.attributes["service.instance.id"] != nil

exporters:
  # The otlp_grpc exporter is used to send telemetry (logs, metrics, traces) to GCP Telemetry API using OTLP gRPC.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter
  otlp_grpc:
    endpoint: telemetry.googleapis.com:443
    balancer_name: pick_first
    auth:
      authenticator: googleclientauth

extensions:
  # Opens an endpoint on 13133 that can be used to check the
  # status of the collector. Since this does not configure the
  # `path` config value, the endpoint will default to `/`.
  #
  # When running on Cloud Run, this extension is required and not optional.
  # In other environments it is recommended but may not be required for operation
  # (i.e. in Container-Optimized OS or other GCE environments).
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/healthcheckextension
  health_check:
    endpoint: 0.0.0.0:13133
  googleclientauth:

service:
  extensions:
  - health_check
  - googleclientauth
  pipelines:
    logs:
      receivers:
      - otlp
      processors:
      - resourcedetection
      - resource/gcp_project_id
      - transform/otlp_grpc/preserve_instrumentation_source_version
      - transform/otlp_grpc/copy_service_resource_labels
      - memory_limiter
      - batch
      exporters:
      - otlp_grpc
    metrics/otlp:
      receivers:
      - otlp
      processors:
      - resourcedetection
      - resource/gcp_project_id
      - transform/collision
      - transform/prometheus_unknown_types
      - metricstarttime
      - memory_limiter
      - batch
      exporters:
      - otlp_grpc
    traces:
      receivers:
      - otlp
      processors:
      - resourcedetection
      - resource/gcp_project_id
      - memory_limiter
      - batch
      exporters:
      - otlp_grpc
  # Internal telemetry for the collector supports both push and pull-based telemetry data transmission.
  # Leveraging the pre-configured OTLP receiver eliminates the need for an additional port.
  #
  # Docs:
  # https://opentelemetry.io/docs/collector/internal-telemetry/
  telemetry:
    metrics:
      readers:
        - periodic:
            exporter:
              otlp:
                protocol: grpc
                endpoint: http://localhost:4317
                insecure: true
```

### Exporters

The Collector configuration uses the following:

- The OTLP gRPC exporter, to send logs, metrics, and traces to the [Telemetry (OTLP) API](https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/overview.md.txt).
- The [`googleclientauthextension`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.158.0/extension/googleclientauthextension) for API authentication.

### Processors

The Collector configuration includes the following processors:

- [`batch`](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor):
  Configured to batch telemetry requests at the Google Cloud maximum number of
  entries per request, or at the Google Cloud minimum interval of every 5
  seconds (whichever comes first).

- [`memory_limiter`](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/memorylimiterprocessor):
  Caps the Collector's memory usage to prevent out-of-memory crashes by
  dropping data points when the limit is exceeded.

- [`resourcedetection`](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor):
  Automatically detects Google Cloud resource labels such as `project_id`.

### Receivers

The Collector configuration includes only the
[`otlp` receiver](https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver).
For information about instrumenting your applications to send OTLP traces
and metrics to the Collector's OTLP endpoint, see
[Choose an instrumentation
approach](https://docs.cloud.google.com/stackdriver/docs/instrumentation/choose-approach).

### Available components

The Google-Built OpenTelemetry Collector contains the components that most users will need to
enable a rich experience within Google Cloud Observability. For a complete list of
available components, see
[Components](https://github.com/GoogleCloudPlatform/opentelemetry-operations-collector/tree/v0.164.0/google-built-opentelemetry-collector/README.md#components)
in the `opentelemetry-operations-collector` repository.

To request any changes or additions to the available components,
[open a feature request](https://github.com/GoogleCloudPlatform/opentelemetry-operations-collector/issues).
in the `opentelemetry-operations-collector` repository.

## Generate telemetry

You can test your configuration by using the open-source
[`telemetrygen` tool](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.164.0/cmd/telemetrygen).
The OpenTelemetry project provides a [container in the GitHub Container registry](https://github.com/open-telemetry/opentelemetry-collector-contrib/pkgs/container/opentelemetry-collector-contrib%2Ftelemetrygen).

Before running the following commands, replace the following placeholders,
if you changed the defaults used in the Docker commands in
[Deploy the Collector](https://docs.cloud.google.com/stackdriver/docs/instrumentation/opentelemetry-collector-cos.md.txt#deploy-collector):

- <var label="bridge network name" translate="no">otel</var>: The name you specified when you created the Docker `bridge` network.
- <var label="container name" translate="no">opentelemetry-collector</var>: The name you specified when running the container.

### Generate logs

To generate logs by using the `telemetrygen` tool, run the following command:

```
docker run \
  --net=otel \
  ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.105.0 \
  logs --otlp-insecure --rate=3 --duration=5m \
  --otlp-endpoint=opentelemetry-collector:4317
```

### Generate metrics

To generate metrics by using the `telemetrygen` tool, run the following
command:

```
docker run \
  --net=otel \
  ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.105.0 \
  metrics --otlp-insecure --rate=0.1 --duration=5m \
  --otlp-endpoint=opentelemetry-collector:4317
```

### Generate traces

To generate traces by using the `telemetrygen` tool, run the following
command:

```
docker run \
  --net=otel \
  ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.105.0 \
  traces --otlp-insecure --rate=3 --duration=5m \
  --otlp-endpoint=opentelemetry-collector:4317
```

After a few minutes, telemetry generated by the application begins flowing
through the Collector to the Google Cloud console for each signal.

## View telemetry

The Google-Built OpenTelemetry Collector sends metrics, logs, and traces from your instrumented
applications to Google Cloud Observability. The Collector also sends self-observability
metrics. The following sections describe how to view this telemetry.

<br />

### View your metrics

<br />

The Google-Built OpenTelemetry Collector collects Prometheus metrics that you can view by using
the [Metrics Explorer](https://docs.cloud.google.com/monitoring/charts/metrics-explorer.md.txt). The metrics collected depend
on the instrumentation of the app, although the Google-built Collector also
writes some self-metrics.

<br />

To view the metrics collected by the Google-Built OpenTelemetry Collector, do the following:

1. In the Google Cloud console, go to the
   **Metrics explorer** page:

   [Go to **Metrics explorer**](https://console.cloud.google.com/monitoring/metrics-explorer)

   <br />

   If you use the search bar to find this page, then select the result whose subheading is
   **Monitoring**.
2. In the toolbar of the Google Cloud console, select your Google Cloud project. For [App Hub](https://docs.cloud.google.com/app-hub/docs/overview.md.txt) configurations, select the App Hub host project or the app-enabled folder's management project.
3. In the **Metric** element, expand the **Select a metric** menu, enter `Prometheus Target` in the filter bar, and then use the submenus to select a specific resource type and metric:
   1. In the **Active resources** menu, select **Prometheus Target**.
   2. To select a metric, use the **Active metric categories** and **Active metrics** menus. Metrics collected by the Google-Built OpenTelemetry Collector have the prefix `prometheus.googleapis.com`.
   3. Click **Apply**.
4. To add filters, which remove time series from the query results, use the
   [**Filter** element](https://docs.cloud.google.com/monitoring/charts/metrics-selector.md.txt#filter-option).

5. Configure how the data is viewed.   

   When the measurements for a metric are
   cumulative, Metrics Explorer automatically normalizes the measured data by
   the alignment period, which results in the chart displaying a rate. For
   more information, see [Kinds, types, and conversions](https://docs.cloud.google.com/monitoring/api/v3/aggregation.md.txt#ts-conversion).

   When integer or double values are measured, such as with
   `counter` metrics, Metrics Explorer automatically sums all time series.
   To change this behavior, set the first menu of the **Aggregation** entry
   to **None**.

   For more information about configuring a chart, see
   [Select metrics when using Metrics Explorer.](https://docs.cloud.google.com/monitoring/charts/metrics-selector.md.txt)

<br />

### View your traces

<br />

To view your trace data, do the following:

1. In the Google Cloud console, go to the
   ![](https://docs.cloud.google.com/static/stackdriver/images/trace-explorer-icon.png)
   **Trace explorer** page:

   [Go to **Trace explorer**](https://console.cloud.google.com/traces/explorer)

   <br />

   You can also find this page by using the search bar.
2. In the toolbar of the Google Cloud console, select your Google Cloud project. For [App Hub](https://docs.cloud.google.com/app-hub/docs/overview.md.txt) configurations, select the App Hub host project or management project.
3. In the table section of the page, select a row.
4. In the Gantt chart on the **Trace details** panel,
   select a span.

   A panel opens that displays information about the traced request. These
   details include the method, status code, number of bytes, and the
   user agent of the caller.
5. To view the logs associated with this trace,
   select the **Logs \& Events** tab.

   The tab shows individual logs. To view the details of the log entry,
   expand the log entry. You can also click **View Logs** and view the log
   by using the Logs Explorer.

For more information about using the Cloud Trace explorer, see
[Find and explore traces](https://docs.cloud.google.com/trace/docs/finding-traces.md.txt).

<br />

### View your logs

<br />

From the Logs Explorer, you can inspect your logs, and you can also
view associated traces, when they exist.

1. In the Google Cloud console, go to the

   **Logs Explorer** page:

   [Go to **Logs Explorer**](https://console.cloud.google.com/logs/query)

   <br />

   If you use the search bar to find this page, then select the result whose subheading is
   **Logging**.
2. Locate a log entry from your instrumented app.
   To view the details, expand the log entry.

3. Click ![](https://docs.cloud.google.com/static/stackdriver/images/trace-explorer-icon.png) **Traces** on a log entry with a trace
   message, and then select **View trace details**.

   A **Trace details** panel opens and displays the selected trace.

For more information about using the Logs Explorer, see
[View logs by using the Logs Explorer](https://docs.cloud.google.com/logging/docs/view/logs-explorer-interface.md.txt).

<br />

### Observe and debug the Collector

<br />

The Google-Built OpenTelemetry Collector automatically provides self-observability metrics to
help you monitor its performance and ensure continued uptime of the OTLP
ingestion pipeline.

To monitor the Collector, install the sample dashboard for the Collector. This
dashboard offers at-a-glance insights into several metrics from the Collector,
including uptime, memory usage, and API calls to Google Cloud Observability.

To install the dashboard, do the following:

1. In the Google Cloud console, go to the **Dashboards** page:

   [Go to **Dashboards**](https://console.cloud.google.com/monitoring/dashboards)

   <br />

   If you use the search bar to find this page, then select the result whose subheading is
   **Monitoring**.
2. Click **Dashboard Templates**.
3. Search for the **OpenTelemetry Collector** dashboard.
4. Optional: To preview the dashboard, select it.
5. Click **Add dashboard to your list** and
   then complete the dialog.

   The dialog lets you select the name of the dashboard,
   and add labels to the dashboard.

For more information about installing dashboards, see [Install a dashboard
template](https://docs.cloud.google.com/monitoring/dashboards/dashboard-templates).