|
| 1 | +--- |
| 2 | +title: Configuring Telemetry Ingestion |
| 3 | +description: Set up the OpenTelemetry Collector and Data Prepper to ingest traces, logs, and metrics for APM |
| 4 | +sidebar: |
| 5 | + label: Telemetry Ingestion |
| 6 | + order: 10 |
| 7 | +--- |
| 8 | + |
| 9 | +To use APM, you need to ingest application traces and logs into OpenSearch using the OpenTelemetry Collector and Data Prepper pipeline. For an overview of the complete APM architecture, see the [APM overview](/docs/apm/). |
| 10 | + |
| 11 | +This page covers configuring the OpenTelemetry Collector and Data Prepper to process and route telemetry data to OpenSearch and Prometheus. |
| 12 | + |
| 13 | +## Configuring the OpenTelemetry Collector |
| 14 | + |
| 15 | +The [OpenTelemetry (OTel) Collector](https://opentelemetry.io/docs/collector/) acts as the entry point for all application telemetry. It receives data through the OpenTelemetry Protocol (OTLP) and routes traces and logs to Data Prepper while sending metrics to Prometheus. |
| 16 | + |
| 17 | +The following example shows the key exporter and pipeline configuration for routing telemetry to Data Prepper and Prometheus: |
| 18 | + |
| 19 | +```yaml |
| 20 | +exporters: |
| 21 | + otlp/opensearch: |
| 22 | + endpoint: "data-prepper:21890" |
| 23 | + tls: |
| 24 | + insecure: true |
| 25 | + |
| 26 | + otlphttp/prometheus: |
| 27 | + endpoint: "http://prometheus:9090/api/v1/otlp" |
| 28 | + tls: |
| 29 | + insecure: true |
| 30 | + |
| 31 | +service: |
| 32 | + pipelines: |
| 33 | + traces: |
| 34 | + receivers: [otlp] |
| 35 | + processors: [resourcedetection, memory_limiter, transform, batch] |
| 36 | + exporters: [otlp/opensearch] |
| 37 | + |
| 38 | + metrics: |
| 39 | + receivers: [otlp] |
| 40 | + processors: [resourcedetection, memory_limiter, batch] |
| 41 | + exporters: [otlphttp/prometheus] |
| 42 | + |
| 43 | + logs: |
| 44 | + receivers: [otlp] |
| 45 | + processors: [resourcedetection, memory_limiter, transform, batch] |
| 46 | + exporters: [otlp/opensearch] |
| 47 | +``` |
| 48 | +
|
| 49 | +The `otlp/opensearch` exporter sends traces and logs to Data Prepper. The `otlphttp/prometheus` exporter sends metrics directly to Prometheus. For a complete OTel Collector configuration example including receivers, processors, and telemetry settings, see the [observability-stack OTel Collector config](https://github.com/opensearch-project/observability-stack/blob/main/docker-compose/otel-collector/config.yaml). |
| 50 | + |
| 51 | +## Configuring Data Prepper pipelines |
| 52 | + |
| 53 | +Data Prepper receives telemetry data from the OTel Collector and processes it into the formats required for APM. The pipeline architecture routes data through specialized subpipelines for log processing, trace storage, and service map generation. |
| 54 | + |
| 55 | +The following example shows a complete Data Prepper pipeline configuration: |
| 56 | + |
| 57 | +```yaml |
| 58 | +# Main OTLP pipeline - receives all telemetry and routes by type |
| 59 | +otlp-pipeline: |
| 60 | + source: |
| 61 | + otlp: |
| 62 | + ssl: false |
| 63 | + route: |
| 64 | + - logs: "getEventType() == \"LOG\"" |
| 65 | + - traces: "getEventType() == \"TRACE\"" |
| 66 | + sink: |
| 67 | + - pipeline: |
| 68 | + name: "otel-logs-pipeline" |
| 69 | + routes: |
| 70 | + - "logs" |
| 71 | + - pipeline: |
| 72 | + name: "otel-traces-pipeline" |
| 73 | + routes: |
| 74 | + - "traces" |
| 75 | +
|
| 76 | +# Log processing pipeline |
| 77 | +otel-logs-pipeline: |
| 78 | + workers: 5 |
| 79 | + delay: 10 |
| 80 | + source: |
| 81 | + pipeline: |
| 82 | + name: "otlp-pipeline" |
| 83 | + buffer: |
| 84 | + bounded_blocking: |
| 85 | + sink: |
| 86 | + - opensearch: |
| 87 | + hosts: ["https://<opensearch-host>:9200"] |
| 88 | + username: <username> |
| 89 | + password: <password> |
| 90 | + insecure: true |
| 91 | + index_type: log-analytics-plain |
| 92 | +
|
| 93 | +# Trace processing pipeline |
| 94 | +otel-traces-pipeline: |
| 95 | + source: |
| 96 | + pipeline: |
| 97 | + name: "otlp-pipeline" |
| 98 | + sink: |
| 99 | + - pipeline: |
| 100 | + name: "traces-raw-pipeline" |
| 101 | + - pipeline: |
| 102 | + name: "service-map-pipeline" |
| 103 | +
|
| 104 | +# Raw trace storage pipeline |
| 105 | +traces-raw-pipeline: |
| 106 | + source: |
| 107 | + pipeline: |
| 108 | + name: "otel-traces-pipeline" |
| 109 | + processor: |
| 110 | + - otel_traces: |
| 111 | + sink: |
| 112 | + - opensearch: |
| 113 | + hosts: ["https://<opensearch-host>:9200"] |
| 114 | + username: <username> |
| 115 | + password: <password> |
| 116 | + insecure: true |
| 117 | + index_type: trace-analytics-plain-raw |
| 118 | +
|
| 119 | +# Service map and APM metrics pipeline |
| 120 | +service-map-pipeline: |
| 121 | + source: |
| 122 | + pipeline: |
| 123 | + name: "otel-traces-pipeline" |
| 124 | + processor: |
| 125 | + - otel_apm_service_map: |
| 126 | + group_by_attributes: [telemetry.sdk.language] # Add any resource attribute to group by |
| 127 | + route: |
| 128 | + - otel_apm_service_map_route: 'getEventType() == "SERVICE_MAP"' |
| 129 | + - service_processed_metrics: 'getEventType() == "METRIC"' |
| 130 | + sink: |
| 131 | + - opensearch: |
| 132 | + hosts: ["https://<opensearch-host>:9200"] |
| 133 | + username: <username> |
| 134 | + password: <password> |
| 135 | + index_type: otel-v2-apm-service-map |
| 136 | + routes: [otel_apm_service_map_route] |
| 137 | + insecure: true |
| 138 | + - prometheus: |
| 139 | + url: "http://prometheus:9090/api/v1/write" |
| 140 | + routes: [service_processed_metrics] |
| 141 | +``` |
| 142 | + |
| 143 | +### Pipeline architecture |
| 144 | + |
| 145 | +The Data Prepper pipeline processes telemetry data using the following steps: |
| 146 | + |
| 147 | +1. The entry pipeline (`otlp-pipeline`) receives all telemetry and routes logs and traces to their respective subpipelines. |
| 148 | +2. The log pipeline (`otel-logs-pipeline`) writes logs to OpenSearch using the `log-analytics-plain` index type. |
| 149 | +3. The trace pipeline (`otel-traces-pipeline`) distributes traces to both the raw storage pipeline and the service map pipeline. |
| 150 | +4. The raw trace pipeline (`traces-raw-pipeline`) processes individual trace spans using the `otel_traces` processor and stores them in OpenSearch using the `trace-analytics-plain-raw` index type. |
| 151 | +5. The service map pipeline (`service-map-pipeline`) uses the `otel_apm_service_map` processor to generate service dependency maps and RED metrics. Service map topology data is written to OpenSearch, and RED metrics are exported to Prometheus through remote write. |
| 152 | + |
| 153 | +Two key configuration options for the `otel_apm_service_map` processor are `group_by_attributes` (which determines how services can be grouped in the application map) and `window_duration` (which sets the time window for aggregating trace data). |
| 154 | + |
| 155 | +## Verifying ingestion |
| 156 | + |
| 157 | +After configuring the OTel Collector and Data Prepper, verify that data is flowing correctly: |
| 158 | + |
| 159 | +1. **Verify OpenSearch indexes** - confirm the following indexes are created in your OpenSearch cluster: |
| 160 | + - `otel-v1-apm-span-*` - raw trace spans |
| 161 | + - `otel-v2-apm-service-map` - service topology data |
| 162 | + - `logs-otel-v1-*` - application logs |
| 163 | + |
| 164 | + You can check indexes using: |
| 165 | + ```bash |
| 166 | + curl -k -u admin:My_password_123!@# https://localhost:9200/_cat/indices?v |
| 167 | + ``` |
| 168 | + |
| 169 | +2. **Verify Prometheus** - confirm the Data Prepper remote write target is active in your Prometheus instance by checking the Prometheus targets page at `http://localhost:9090/targets`. |
| 170 | + |
| 171 | +3. **Verify in OpenSearch Dashboards** - navigate to **Observability** > **APM** to confirm that your services appear in the [Services](/docs/apm/services/) catalog and the [Application Map](/docs/apm/service-map/). |
| 172 | + |
| 173 | +> **Warning:** Ensure that all port mappings are correct between the OTel Collector, Data Prepper, OpenSearch, and Prometheus. Mismatched ports are a common cause of ingestion failures. |
| 174 | + |
| 175 | +## Next steps |
| 176 | + |
| 177 | +- [Configuring APM in OpenSearch Dashboards](/docs/apm/configuring-apm/): Create datasets, index patterns, and configure APM settings to start using APM features. |
0 commit comments