פריסת OpenTelemetry Collector במערכת הפעלה שמותאמת לקונטיינרים

כדי לאסוף יומנים, מדדים ומעקבים של OTLP מאפליקציות עם אינסטרומנטציה ולייצא את הנתונים האלה אל Google Cloud, אתם יכולים להריץ את הקונטיינר של Google-Built OpenTelemetry Collector במערכת הפעלה שמותאמת לקונטיינרים.

לפני שמתחילים

כדי להריץ את OpenTelemetry Collector, צריך את המשאבים הבאים:

  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. מכונה וירטואלית (VM) של מערכת הפעלה שמותאמת לקונטיינרים. אם אין לכם מכונה וירטואלית עם מערכת הפעלה שמותאמת לקונטיינרים, אתם יכולים לפעול לפי ההוראות במאמר יצירה והגדרה של מכונות.
  5. התקנה של gcloud. מידע נוסף על התקנת gcloud זמין במאמר התקנת Google Cloud CLI.

הגדרת הרשאות ל-Collector

כברירת מחדל, במכונות וירטואליות של מערכת הפעלה שמותאמת לקונטיינרים נעשה שימוש בחשבון השירות שמוגדר כברירת מחדל של Compute Engine, ‏PROJECT_NUMBER-compute@. בדרך כלל, לחשבון השירות הזה יש את התפקידים של ניהול זהויות והרשאות גישה (IAM) שנדרשים כדי לכתוב את נתוני הטלמטריה שמתוארים במסמך הזה:

אם אתם מגדירים חשבון שירות בהתאמה אישית למכונה, קראו את המאמר ניהול הגישה לחשבונות שירות.

פריסת ה-Collector

כדי להריץ את Google-Built OpenTelemetry Collector, צריך לספק קובץ תצורה למכונה הווירטואלית של מערכת ההפעלה שמותאמת לקונטיינרים. אפשר להשתמש בכלי cloud-init כדי לכתוב קובץ תצורה. הקובץ הבא של cloud-init מומלץ לשימוש ב-Collector שנוצר על ידי 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

מומלץ ליצור רשת Docker bridge כדי לאפשר תקשורת בין הקונטיינר של Collector לבין כל קונטיינר אחר במערכת שישלח נתוני טלמטריה. כדי ליצור את הרשת, מריצים את הפקודה הבאה:

docker network create -d bridge otel

מריצים את מאגר ה-Collector באמצעות הפקודה הבאה:

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

הפקודה הקודמת מבצעת את הפעולות הבאות:

  • מפעילה את מאגר הנתונים של Collector ברקע.
  • מצרף את מאגר ה-Collector לרשת הגשר otel שנוצרה קודם. אפשר לחבר קונטיינרים אחרים לגשר כדי לשלוח נתוני טלמטריה.
  • הפקודה הזו טוענת את קובץ התצורה בקונטיינר כדי שאפשר יהיה לגשת לקובץ ולהגדיר את ה-Collector.

הגדרת ה-Collector

אנחנו מספקים הגדרה של OpenTelemetry Collector לשימוש עם ה-Collector ש-Google פיתחה. ההגדרה הזו נועדה להעביר כמויות גדולות של מדדים, יומנים ומעקבים של OTLP. ההגדרה הזו גם נועדה למנוע בעיות נפוצות בהטמעה. אפשר להוסיף להגדרות, אבל מומלץ מאוד לא להסיר רכיבים.

בקטע הזה מתוארים ההגדרות שסופקו, הרכיבים העיקריים כמו מייצאים, מעבדים, מקלטים ורכיבים זמינים אחרים.

הגדרת Collector שסופקה

אפשר למצוא את הגדרות ה-Collector בספרייה google-built-opentelemetry-collector במאגר 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

יצואנים

הגדרת ה-Collector משתמשת בפרטים הבאים:

מעבדים

ההגדרות של Collector כוללות את המעבדים הבאים:

  • ‫batch: מוגדר לאסוף בקשות טלמטריה באצווה לפי Google Cloud המספר המקסימלי של רשומות לכל בקשה, או לפי Google Cloud המרווח המינימלי של כל 5 שניות (המוקדם מביניהם).

  • ‫memory_limiter: מגדירה את מגבלת השימוש בזיכרון של ה-Collector כדי למנוע קריסות בגלל מחסור בזיכרון, על ידי השמטת נקודות על הגרף כשחורגים מהמגבלה.

  • ‫resourcedetection: זיהוי אוטומטי של תוויות משאבים ב- Google Cloud , כמו project_id.

