Men-deploy OpenTelemetry Collector di Container-Optimized OS

Untuk mengumpulkan log, metrik, dan trace OTLP dari aplikasi yang diinstrumentasi dan mengekspor data tersebut ke Google Cloud, Anda dapat menjalankan container OpenTelemetry Collector Buatan Google di Container-Optimized OS.

Sebelum memulai

Menjalankan OpenTelemetry Collector memerlukan resource berikut:

  1. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that billing is enabled for your Google Cloud project.

  3. Enable the Cloud Logging, Cloud Monitoring, and Cloud Trace APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  4. Virtual machine (VM) Container-Optimized OS. Jika Anda tidak memiliki VM Container-Optimized OS, ikuti petunjuk di Membuat dan mengonfigurasi instance.
  5. Penginstalan gcloud. Untuk mengetahui informasi tentang cara menginstal gcloud, lihat Menginstal Google Cloud CLI.

Mengonfigurasi izin untuk Kolektor

Secara default, VM Container-Optimized OS menggunakan akun layanan default Compute Engine, PROJECT_NUMBER-compute@. Akun layanan ini biasanya memiliki peran Identity and Access Management (IAM) yang diperlukan untuk menulis telemetri yang dijelaskan dalam dokumen ini:

Jika Anda mengonfigurasi akun layanan kustom untuk instance, lihat Mengelola akses ke akun layanan.

Men-deploy Kolektor

Untuk menjalankan Google-Built OpenTelemetry Collector, Anda harus menyediakan file konfigurasi untuk VM Container-Optimized OS Anda. Anda dapat menggunakan alat cloud-init untuk menulis file konfigurasi. Berikut adalah file cloud-init yang direkomendasikan untuk menggunakan Collector buatan Google:

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 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:
      # Dedicated OTLP gRPC exporters are configured per signal (logs, metrics, traces)
      # so each sending queue and batch size matches the Cloud Telemetry API quotas:
      # https://docs.cloud.google.com/stackdriver/quotas
      #
      # Note: In addition to per-request item limits (8,192 for logs/traces, 200 for
      # metrics), the API enforces a 5 MiB request size limit. An 8,192-item batch
      # stays under 5 MiB only when the average log or span is under ~640 bytes. If
      # your payloads are larger, reduce `max_size` or set `sending_queue.batch.sizer: bytes`
      # and update `min_size` and `max_size` with byte limits that make sense for your deployment.
      #
      # For `telemetry.googleapis.com:443`, `sending_queue.num_consumers` can be increased up to 100
      # per exporter if you have the CPU and network bandwidth to increase request concurrency.
      #
      # Docs:
      # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter
      otlp_grpc/logs:
        endpoint: telemetry.googleapis.com:443
        balancer_name: pick_first
        auth:
          authenticator: googleclientauth
        sending_queue:
          enabled: true
          sizer: bytes
          queue_size: 20971520 # 20 MiB queue bound
          block_on_overflow: true
          num_consumers: 25
          batch:
            sizer: items
            min_size: 8192
            max_size: 8192
            flush_timeout: 1s

      otlp_grpc/metrics:
        endpoint: telemetry.googleapis.com:443
        balancer_name: pick_first
        auth:
          authenticator: googleclientauth
        sending_queue:
          enabled: true
          sizer: bytes
          queue_size: 20971520 # 20 MiB queue bound
          block_on_overflow: true
          num_consumers: 25
          batch:
            sizer: items
            min_size: 200
            max_size: 200
            flush_timeout: 1s

      otlp_grpc/traces:
        endpoint: telemetry.googleapis.com:443
        balancer_name: pick_first
        auth:
          authenticator: googleclientauth
        sending_queue:
          enabled: true
          sizer: bytes
          queue_size: 20971520 # 20 MiB queue bound
          block_on_overflow: true
          num_consumers: 25
          batch:
            sizer: items
            min_size: 8192
            max_size: 8192
            flush_timeout: 1s

    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
          exporters:
          - otlp_grpc/logs
        metrics/otlp:
          receivers:
          - otlp
          processors:
          - resourcedetection
          - resource/gcp_project_id
          - transform/collision
          - transform/prometheus_unknown_types
          - metricstarttime
          - memory_limiter
          exporters:
          - otlp_grpc/metrics
        traces:
          receivers:
          - otlp
          processors:
          - resourcedetection
          - resource/gcp_project_id
          - memory_limiter
          exporters:
          - otlp_grpc/traces
      # 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

Sebaiknya buat jaringan bridge Docker untuk memfasilitasi komunikasi antara container Collector dan container lain di sistem yang akan mengirim telemetri. Untuk membuat jaringan, jalankan perintah berikut:

docker network create -d bridge otel

Jalankan container Collector dengan perintah berikut:

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.165.2-r.1 \
    --config=/etc/config/config.yaml

Perintah sebelumnya melakukan hal berikut:

  • Menjalankan container Collector di latar belakang.
  • Memasang container Collector ke jaringan bridge otel yang dibuat sebelumnya. Penampung lain dapat dihubungkan ke perantara untuk mengirim telemetri.
  • Memasang file konfigurasi Anda di container sehingga file tersebut dapat diakses untuk mengonfigurasi Collector.

Mengonfigurasi Kolektor

Kami menyediakan konfigurasi OpenTelemetry Collector untuk Anda gunakan dengan Collector buatan Google. Konfigurasi ini dirancang untuk mengirimkan metrik, log, dan trace OTLP dalam volume tinggi. Konfigurasi ini juga dirancang untuk mencegah masalah penyerapan yang umum. Anda dapat menambahkan konfigurasi, tetapi sebaiknya jangan menghapus elemen.

Bagian ini menjelaskan konfigurasi yang disediakan, komponen utama seperti pengekspor, pemroses, penerima, dan komponen lain yang tersedia.

Konfigurasi Kolektor yang disediakan

Anda dapat menemukan konfigurasi Collector di direktori google-built-opentelemetry-collector pada repositori opentelemetry-operations-collector:

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 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:
  # Dedicated OTLP gRPC exporters are configured per signal (logs, metrics, traces)
  # so each sending queue and batch size matches the Cloud Telemetry API quotas:
  # https://docs.cloud.google.com/stackdriver/quotas
  #
  # Note: In addition to per-request item limits (8,192 for logs/traces, 200 for
  # metrics), the API enforces a 5 MiB request size limit. An 8,192-item batch
  # stays under 5 MiB only when the average log or span is under ~640 bytes. If
  # your payloads are larger, reduce `max_size` or set `sending_queue.batch.sizer: bytes`
  # and update `min_size` and `max_size` with byte limits that make sense for your deployment.
  #
  # For `telemetry.googleapis.com:443`, `sending_queue.num_consumers` can be increased up to 100
  # per exporter if you have the CPU and network bandwidth to increase request concurrency.
  #
  # Docs:
  # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter
  otlp_grpc/logs:
    endpoint: telemetry.googleapis.com:443
    balancer_name: pick_first
    auth:
      authenticator: googleclientauth
    sending_queue:
      enabled: true
      sizer: bytes
      queue_size: 20971520 # 20 MiB queue bound
      block_on_overflow: true
      num_consumers: 25
      batch:
        sizer: items
        min_size: 8192
        max_size: 8192
        flush_timeout: 1s

  otlp_grpc/metrics:
    endpoint: telemetry.googleapis.com:443
    balancer_name: pick_first
    auth:
      authenticator: googleclientauth
    sending_queue:
      enabled: true
      sizer: bytes
      queue_size: 20971520 # 20 MiB queue bound
      block_on_overflow: true
      num_consumers: 25
      batch:
        sizer: items
        min_size: 200
        max_size: 200
        flush_timeout: 1s

  otlp_grpc/traces:
    endpoint: telemetry.googleapis.com:443
    balancer_name: pick_first
    auth:
      authenticator: googleclientauth
    sending_queue:
      enabled: true
      sizer: bytes
      queue_size: 20971520 # 20 MiB queue bound
      block_on_overflow: true
      num_consumers: 25
      batch:
        sizer: items
        min_size: 8192
        max_size: 8192
        flush_timeout: 1s

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
      exporters:
      - otlp_grpc/logs
    metrics/otlp:
      receivers:
      - otlp
      processors:
      - resourcedetection
      - resource/gcp_project_id
      - transform/collision
      - transform/prometheus_unknown_types
      - metricstarttime
      - memory_limiter
      exporters:
      - otlp_grpc/metrics
    traces:
      receivers:
      - otlp
      processors:
      - resourcedetection
      - resource/gcp_project_id
      - memory_limiter
      exporters:
      - otlp_grpc/traces
  # 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

