exporters:
  googlecloud:
    metric:
      instrumentation_library_labels: false
      prefix: ""
      resource_filters: []
      service_resource_labels: false
      skip_create_descriptor: true
    user_agent: Google-Cloud-Ops-Agent-Metrics/2.63.0 (BuildDistro=noble;Platform=linux;ShortName=ubuntu;ShortVersion=24.04)
processors:
  agentmetrics/hostmetrics_0:
    blank_label_metrics:
    - system.cpu.utilization
  cumulativetodelta/loggingmetrics_4:
    include:
      match_type: strict
      metrics:
      - otel_log_entry_count
      - otel_log_entry_retry_count
      - otel_request_count
      - fluentbit_log_entry_count
      - fluentbit_log_entry_retry_count
      - fluentbit_request_count
    initial_value: drop
  deltatocumulative/loggingmetrics_6: {}
  filter/default__pipeline_hostmetrics_0:
    metrics:
      exclude:
        match_type: regexp
        metric_names: []
  filter/fluentbit_0:
    metrics:
      include:
        match_type: strict
        metric_names:
        - fluentbit_uptime
  filter/hostmetrics_1:
    metrics:
      exclude:
        match_type: strict
        metric_names:
        - system.network.dropped
        - system.filesystem.inodes.usage
        - system.paging.faults
        - system.disk.operation_time
  filter/loggingmetrics_1:
    metrics:
      datapoint:
      - metric.name == "grpc.client.attempt.duration_count" and (not IsMatch(datapoint.attributes["grpc.target"], "logging.googleapis"))
  filter/loggingmetrics_2:
    metrics:
      include:
        match_type: strict
        metric_names:
        - fluentbit_stackdriver_requests_total
        - fluentbit_stackdriver_proc_records_total
        - fluentbit_stackdriver_retried_records_total
        - otelcol_exporter_sent_log_records
        - otelcol_exporter_send_failed_log_records
        - grpc.client.attempt.duration_count
  filter/otel_1:
    metrics:
      datapoint:
      - metric.name == "grpc.client.attempt.duration_count" and (not IsMatch(datapoint.attributes["grpc.target"], "monitoring.googleapis"))
  filter/otel_2:
    metrics:
      include:
        match_type: strict
        metric_names:
        - otelcol_process_uptime
        - otelcol_process_memory_rss
        - grpc.client.attempt.duration_count
        - googlecloudmonitoring/point_count
  interval/loggingmetrics_7:
    interval: 1m
  metricstransform/fluentbit_1:
    transforms:
    - action: update
      include: fluentbit_uptime
      new_name: agent/uptime
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: version
        new_value: google-cloud-ops-agent-logging/2.63.0-noble
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - version
    - action: update
      include: ^(.*)$$
      match_type: regexp
      new_name: agent.googleapis.com/$${1}
  metricstransform/hostmetrics_2:
    transforms:
    - action: update
      include: system.cpu.time
      new_name: cpu/usage_time
      operations:
      - action: toggle_scalar_data_type
      - action: update_label
        label: cpu
        new_label: cpu_number
      - action: update_label
        label: state
        new_label: cpu_state
    - action: update
      include: system.cpu.utilization
      new_name: cpu/utilization
      operations:
      - action: aggregate_labels
        aggregation_type: mean
        label_set:
        - state
        - blank
      - action: update_label
        label: blank
        new_label: cpu_number
      - action: update_label
        label: state
        new_label: cpu_state
    - action: update
      include: system.cpu.load_average.1m
      new_name: cpu/load_1m
    - action: update
      include: system.cpu.load_average.5m
      new_name: cpu/load_5m
    - action: update
      include: system.cpu.load_average.15m
      new_name: cpu/load_15m
    - action: update
      include: system.disk.read_io
      new_name: disk/read_bytes_count
    - action: update
      include: system.disk.write_io
      new_name: disk/write_bytes_count
    - action: update
      include: system.disk.operations
      new_name: disk/operation_count
    - action: update
      include: system.disk.io_time
      new_name: disk/io_time
      operations:
      - action: experimental_scale_value
        experimental_scale: 1000.0
      - action: toggle_scalar_data_type
    - action: update
      include: system.disk.weighted_io_time
      new_name: disk/weighted_io_time
      operations:
      - action: experimental_scale_value
        experimental_scale: 1000.0
      - action: toggle_scalar_data_type
    - action: update
      include: system.disk.average_operation_time
      new_name: disk/operation_time
      operations:
      - action: experimental_scale_value
        experimental_scale: 1000.0
      - action: toggle_scalar_data_type
    - action: update
      include: system.disk.pending_operations
      new_name: disk/pending_operations
      operations:
      - action: toggle_scalar_data_type
    - action: update
      include: system.disk.merged
      new_name: disk/merged_operations
    - action: update
      include: system.filesystem.usage
      new_name: disk/bytes_used
      operations:
      - action: toggle_scalar_data_type
      - action: aggregate_labels
        aggregation_type: max
        label_set:
        - device
        - state
    - action: update
      include: system.filesystem.utilization
      new_name: disk/percent_used
      operations:
      - action: aggregate_labels
        aggregation_type: max
        label_set:
        - device
        - state
    - action: update
      include: system.memory.usage
      new_name: memory/bytes_used
      operations:
      - action: toggle_scalar_data_type
      - action: aggregate_label_values
        aggregated_values:
        - slab_reclaimable
        - slab_unreclaimable
        aggregation_type: sum
        label: state
        new_value: slab
    - action: update
      include: system.memory.utilization
      new_name: memory/percent_used
      operations:
      - action: aggregate_label_values
        aggregated_values:
        - slab_reclaimable
        - slab_unreclaimable
        aggregation_type: sum
        label: state
        new_value: slab
    - action: update
      include: system.network.io
      new_name: interface/traffic
      operations:
      - action: update_label
        label: interface
        new_label: device
      - action: update_label
        label: direction
        value_actions:
        - new_value: rx
          value: receive
        - new_value: tx
          value: transmit
    - action: update
      include: system.network.errors
      new_name: interface/errors
      operations:
      - action: update_label
        label: interface
        new_label: device
      - action: update_label
        label: direction
        value_actions:
        - new_value: rx
          value: receive
        - new_value: tx
          value: transmit
    - action: update
      include: system.network.packets
      new_name: interface/packets
      operations:
      - action: update_label
        label: interface
        new_label: device
      - action: update_label
        label: direction
        value_actions:
        - new_value: rx
          value: receive
        - new_value: tx
          value: transmit
    - action: update
      include: system.network.connections
      new_name: network/tcp_connections
      operations:
      - action: toggle_scalar_data_type
      - action: delete_label_value
        label: protocol
        label_value: udp
      - action: update_label
        label: state
        new_label: tcp_state
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - tcp_state
      - action: add_label
        new_label: port
        new_value: all
    - action: update
      include: system.processes.created
      new_name: processes/fork_count
    - action: update
      include: system.processes.count
      new_name: processes/count_by_state
      operations:
      - action: toggle_scalar_data_type
      - action: update_label
        label: status
        new_label: state
    - action: update
      include: system.paging.usage
      new_name: swap/bytes_used
      operations:
      - action: toggle_scalar_data_type
    - action: update
      include: system.paging.utilization
      new_name: swap/percent_used
    - action: insert
      include: swap/percent_used
      new_name: pagefile/percent_used
      operations:
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - state
    - action: update
      include: system.paging.operations
      new_name: swap/io
      operations:
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - direction
      - action: update_label
        label: direction
        value_actions:
        - new_value: in
          value: page_in
        - new_value: out
          value: page_out
    - action: update
      include: process.cpu.time
      new_name: processes/cpu_time
      operations:
      - action: experimental_scale_value
        experimental_scale: 1e+06
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: process
        new_value: all
      - action: delete_label_value
        label: state
        label_value: wait
      - action: update_label
        label: state
        new_label: user_or_syst
      - action: update_label
        label: user_or_syst
        value_actions:
        - new_value: syst
          value: system
    - action: update
      include: process.disk.read_io
      new_name: processes/disk/read_bytes_count
      operations:
      - action: add_label
        new_label: process
        new_value: all
    - action: update
      include: process.disk.write_io
      new_name: processes/disk/write_bytes_count
      operations:
      - action: add_label
        new_label: process
        new_value: all
    - action: update
      include: process.memory.usage
      new_name: processes/rss_usage
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: process
        new_value: all
    - action: update
      include: process.memory.virtual
      new_name: processes/vm_usage
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: process
        new_value: all
    - action: update
      include: ^(.*)$$
      match_type: regexp
      new_name: agent.googleapis.com/$${1}
  metricstransform/loggingmetrics_3:
    transforms:
    - action: update
      include: fluentbit_stackdriver_retried_records_total
      new_name: fluentbit_log_entry_retry_count
      operations:
      - action: toggle_scalar_data_type
      - action: update_label
        label: status
        new_label: response_code
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: insert
      include: otelcol_exporter_send_failed_log_records
      new_name: otel_log_entry_retry_count
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: response_code
        new_value: "400"
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: update
      include: fluentbit_stackdriver_requests_total
      new_name: fluentbit_request_count
      operations:
      - action: toggle_scalar_data_type
      - action: update_label
        label: status
        new_label: response_code
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: update
      include: grpc.client.attempt.duration_count
      new_name: otel_request_count
      operations:
      - action: update_label
        label: grpc.status
        new_label: response_code
      - action: update_label
        label: response_code
        value_actions:
        - new_value: "409"
          value: ABORTED
        - new_value: "409"
          value: ALREADY_EXISTS
        - new_value: "499"
          value: CANCELLED
        - new_value: "500"
          value: DATA_LOSS
        - new_value: "504"
          value: DEADLINE_EXCEEDED
        - new_value: "400"
          value: FAILED_PRECONDITION
        - new_value: "500"
          value: INTERNAL
        - new_value: "400"
          value: INVALID_ARGUMENT
        - new_value: "404"
          value: NOT_FOUND
        - new_value: "200"
          value: OK
        - new_value: "400"
          value: OUT_OF_RANGE
        - new_value: "403"
          value: PERMISSION_DENIED
        - new_value: "429"
          value: RESOURCE_EXHAUSTED
        - new_value: "401"
          value: UNAUTHENTICATED
        - new_value: "503"
          value: UNAVAILABLE
        - new_value: "501"
          value: UNIMPLEMENTED
        - new_value: "500"
          value: UNKNOWN
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: update
      include: fluentbit_stackdriver_proc_records_total
      new_name: fluentbit_log_entry_count
      operations:
      - action: toggle_scalar_data_type
      - action: update_label
        label: status
        new_label: response_code
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: update
      include: otelcol_exporter_sent_log_records
      new_name: otel_log_entry_count
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: response_code
        new_value: "200"
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: update
      include: otelcol_exporter_send_failed_log_records
      new_name: otel_log_entry_count
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: response_code
        new_value: "400"
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
    - action: combine
      include: ^otel_log_entry_count$$
      match_type: regexp
      new_name: otel_log_entry_count
      operations:
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - response_code
      submatch_case: lower
  metricstransform/loggingmetrics_8:
    transforms:
    - action: update
      include: ^(.*)$$
      match_type: regexp
      new_name: agent.googleapis.com/$${1}
  metricstransform/otel_3:
    transforms:
    - action: update
      include: otelcol_process_uptime
      new_name: agent/uptime
      operations:
      - action: toggle_scalar_data_type
      - action: add_label
        new_label: version
        new_value: google-cloud-ops-agent-metrics/2.63.0-noble
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - version
    - action: update
      include: otelcol_process_memory_rss
      new_name: agent/memory_usage
      operations:
      - action: aggregate_labels
        aggregation_type: sum
        label_set: []
    - action: update
      include: grpc.client.attempt.duration_count
      new_name: agent/api_request_count
      operations:
      - action: update_label
        label: grpc.status
        new_label: state
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - state
    - action: update
      include: googlecloudmonitoring/point_count
      new_name: agent/monitoring/point_count
      operations:
      - action: toggle_scalar_data_type
      - action: aggregate_labels
        aggregation_type: sum
        label_set:
        - status
    - action: update
      include: ^(.*)$$
      match_type: regexp
      new_name: agent.googleapis.com/$${1}
  resourcedetection/_global_0:
    detectors:
    - gcp
  transform/agent_prometheus_0:
    metric_statements:
    - context: metric
      statements:
      - delete_key(resource.attributes, "service.name")
      - delete_key(resource.attributes, "service.version")
      - delete_key(resource.attributes, "service.instance.id")
      - delete_key(resource.attributes, "server.port")
      - delete_key(resource.attributes, "url.scheme")
  transform/loggingmetrics_0:
    error_mode: ignore
    metric_statements:
    - context: metric
      statements:
      - extract_count_metric(true) where name == "grpc.client.attempt.duration"
  transform/loggingmetrics_5:
    metric_statements:
    - context: metric
      statements:
      - set(unit, "1")
    - context: datapoint
      statements:
      - set(time, Now())
      - set(start_time_unix_nano, 0)
      - set(metric.name, "agent/log_entry_count") where metric.name == "fluentbit_log_entry_count"
      - set(metric.name, "agent/log_entry_retry_count") where metric.name == "fluentbit_log_entry_retry_count"
      - set(metric.name, "agent/request_count") where metric.name == "fluentbit_request_count"
      - set(metric.name, "agent/log_entry_count") where metric.name == "otel_log_entry_count"
      - set(metric.name, "agent/log_entry_retry_count") where metric.name == "otel_log_entry_retry_count"
      - set(metric.name, "agent/request_count") where metric.name == "otel_request_count"
  transform/ops_agent_0:
    error_mode: ignore
    metric_statements:
    - context: datapoint
      statements:
      - set(time, Now())
  transform/otel_0:
    error_mode: ignore
    metric_statements:
    - context: metric
      statements:
      - extract_count_metric(true) where name == "grpc.client.attempt.duration"
