

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 애플리케이션 원격 측정 수집
<a name="observability-ingestion"></a>

Amazon OpenSearch Service에서 관찰성 기능을 사용하려면 애플리케이션 트레이스, 로그 및 지표를 수집해야 합니다. 이 페이지에서는 원격 측정 데이터를 처리하고 OpenSearch 및 Amazon Managed Service for Prometheus로 라우팅하도록 OpenTelemetry Collector 및 OpenSearch Ingestion 파이프라인을 구성하는 방법을 다룹니다. OpenSearch 

## OpenTelemetry Collector 구성
<a name="observability-ingestion-otel"></a>

OpenTelemetry(OTel) Collector는 모든 애플리케이션 원격 측정의 진입점입니다. OTLP를 통해 데이터를 수신하고 Prometheus로 지표를 전송하는 동안 추적 및 로그를 OpenSearch Ingestion으로 라우팅합니다.

다음 방법 중 하나를 사용하여 OTel Collector를 구성할 수 있습니다.

OTel Collector는 SigV4 인증을 사용하여 추적 및 로그를 OpenSearch Ingestion 엔드포인트로 내보내고 Prometheus 원격 쓰기 내보내기를 사용하여 지표를 Amazon Managed Service for Prometheus로 내보냅니다. OpenSearch Ingestion은 OpenSearch로의 처리, 보강 및 라우팅을 처리합니다.

### OpenSearch Ingestion을 사용한 OTel Collector 구성
<a name="observability-ingestion-otel-osis"></a>

다음 예제 구성은 SigV4 인증을 사용하여 추적 및 로그를 OpenSearch Ingestion 엔드포인트로 내보내고 지표를 Prometheus로 내보냅니다.

```
extensions:
  sigv4auth:
    region: us-west-2
    service: osis

exporters:
  otlphttp/osis-traces:
    traces_endpoint: ${OSIS_ENDPOINT}/v1/traces
    auth: { authenticator: sigv4auth }
    compression: none
  otlphttp/osis-logs:
    logs_endpoint: ${OSIS_ENDPOINT}/v1/logs
    auth: { authenticator: sigv4auth }
    compression: none
  # Amazon Managed Service for Prometheus via Prometheus Remote Write with SigV4 auth
  prometheusremotewrite/amp:
    endpoint: "https://aps-workspaces.region.amazonaws.com/workspaces/workspace-id/api/v1/remote_write"
    auth:
      authenticator: sigv4auth

service:
  extensions: [sigv4auth]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlphttp/osis-traces]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlphttp/osis-logs]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [prometheusremotewrite/amp]
```

**참고**  
데이터를 전송하는 IAM 보안 주체는 파이프라인 ARN에 대한 `osis:Ingest` 및 `aps:RemoteWrite` 권한이 필요합니다.

## OpenSearch Ingestion 파이프라인 구성
<a name="observability-ingestion-pipelines"></a>

OpenSearch Ingestion(또는 자체 관리형 Data Prepper)은 OTel Collector에서 원격 측정을 수신하여 애플리케이션 성능 모니터링(APM)을 위해 처리합니다.

### 파이프라인 아키텍처
<a name="observability-ingestion-pipeline-arch"></a>

파이프라인은 다음 단계에서 원격 측정 데이터를 처리합니다.

1. 진입 파이프라인은 모든 원격 측정을 수신하고 로그와 추적을 별도의 하위 파이프라인으로 라우팅합니다.

1. 로그 파이프라인은 `log-analytics-plain` 인덱스 유형을 사용하여 OpenSearch에 로그 데이터를 씁니다.

1. 트레이스 파이프라인은 스팬을 원시 스토리지 파이프라인과 서비스 맵 파이프라인에 분산합니다.

1. 원시 추적 파이프라인 프로세스는 `otel_traces` 프로세서에 걸쳐 있으며 `trace-analytics-plain-raw` 인덱스 유형에 저장됩니다.

1. 서비스 맵 파이프라인은 `otel_apm_service_map` 프로세서를 사용하여 토폴로지 및 RED(Rate, Errors, Duration) 지표를 생성합니다. 원격 쓰기를 통해 OpenSearch 및 Prometheus에 씁니다.

### 파이프라인 구성
<a name="observability-ingestion-pipeline-config"></a>

다음 예제에서는 로그, 추적 및 지표와 같은 모든 관찰성 신호 유형을 포함하는 OpenSearch Ingestion의 전체 파이프라인 구성을 보여줍니다. 모든 파이프라인 또는 사용 사례와 관련된 파이프라인만 포함할 수 있습니다. *자리 표시자*를 자신의 정보로 바꿉니다.

