# ADOT (AWS Distro for OpenTelemetry) Collector config — dual-export reference
#
# Pattern: instrument once with OpenTelemetry, send TRACES to CloudWatch
# Application Signals / X-Ray (for the service map + SLOs) and METRICS to
# Amazon Managed Service for Prometheus (for PromQL + high-cardinality infra).
# This keeps instrumentation vendor-portable while using each backend for what
# it is best at.
#
# Setup assumed: ADOT Collector v0.40+ running as a sidecar/daemonset with an
# IAM role allowing aps:RemoteWrite to your AMP workspace and X-Ray write.
# Verify exporter names against the ADOT release you deploy - exporter configs
# change across versions.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  # COST CONTROL LIVES HERE. Drop noisy metrics before they are ingested -
  # ingestion is the largest AMP cost driver. Edit the regexp to keep only
  # what you alert or dashboard on.
  filter/keep_useful_metrics:
    metrics:
      include:
        match_type: regexp
        metric_names:
          - "^http_server_.*"
          - "^http_client_.*"
          - "^.*_request_duration_seconds.*"
          - "^node_(cpu|memory|filesystem)_.*"
          - "^kube_(pod|deployment)_.*"
  batch:
    timeout: 30s
  resourcedetection:
    detectors: [env, ec2, ecs, eks]
    timeout: 5s

exporters:
  # METRICS -> Amazon Managed Service for Prometheus (remote write)
  prometheusremotewrite:
    endpoint: "https://aps-workspaces.<REGION>.amazonaws.com/workspaces/<WORKSPACE_ID>/api/v1/remote_write"
    auth:
      authenticator: sigv4auth
  # TRACES -> X-Ray (feeds CloudWatch Application Signals service map + SLOs)
  awsxray:
    region: "<REGION>"

extensions:
  sigv4auth:
    region: "<REGION>"

service:
  extensions: [sigv4auth]
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [resourcedetection, filter/keep_useful_metrics, batch]
      exporters: [prometheusremotewrite]
    traces:
      receivers: [otlp]
      processors: [resourcedetection, batch]
      exporters: [awsxray]
