|
| 1 | +--- |
| 2 | +title: Vector |
| 3 | +sidebar_order: 85 |
| 4 | +description: Learn how to set up Vector to forward logs to Sentry via OpenTelemetry. |
| 5 | +--- |
| 6 | + |
| 7 | +You can configure [Vector](https://vector.dev/) to forward logs to Sentry using its [OpenTelemetry sink](https://vector.dev/docs/reference/configuration/sinks/opentelemetry/). |
| 8 | + |
| 9 | +<Alert level="info"> |
| 10 | + |
| 11 | +This integration requires Vector version [0.51.0](https://vector.dev/releases/0.51.0/) or higher, which introduced the `otlp` codec for encoding events in OpenTelemetry format. |
| 12 | + |
| 13 | +</Alert> |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +Before you begin, ensure you have: |
| 18 | + |
| 19 | +- Vector installed and running |
| 20 | +- A Sentry project you want to send data to |
| 21 | + |
| 22 | +## Configuration |
| 23 | + |
| 24 | +To send logs to Sentry, configure Vector with an OpenTelemetry sink that points to your Sentry OTLP logs endpoint. You can find your endpoint and authentication details in your [Sentry Project Settings](https://sentry.io/settings/projects/) under **Client Keys (DSN)** > **OpenTelemetry (OTLP)**. |
| 25 | + |
| 26 | +Add the following sink configuration to your Vector configuration file: |
| 27 | + |
| 28 | +```yaml {filename:vector.yaml} |
| 29 | +sinks: |
| 30 | + sentry_logs: |
| 31 | + inputs: |
| 32 | + - your_source_id # Replace with your actual source ID |
| 33 | + type: opentelemetry |
| 34 | + protocol: |
| 35 | + type: http |
| 36 | + uri: ___OTLP_LOGS_URL___ |
| 37 | + headers: |
| 38 | + x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___" |
| 39 | + encoding: |
| 40 | + codec: otlp |
| 41 | +``` |
| 42 | +
|
| 43 | +```toml {filename:vector.toml} |
| 44 | +[sinks.sentry_logs] |
| 45 | +inputs = ["your_source_id"] # Replace with your actual source ID |
| 46 | +type = "opentelemetry" |
| 47 | + |
| 48 | +[sinks.sentry_logs.protocol] |
| 49 | +type = "http" |
| 50 | +uri = "___OTLP_LOGS_URL___" |
| 51 | + |
| 52 | +[sinks.sentry_logs.protocol.headers] |
| 53 | +x-sentry-auth = "sentry sentry_key=___PUBLIC_KEY___" |
| 54 | + |
| 55 | +[sinks.sentry_logs.encoding] |
| 56 | +codec = "otlp" |
| 57 | +``` |
| 58 | + |
| 59 | +### Configuration Options |
| 60 | + |
| 61 | +- **inputs**: The source or transform IDs that feed data into this sink |
| 62 | +- **type**: Must be `opentelemetry` to use the OTLP sink |
| 63 | +- **protocol.type**: Use `http` for HTTP transport |
| 64 | +- **protocol.uri**: Your Sentry OTLP logs endpoint |
| 65 | +- **protocol.headers**: Authentication headers including the `x-sentry-auth` header with your Sentry public key |
| 66 | +- **encoding.codec**: Must be `otlp` for OpenTelemetry protocol encoding |
| 67 | + |
| 68 | +## Example: Forwarding File Logs |
| 69 | + |
| 70 | +Here's a complete example that reads logs from a file and forwards them to Sentry: |
| 71 | + |
| 72 | +```yaml {filename:vector.yaml} |
| 73 | +sources: |
| 74 | + app_logs: |
| 75 | + type: file |
| 76 | + include: |
| 77 | + - /var/log/app/*.log |
| 78 | + |
| 79 | +sinks: |
| 80 | + sentry_logs: |
| 81 | + inputs: |
| 82 | + - app_logs |
| 83 | + type: opentelemetry |
| 84 | + protocol: |
| 85 | + type: http |
| 86 | + uri: ___OTLP_LOGS_URL___ |
| 87 | + headers: |
| 88 | + x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___" |
| 89 | + encoding: |
| 90 | + codec: otlp |
| 91 | +``` |
| 92 | +
|
| 93 | +For more information on Vector configuration options, see the [Vector documentation](https://vector.dev/docs/reference/configuration/). |
0 commit comments