```
version: '2'

# Main OTLP pipeline - receives all telemetry and routes by signal type
otlp-pipeline:
  source:
    otlp:
      logs_path: '/pipeline-name/v1/logs'
      traces_path: '/pipeline-name/v1/traces'
      metrics_path: '/pipeline-name/v1/metrics'
  route:
    - logs: 'getEventType() == "LOG"'
    - traces: 'getEventType() == "TRACE"'
    - metrics: 'getEventType() == "METRIC"'
  processor: []
  sink:
    - pipeline:
        name: otel-logs-pipeline
        routes:
          - logs
    - pipeline:
        name: otel-traces-pipeline
        routes:
          - traces
    - pipeline:
        name: otel-metrics-pipeline
        routes:
          - metrics

# Log processing pipeline
otel-logs-pipeline:
  source:
    pipeline:
      name: otlp-pipeline
  processor:
    - copy_values:
        entries:
          - from_key: "time"
            to_key: "@timestamp"
  sink:
    - opensearch:
        hosts:
          - 'https://opensearch-endpoint'
        index_type: log-analytics-plain
        aws:
          serverless: false
          region: 'region'
          sts_role_arn: "arn:aws:iam::account-id:role/pipeline-role"

# Trace fan-out pipeline
otel-traces-pipeline:
  source:
    pipeline:
      name: otlp-pipeline
  processor: []
  sink:
    - pipeline:
        name: traces-raw-pipeline
        routes: []
    - pipeline:
        name: service-map-pipeline
        routes: []

# Raw trace storage pipeline
traces-raw-pipeline:
  source:
    pipeline:
      name: otel-traces-pipeline
  processor:
    - otel_traces:
  sink:
    - opensearch:
        hosts:
          - 'https://opensearch-endpoint'
        index_type: trace-analytics-plain-raw
        aws:
          serverless: false
          region: 'region'
          sts_role_arn: "arn:aws:iam::account-id:role/pipeline-role"

# Service map generation pipeline (APM)
service-map-pipeline:
  source:
    pipeline:
      name: otel-traces-pipeline
  processor:
    - otel_apm_service_map:
        group_by_attributes:
          - telemetry.sdk.language # Add any resource attribute to group by
        window_duration: 30s
  route:
    - otel_apm_service_map_route: 'getEventType() == "SERVICE_MAP"'
    - service_processed_metrics: 'getEventType() == "METRIC"'
  sink:
    - opensearch:
        hosts:
          - 'https://opensearch-endpoint'
        aws:
          serverless: false
          region: 'region'
          sts_role_arn: "arn:aws:iam::account-id:role/pipeline-role"
        routes:
          - otel_apm_service_map_route
        index_type: otel-v2-apm-service-map
    - prometheus:
        url: 'https://aps-workspaces.region.amazonaws.com/workspaces/workspace-id/api/v1/remote_write'
        aws:
          region: 'region'
        routes:
          - service_processed_metrics

# Metrics processing pipeline
otel-metrics-pipeline:
  source:
    pipeline:
      name: otlp-pipeline
  processor:
    - otel_metrics:
  sink:
    - prometheus:
        url: 'https://aps-workspaces.region.amazonaws.com/workspaces/workspace-id/api/v1/remote_write'
        aws:
          region: 'region'
```

## 수집 확인
<a name="observability-ingestion-verify"></a>

OTel Collector 및 파이프라인을 구성한 후 원격 측정 데이터가 올바르게 흐르고 있는지 확인합니다.
+ **OpenSearch 인덱스 확인** - 도메인에 `otel-v1-apm-span-*`, `otel-v2-apm-service-map`및 인덱스가 있는지 확인합니다`logs-otel-v1-*`.
+ **Prometheus 대상 확인** - Prometheus 원격 쓰기 대상이 서비스 맵 파이프라인에서 지표를 수신하고 있는지 확인합니다.
+ **OpenSearch UI에서 확인** - **관찰성**으로 이동한 다음 **애플리케이션 모니터링**으로 이동하여 서비스가 나타나는지 확인합니다.

## 다음 단계
<a name="observability-ingestion-next"></a>

원격 측정 데이터가 수집되었는지 확인한 후 다음 주제를 살펴봅니다.
+ [애플리케이션 모니터링](observability-app-monitoring.md) - 서비스 맵 및 RED 지표를 사용하여 애플리케이션 상태를 모니터링합니다.
+ [트레이스 검색](observability-analyze-traces.md) - 분산 트레이스를 검색하고 분석합니다.
+ [로그 검색](observability-analyze-logs.md) - 애플리케이션 로그를 검색하고 쿼리합니다.
+ [지표 검색](observability-metrics.md) - PromQL 지표를 검색하고 쿼리합니다.