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.
Prerequisites
Section titled “Prerequisites”- You have a STACKIT Logs Instance: Create your first STACKIT Logs instance
- You have credentials with write permission for the STACKIT Logs Instance: Retrieve credentials for STACKIT Logs instance
- Data source URL of the STACKI Logs Instance: Retrieve API URL STACKIT Logs instance
Client Configuration
Section titled “Client Configuration”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.
# 1. Define extensionextensions: 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 exporterexporters: 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 logsservice: 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- Create or edit the otel-collector config file usually named
config.yaml - Configure extension of type
bearertokenauth, withscheme: Bearereither set the STACKIT Logs access token intokenfield or in a file and reference that withfilenamefield. - Configure exporter of type
oltphttpto set endpoint and authentication. - For otlphttp
endpointkey, set the value of STACKIT Logs instance’s data source URL appended by/otlp. - For otlphttp
auth.authenticatorkey, set the value as the name of bearertokenauth extension configured above. - Configure the
servicesection to setup extensions and pipeline for logs. - Under
service.extensionsarray, add the name of bearertokenauth extension configured above. - Under
service.pipelines.logs.exportersarray, add the name of the otlphttp exporter name configured above. - You can now further configure the otlphttp exporter according to your needs. See the configuration of the exporter for more details.