Skip to content

OpenTelemetry Collector: Write log data with OTLP API

Last updated on

STACKIT Logs also support ingesting OpenTelemetry logs over HTTP. You can configure the OpenTelemetry HTTP exporter for sending log data to STACKIT Logs instance. Additionally, you will need the bearertokenauth extension to enable the STACKIT Logs access token authentication. Make sure these features come bundled in the OTel Collector you are using, for example OpenTelemetry Collector.

OpenTelemetry Collector’s otlphttp exporter for Logs can be configured with the next steps. The configuration file output of steps is shown first, you can extend it according to your requirements.

/etc/otelcol/configs.yaml
# 1. Define extension
extensions:
bearertokenauth/stackit_logs_access_token:
scheme: "Bearer"
# either put token directly here or put the token value in a file and reference the file in `filename`
token: "<Token value from Logs instance Access Token>"
filename: "file-containing-logs-instance-access.token"
# 2. Define otlphttp exporter
exporters:
otlphttp:
# NOTE: The client will internally append `/v1/logs` to this url
endpoint: <data-source-url-of-logs-instance>/otlp
auth:
authenticator: bearertokenauth/stackit_logs_access_token
# 3. Definition of the collector pipeline for logs
service:
extensions:
- bearertokenauth/stackit_logs_access_token # reference the extension to put STACKIT Logs access token
pipelines:
logs:
exporters:
- otlphttp # reference the STACKIT Logs exporter
receivers: [...] # Set the receivers according to your use case
processors: [...] # Set the processors according to your use case
  1. Create or edit the otel-collector config file usually named config.yaml
  2. Configure extension of type bearertokenauth, with scheme: Bearer either set the STACKIT Logs access token in token field or in a file and reference that with filename field.
  3. Configure exporter of type oltphttp to set endpoint and authentication.
  4. For otlphttp endpoint key, set the value of STACKIT Logs instance’s data source URL appended by /otlp.
  5. For otlphttp auth.authenticator key, set the value as the name of bearertokenauth extension configured above.
  6. Configure the service section to setup extensions and pipeline for logs.
  7. Under service.extensions array, add the name of bearertokenauth extension configured above.
  8. Under service.pipelines.logs.exporters array, add the name of the otlphttp exporter name configured above.
  9. You can now further configure the otlphttp exporter according to your needs. See the configuration of the exporter for more details.