receivers:
  hostmetrics/hostmetrics:
    collection_interval: 60s
    scrapers:
      cpu: {}
      disk: {}
      filesystem: {}
      load: {}
      memory: {}
      network: {}
      paging: {}
      process:
        mute_process_all_errors: true
        mute_process_exe_error: true
        mute_process_name_error: true
      processes: {}
  otlpjsonfile/ops_agent:
    include:
    - /run/google-cloud-ops-agent-opentelemetry-collector/enabled_receivers_otlp.json
    - /run/google-cloud-ops-agent-opentelemetry-collector/feature_tracking_otlp.json
    poll_interval: 1m0s
    replay_file: true
  prometheus/agent_prometheus:
    config:
      scrape_configs:
      - job_name: logging-collector
        metrics_path: /metrics
        scrape_interval: 1m
        static_configs:
        - targets:
          - 0.0.0.0:20202
      - job_name: otel-collector
        scrape_interval: 1m
        static_configs:
        - targets:
          - 0.0.0.0:20201
service:
  pipelines:
    metrics/default__pipeline_hostmetrics:
      exporters:
      - googlecloud
      processors:
      - agentmetrics/hostmetrics_0
      - filter/hostmetrics_1
      - metricstransform/hostmetrics_2
      - filter/default__pipeline_hostmetrics_0
      - resourcedetection/_global_0
      receivers:
      - hostmetrics/hostmetrics
    metrics/fluentbit:
      exporters:
      - googlecloud
      processors:
      - transform/agent_prometheus_0
      - filter/fluentbit_0
      - metricstransform/fluentbit_1
      - resourcedetection/_global_0
      receivers:
      - prometheus/agent_prometheus
    metrics/loggingmetrics:
      exporters:
      - googlecloud
      processors:
      - transform/agent_prometheus_0
      - transform/loggingmetrics_0
      - filter/loggingmetrics_1
      - filter/loggingmetrics_2
      - metricstransform/loggingmetrics_3
      - cumulativetodelta/loggingmetrics_4
      - transform/loggingmetrics_5
      - deltatocumulative/loggingmetrics_6
      - interval/loggingmetrics_7
      - metricstransform/loggingmetrics_8
      - resourcedetection/_global_0
      receivers:
      - prometheus/agent_prometheus
    metrics/opsagent:
      exporters:
      - googlecloud
      processors:
      - transform/ops_agent_0
      - resourcedetection/_global_0
      receivers:
      - otlpjsonfile/ops_agent
    metrics/otel:
      exporters:
      - googlecloud
      processors:
      - transform/agent_prometheus_0
      - transform/otel_0
      - filter/otel_1
      - filter/otel_2
      - metricstransform/otel_3
      - resourcedetection/_global_0
      receivers:
      - prometheus/agent_prometheus
  telemetry:
    metrics:
      readers:
      - pull:
          exporter:
            prometheus:
              host: 0.0.0.0
              port: 20201
              without_scope_info: true
              without_type_suffix: true
              without_units: true

