| 1 |
# OTLP Receiver |
| 2 |
|
| 3 |
<!-- status autogenerated section --> |
| 4 |
| Status | | |
| 5 |
| ------------- |-----------| |
| 6 |
| Stability | [development]: profiles | |
| 7 |
| | [stable]: traces, metrics, logs | |
| 8 |
| Distributions | [core], [contrib], [k8s], [otlp] | |
| 9 |
| Issues | [](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fotlp) [](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fotlp) | |
| 10 |
|
| 11 |
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development |
| 12 |
[stable]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stable |
| 13 |
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol |
| 14 |
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib |
| 15 |
[k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s |
| 16 |
[otlp]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-otlp |
| 17 |
<!-- end autogenerated section --> |
| 18 |
|
| 19 |
Receives data via gRPC or HTTP using [OTLP]( |
| 20 |
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md) |
| 21 |
format. |
| 22 |
|
| 23 |
## Getting Started |
| 24 |
|
| 25 |
All that is required to enable the OTLP receiver is to include it in the |
| 26 |
receiver definitions. A protocol can be disabled by simply not specifying it in |
| 27 |
the list of protocols. |
| 28 |
|
| 29 |
```yaml |
| 30 |
receivers: |
| 31 |
otlp: |
| 32 |
protocols: |
| 33 |
grpc: |
| 34 |
http: |
| 35 |
``` |
| 36 |
|
| 37 |
The following settings are configurable: |
| 38 |
|
| 39 |
- `endpoint` (default = localhost:4317 for grpc protocol, localhost:4318 http protocol): |
| 40 |
host:port to which the receiver is going to receive data. The valid syntax is |
| 41 |
described at https://github.com/grpc/grpc/blob/master/doc/naming.md. See our |
| 42 |
[security best practices doc](https://opentelemetry.io/docs/security/config-best-practices/#protect-against-denial-of-service-attacks) |
| 43 |
to understand how to set the endpoint in different environments. |
| 44 |
|
| 45 |
## Advanced Configuration |
| 46 |
|
| 47 |
Several helper files are leveraged to provide additional capabilities automatically: |
| 48 |
|
| 49 |
- [gRPC settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configgrpc/README.md) including CORS |
| 50 |
- [HTTP settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/confighttp/README.md) |
| 51 |
- [TLS and mTLS settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md) |
| 52 |
- [Auth settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configauth/README.md) |
| 53 |
|
| 54 |
## Writing with HTTP/JSON |
| 55 |
|
| 56 |
The OTLP receiver can receive trace export calls via HTTP/JSON in addition to |
| 57 |
gRPC. The HTTP/JSON address is the same as gRPC as the protocol is recognized |
| 58 |
and processed accordingly. Note the serialization format needs to be [OTLP JSON](https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding). |
| 59 |
|
| 60 |
The HTTP/JSON configuration also provides `traces_url_path`, |
| 61 |
`metrics_url_path`, `logs_url_path`, and `profiles_url_path` configurations to |
| 62 |
allow the URL paths that signal data needs to be sent to be modified per signal |
| 63 |
type. These default to `/v1/traces`, `/v1/metrics`, `/v1/logs`, and |
| 64 |
`/v1/profiles` respectively. |
| 65 |
|
| 66 |
To write traces with HTTP/JSON, `POST` to `[address]/[traces_url_path]` for |
| 67 |
traces, to `[address]/[metrics_url_path]` for metrics, to |
| 68 |
`[address]/[logs_url_path]` for logs, and to `[address]/[profiles_url_path]` for |
| 69 |
profiles. |
| 70 |
The default port is `4318`. When using the `otlphttpexporter` peer to |
| 71 |
communicate with this component, use the `traces_endpoint`, |
| 72 |
`metrics_endpoint`, `logs_endpoint`, and `profiles_endpoint` settings in the |
| 73 |
`otlphttpexporter` to set the proper URL to match the address and URL signal |
| 74 |
path on the `otlpreceiver`. |
| 75 |
|
| 76 |
### CORS (Cross-origin resource sharing) |
| 77 |
|
| 78 |
The HTTP/JSON endpoint can also optionally configure [CORS][cors] under `cors:`. |
| 79 |
Specify what origins (or wildcard patterns) to allow requests from as |
| 80 |
`allowed_origins`. To allow additional request headers outside of the [default |
| 81 |
safelist][cors-headers], set `allowed_headers`. Browsers can be instructed to |
| 82 |
[cache][cors-max-age] responses to preflight requests by setting `max_age`. |
| 83 |
|
| 84 |
[cors]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS |
| 85 |
[cors-headers]: https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header |
| 86 |
[cors-max-age]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age |
| 87 |
|
| 88 |
```yaml |
| 89 |
receivers: |
| 90 |
otlp: |
| 91 |
protocols: |
| 92 |
http: |
| 93 |
endpoint: "localhost:4318" |
| 94 |
cors: |
| 95 |
allowed_origins: |
| 96 |
- http://test.com |
| 97 |
# Origins can have wildcards with *, use * by itself to match any origin. |
| 98 |
- https://*.example.com |
| 99 |
allowed_headers: |
| 100 |
- Example-Header |
| 101 |
max_age: 7200 |
| 102 |
``` |
| 103 |
|
| 104 |
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib |
| 105 |
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol |