Better Stack OpenTelemetry Logging
Start logging in 6 minutes
Collect logs and metrics from your application using OpenTelemetry.
1. Install OpenTelemetry collector
Install and set up OpenTelemetry collector.
2. Add required modules
Add the following components to your collector distribution:
- Exporters: OTLP and Prometheus Remote Write
- Processors: Attributes
To add them, you will need to add the modules to your YAML manifest file (replace
0.81.0 by your used version):
dist: # your distribution metadata... exporters: # your currently used exporters... - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.81.0 - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.81.0 processors: # your currently used processors... - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.81.0
After changing the configuration, rebuild your collector distribution.
3. Set up sending logs and metrics
Set up new logs and metrics pipeline to send the data to Better Stack. Use your collector YAML configuration file:
exporters: otlp/betterstack: endpoint: "https://in-otel.logs.betterstack.com:443" prometheusremotewrite/betterstack: endpoint: "https://in-otel.logs.betterstack.com/metrics" processors: attributes/betterstack: actions: - key: better_stack_source_token value: $SOURCE_TOKEN action: insert service: pipelines: metrics/betterstack: receivers: [otlp, spanmetrics] # your current metrics receivers processors: [filter, batch, attributes/betterstack] # your current metrics processors + attributes/betterstack exporters: [prometheusremotewrite/betterstack] logs/betterstack: receivers: [otlp] # your current logs receivers processors: [batch, attributes/betterstack] # your current logs processors + attributes/betterstack exporters: [otlp/betterstack]
4. Restart OpenTelemetry collector
Restart your OTel collector for the new configuration to take effect.
You should see your logs in Better Stack -> Live tail.
Please let us know at firstname.lastname@example.org.
We're happy to help! 🙏
You could add the
attributes/betterstack processor and
prometheusremotewrite/betterstack exporters to your pipelines instead of defining new ones. However, this would expose your Better Stack source token to other logs or metrics tools.