Eksportir

Konfigurasi Collector menggunakan hal berikut:

Prosesor

Konfigurasi Collector mencakup pemroses berikut:

  • batch: Dikonfigurasi untuk mengelompokkan permintaan telemetri pada Google Cloud jumlah maksimum entri per permintaan, atau pada Google Cloud interval minimum setiap 5 detik (mana saja yang tercapai lebih dulu).

  • memory_limiter: Membatasi penggunaan memori Collector untuk mencegah error kehabisan memori dengan menghapus titik data saat batas terlampaui.

  • resourcedetection: Mendeteksi label resource Google Cloud secara otomatis seperti project_id.

Penerima

Konfigurasi Collector hanya mencakup penerima otlp. Untuk mengetahui informasi tentang cara melengkapi aplikasi Anda untuk mengirim trace dan metrik OTLP ke endpoint OTLP Kolektor, lihat Memilih pendekatan instrumentasi.

Komponen yang tersedia

Google-Built OpenTelemetry Collector berisi komponen yang akan dibutuhkan sebagian besar pengguna untuk mengaktifkan pengalaman yang kaya dalam Google Cloud Observability. Untuk mengetahui daftar lengkap komponen yang tersedia, lihat Komponen di repositori opentelemetry-operations-collector.

Untuk meminta perubahan atau penambahan pada komponen yang tersedia, buka permintaan fitur. di repositori opentelemetry-operations-collector.

Membuat telemetri

Anda dapat menguji konfigurasi menggunakan alat telemetrygen open source. Project OpenTelemetry menyediakan container di GitHub Container Registry.

Sebelum menjalankan perintah berikut, ganti placeholder berikut, jika Anda mengubah default yang digunakan dalam perintah Docker di Men-deploy Kolektor:

  • otel: Nama yang Anda tentukan saat membuat jaringan bridge Docker.
  • opentelemetry-collector: Nama yang Anda tentukan saat menjalankan container.

Membuat log

Untuk membuat log menggunakan alat telemetrygen, jalankan perintah berikut:

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

Membuat metrik

Untuk membuat metrik menggunakan alat telemetrygen, jalankan perintah berikut:

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

Membuat trace

Untuk membuat trace menggunakan alat telemetrygen, jalankan perintah berikut:

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

Setelah beberapa menit, telemetri yang dihasilkan oleh aplikasi akan mulai mengalir melalui Collector ke konsol Google Cloud untuk setiap sinyal.

Melihat telemetri

OpenTelemetry Collector Buatan Google mengirimkan metrik, log, dan trace dari aplikasi yang diinstrumentasi ke Google Cloud Observability. Kolektor juga mengirimkan metrik kemampuan observasi mandiri. Bagian berikut menjelaskan cara melihat telemetri ini.

Melihat metrik Anda

Kolektor OpenTelemetry Buatan Google mengumpulkan metrik Prometheus yang dapat Anda lihat menggunakan Metrics Explorer. Metrik yang dikumpulkan bergantung pada instrumentasi aplikasi, meskipun Collector yang dibuat Google juga menulis beberapa metrik mandiri.