מקלטים

ההגדרות של Collector כוללות רק את המקלט otlp. במאמר בחירת גישה למדידת ביצועים מוסבר איך להגדיר את האפליקציות כך שישלחו עקבות ומדדים של OTLP לנקודת הקצה של ה-Collector.

רכיבים זמינים

ה-Google-Built OpenTelemetry Collector מכיל את הרכיבים שרוב המשתמשים צריכים כדי להפעיל חוויה עשירה ב-Google Cloud Observability. רשימה מלאה של הרכיבים הזמינים מופיעה בקטע Components במאגר opentelemetry-operations-collector.

כדי לבקש שינויים או תוספות לרכיבים הזמינים, הגישו בקשה להוספת תכונה במאגר opentelemetry-operations-collector.

יצירת טלמטריה

אפשר לבדוק את ההגדרות באמצעות הכלי telemetrygen בקוד פתוח. בפרויקט OpenTelemetry יש קונטיינר ב-Container Registry של GitHub.

אם שיניתם את ברירות המחדל שבהן השתמשתם בפקודות Docker בקטע פריסת ה-Collector, לפני שתריצו את הפקודות הבאות, החליפו את הפלייסהולדרים הבאים:

  • ‫otel: השם שציינתם כשיצרתם את רשת Docker bridge.
  • ‫opentelemetry-collector: השם שציינתם כשהפעלתם את הקונטיינר.

יצירת יומנים

כדי ליצור יומנים באמצעות הכלי telemetrygen, מריצים את הפקודה הבאה:

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

יצירת מדדים

כדי ליצור מדדים באמצעות הכלי telemetrygen, מריצים את הפקודה הבאה:

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

יצירת מעקבים

כדי ליצור מעקבים באמצעות הכלי telemetrygen, מריצים את הפקודה הבאה:

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

אחרי כמה דקות, נתוני הטלמטריה שנוצרו על ידי האפליקציה מתחילים לזרום דרך ה-Collector למסוף Google Cloud לכל אות.

הצגת נתוני הטלמטריה

הכלי Google-Built OpenTelemetry Collector שולח מדדים, יומנים ומעקבים מהאפליקציות עם האינסטרומנטציה אל Google Cloud Observability. ה-Collector גם שולח מדדי תצפיתיות עצמית. בקטעים הבאים מוסבר איך לצפות בנתוני הטלמטריה האלה.

איך רואים את המדדים

הכלי Google-Built OpenTelemetry Collector אוסף מדדים של Prometheus, שאפשר לראות באמצעות Metrics Explorer. המדדים שנאספים תלויים במכשור של האפליקציה, אבל ה-Collector שנוצר על ידי Google כותב גם כמה מדדים עצמיים.

כדי לראות את המדדים שנאספו על ידי Google-Built OpenTelemetry Collector:
  1. במסוף Google Cloud , נכנסים לדף  Metrics explorer:

    כניסה לדף Metrics Explorer

    אם אתם משתמשים בשורת החיפוש כדי למצוא את הדף הזה, בחרו בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. בסרגל הכלים של מסוף Google Cloud , בוחרים את הפרויקט ב- Google Cloud . בהגדרות של App Hub, בוחרים את הפרויקט המארח של App Hub או את פרויקט הניהול של התיקייה לניהול אפליקציות.
  3. ברכיב Metric, מרחיבים את התפריט Select a metric, מזינים Prometheus Target בסרגל הסינון ומשתמשים בתפריטי המשנה כדי לבחור את סוג המשאב הספציפי ואת המדד:
    1. בתפריט Active resources בוחרים באפשרות Prometheus Target.
    2. כדי לבחור מדד, משתמשים בתפריטים Active metric categories ו-Active metrics. למדדים שנאספים על ידי Google-Built OpenTelemetry Collector יש את הקידומת prometheus.googleapis.com.
    3. לוחצים על אישור.
  4. כדי להוסיף מסננים שמסירים סדרות זמנים מתוצאות השאילתה, משתמשים ברכיב Filter.

  5. מגדירים את אופן התצוגה של הנתונים.

    כשהמדידות של מדד מסוים הן מצטברות, הכלי Metrics Explorer מנרמל באופן אוטומטי את הנתונים שנמדדו לפי תקופת ההתאמה, וכתוצאה מכך בתרשים מוצג שיעור. למידע נוסף, ראו סוגים, טיפוסים והמרות.

    כשמודדים ערכים של מספרים שלמים או ערכים כפולים, כמו במדדי counter, הכלי Metrics Explorer מסכם באופן אוטומטי את כל סדרות הזמנים. כדי לשנות את ההתנהגות הזו, מגדירים את התפריט הראשון של הרשומה Aggregation לערך None.

    מידע נוסף על הגדרת תרשים זמין במאמר איך בוחרים מדדים כשמשתמשים ב-Metrics Explorer.

הצגת המעקבים

כדי להציג את נתוני המעקב:

  1. במסוף Google Cloud , נכנסים לדף Trace explorer:

    כניסה לדף Trace Explorer

    אפשר גם למצוא את הדף הזה באמצעות שורת החיפוש.

  2. בסרגל הכלים של מסוף Google Cloud , בוחרים את הפרויקט ב- Google Cloud . בהגדרות של App Hub, בוחרים את הפרויקט המארח או את פרויקט הניהול של App Hub.
  3. בקטע של הטבלה בדף, בוחרים שורה.
  4. בתרשים הגאנט שבחלונית Trace details, בוחרים span.

    נפתח חלון שבו מוצג מידע על הבקשה שנבדקה. הפרטים האלה כוללים את השיטה, קוד הסטטוס, מספר הבייטים וסוכן המשתמש של מבצע הקריאה.

  5. כדי לראות את היומנים שמשויכים למעקב הזה, בוחרים בכרטיסייה Logs & Events.

    בכרטיסייה מוצגים יומנים נפרדים. כדי לראות את הפרטים של הרשומה ביומן, מרחיבים אותה. אפשר גם ללחוץ על View Logs כדי לראות את היומן באמצעות Logs Explorer.

מידע נוסף על השימוש ב-Cloud Trace Explorer זמין במאמר חיפוש ועיון במעקבים.

הצגת רישומי היומן

ב-Logs Explorer אתם יכולים לבדוק את היומנים, וגם לראות את המעקבים שמשויכים אליהם, אם יש כאלה.

  1. במסוף Google Cloud , נכנסים לדף Logs Explorer של :

    נכנסים ל-Logs Explorer.

    אם אתם משתמשים בשורת החיפוש כדי למצוא את הדף הזה, בחרו בתוצאה עם כותרת המשנה Logging.

  2. מאתרים רשומת יומן מהאפליקציה עם כלי המדידה ומרחיבים את הרשומה כדי לראות את הפרטים.

  3. לוחצים על Traces ברשומת יומן עם הודעת מעקב, ובוחרים באפשרות View trace details.

    החלונית Trace details נפתחת ומוצג בה המעקב שנבחר.

למידע נוסף על השימוש ב-Logs Explorer, קראו את המאמר הצגת יומנים באמצעות Logs Explorer.

מעקב אחרי ה-Collector וניפוי באגים

הכלי Google-Built OpenTelemetry Collector מספק באופן אוטומטי מדדי תצפית עצמית, כדי לעזור לכם לעקוב אחרי הביצועים שלו ולוודא שצינור עיבוד הנתונים של הטמעת OTLP פועל באופן תקין.

כדי לעקוב אחרי ה-Collector, מתקינים את לוח הבקרה לדוגמה של ה-Collector. בלוח הבקרה הזה מוצגות תובנות במבט מהיר על כמה מדדים מה-Collector, כולל זמן פעולה תקינה, שימוש בזיכרון וקריאות ל-API אל Google Cloud Observability.

כדי להתקין את מרכז הבקרה:

  1. נכנסים לדף  Dashboards במסוף Google Cloud :

    עוברים אל מרכזי בקרה.

    אם אתם משתמשים בשורת החיפוש כדי למצוא את הדף הזה, בחרו בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. לוחצים על תבניות של מרכזי בקרה.
  3. מחפשים את מרכז הבקרה OpenTelemetry Collector.
  4. אופציונלי: כדי לראות תצוגה מקדימה של מרכז הבקרה, בוחרים אותו.
  5. לוחצים על Add dashboard to your list וממלאים את הפרטים בתיבת הדו-שיח.

    בתיבת הדו-שיח אפשר לבחור את שם לוח הבקרה ולהוסיף לו תוויות.

מידע נוסף על התקנת מרכזי בקרה זמין במאמר התקנת תבנית של מרכז בקרה.