Untuk melihat metrik yang dikumpulkan oleh Kolektor OpenTelemetry Buatan Google, lakukan hal berikut:
  1. Di konsol Google Cloud , buka halaman  Metrics explorer:

    Buka Metrics explorer

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Monitoring.

  2. Di toolbar konsol Google Cloud , pilih project Google Cloud Anda. Untuk konfigurasi App Hub, pilih project host App Hub atau project pengelolaan folder khusus aplikasi.
  3. Pada elemen Metric, luaskan menu Select a metric, masukkan Prometheus Target di panel filter, lalu gunakan submenu untuk memilih jenis dan metrik resource tertentu:
    1. Di menu Active resources, pilih Prometheus Target.
    2. Untuk memilih metrik, gunakan menu Kategori metrik aktif dan Metrik aktif. Metrik yang dikumpulkan oleh OpenTelemetry Collector Buatan Google memiliki awalan prometheus.googleapis.com.
    3. Klik Terapkan.
  4. Untuk menambahkan filter, yang menghapus deret waktu dari hasil kueri, gunakan elemen Filter.

  5. Konfigurasi cara data dilihat.

    Jika pengukuran untuk metrik bersifat kumulatif, Metrics Explorer akan otomatis menormalisasi data yang diukur berdasarkan periode penyelarasan, sehingga diagram menampilkan rasio. Untuk mengetahui informasi selengkapnya, lihat Jenis, tipe, dan konversi.

    Saat nilai bilangan bulat atau ganda diukur, seperti dengan metrik counter, Metrics Explorer akan otomatis menjumlahkan semua deret waktu. Untuk mengubah perilaku ini, tetapkan menu pertama entri Aggregation ke None.

    Untuk mengetahui informasi selengkapnya tentang cara mengonfigurasi diagram, lihat Memilih metrik saat menggunakan Metrics Explorer.

Melihat trace Anda

Untuk melihat data trace, lakukan hal berikut:

  1. Di konsol Google Cloud , buka halaman Trace explorer:

    Buka Trace explorer

    Anda juga dapat menemukan halaman ini menggunakan kotak penelusuran.

  2. Di toolbar konsol Google Cloud , pilih project Google Cloud Anda. Untuk konfigurasi App Hub, pilih project host atau project pengelolaan App Hub.
  3. Di bagian tabel halaman, pilih baris.
  4. Di diagram Gantt pada panel Trace details, pilih span.

    Panel yang menampilkan informasi tentang permintaan yang dilacak akan terbuka. Detail ini mencakup metode, kode status, jumlah byte, dan agen pengguna pemanggil.

  5. Untuk melihat log yang terkait dengan trace ini, pilih tab Logs & Events.

    Tab ini menampilkan setiap log. Untuk melihat detail entri log, perluas entri log. Anda juga dapat mengklik View Logs dan melihat log menggunakan Logs Explorer.

Untuk mengetahui informasi selengkapnya tentang cara menggunakan Cloud Trace Explorer, lihat Menemukan dan menjelajahi trace.

Melihat log

Dari Logs Explorer, Anda dapat memeriksa log, dan Anda juga dapat melihat trace terkait, jika ada.

  1. Di konsol Google Cloud , buka halaman segmen:

    Buka Logs Explorer

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Logging.

  2. Temukan entri log dari aplikasi yang diinstrumentasikan. Untuk melihat detailnya, luaskan entri log.

  3. Klik Traces pada entri log dengan pesan trace, lalu pilih View trace details.

    Panel Trace details akan terbuka dan menampilkan trace yang dipilih.

Untuk mengetahui informasi selengkapnya tentang cara menggunakan Logs Explorer, lihat Melihat log menggunakan Logs Explorer.

Mengamati dan men-debug Collector

Google-Built OpenTelemetry Collector otomatis menyediakan metrik kemampuan observasi mandiri untuk membantu Anda memantau performanya dan memastikan waktu beroperasi berkelanjutan dari pipeline penyerapan OTLP.

Untuk memantau Collector, instal contoh dasbor untuk Collector. Dasbor ini menawarkan insight sekilas tentang beberapa metrik dari Collector, termasuk waktu beroperasi, penggunaan memori, dan panggilan API ke Google Cloud Observability.

Untuk menginstal dasbor, lakukan hal berikut:

  1. Di konsol Google Cloud , buka halaman  Dashboards:

    Buka Dashboards

    Jika Anda menggunakan kotak penelusuran untuk menemukan halaman ini, pilih hasil yang subjudulnya adalah Monitoring.

  2. Klik Dashboard Templates.
  3. Telusuri dasbor OpenTelemetry Collector.
  4. Opsional: Untuk melihat pratinjau dasbor, pilih dasbor tersebut.
  5. Klik Add dashboard to your list, lalu lengkapi dialog.

    Dialog ini memungkinkan Anda memilih nama dasbor, dan menambahkan label ke dasbor.

Untuk mengetahui informasi selengkapnya tentang cara menginstal dasbor, lihat Menginstal template dasbor.