This guide details how to send OpenTelemetry Logs to Honeycomb. Existing options include:
OpenTelemetry Logs are structured logs that wrap the bodies of existing logs and optionally correlate them with traces. For example, structured application logs from a logging framework in your application will be automatically correlated with any tracing you also add to that application. OpenTelemetry Logs also enable you to centrally process logs data along with traces and metrics within the OpenTelemetry collector.
You can send existing logs from a logging pipeline or other source – for example, Fluentbit, Splunk, or Kubernetes events – to Honeycomb with the OpenTelemetry Collector.
First, ensure that a receiver is available for your logs source. OpenTelemetry receivers enable other data sources, like different kinds of logs, to be transformed into the OpenTelemetry log format.
Next, configure the receiver for your logs source in your OpenTelemetry Collector configuration file. Each receiver has its own configuration options, so refer to the documentation for your receiver to learn how to best configure it.
Finally, configure an OTLP Logs exporter in your OpenTelemetry Collector configuration file to send to Honeycomb.
The following OpenTelemetry Collector configuration demonstrates how to send Kubernetes Events as OpenTelemetry logs to Honeycomb.
When applied as a ConfigMap to your Kubernetes cluster, this configuration will tell the OpenTelemetry Collector to receive Kubernetes events and then send them to Honeycomb as OpenTelemetry Logs.
To collect and send these Kubernetes Events, add the following to your OpenTelemetry Collector configuration file:
receivers:
k8s_events:
auth_type: serviceAccount
processors:
batch:
exporters:
otlp/k8sevents:
endpoint: api.honeycomb.io:443
headers:
"x-honeycomb-team": YOUR_API_KEY # Use your Honeycomb API Key here
"x-honeycomb-dataset": kubernetes-k8sevents # Use your preferred dataset name here
service:
pipelines:
logs:
receivers: [k8s_events]
processors: [batch]
exporters: [otlp/k8sevents]
Once you run your OpenTelemetry Collector with this configuration, it will collect Kubernetes events and send them to Honeycomb as OpenTelemetry Logs. In Honeycomb, find the logs within the dataset specified in your configuration.
You can also send your structured application logs via OpenTelemetry to an endpoint, such as Honeycomb’s endpoint or the OpenTelemetry Collector. This option is especially useful if structured logging exists in your application, since it allows for automatic correlation of structured logs with traces later.
When you use an OpenTelemetry SDK to create OpenTelemetry Logs, you send to Honeycomb directly or an OpenTelemetry Collector configured to export to Honeycomb.
This example configuration sends all logs created with an ILogger
to Honeycomb, and uses .NET.
First, install the OTLP Logs exporter in your application:
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs --prerelease
Then, create an ILogger
exporter during application startup:
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;
var appResourceBuilder = ResourceBuilder.CreateDefault()
.AddService("your-service-name", "your-service-version");
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.SetResourceBuilder(appResourceBuilder);
options.AddOtlpExporter(option =>
{
option.Endpoint = new Uri("https://api.honeycomb.io");
option.Headers = "x-honeycomb-team=YOUR_API_KEY";
});
});
});
var logger = loggerFactory.CreateLogger<Program>();
Then, run your application to create logs with ILogger
.
Logs will be sent to Honeycomb and located in the dataset that matches your configuration’s service name.
It is generally a best practice to have applications send data to an OpenTelemetry Collector rather than Honeycomb directly, unless those applications are relatively small. By doing so, you can control API keys, data export concerns, and preprocessing of data in one place.
This configuration sends logs to a OpenTelemetry Collector and then to Honeycomb. Your SDK pipelines focus on sending logs to the Collector endpoint and the Honeycomb API key can be centrally managed at the Open Telemetry Collector level.
First, install the OTLP Logs exporter in your application:
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs --prerelease
Then, create an ILogger
exporter during application startup:
using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;
var appResourceBuilder = ResourceBuilder.CreateDefault()
.AddService(serviceName: "your-service-name", serviceVersion: "0.1.0");
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.SetResourceBuilder(appResourceBuilder);
options.AddOtlpExporter(option =>
{
// Default value is localhost:4317
option.Endpoint = new Uri("YOUR_COLLECTOR_ENDPOINT");
});
});
});
var logger = loggerFactory.CreateLogger<Program>();
Then, configure your OpenTelemetry Collector to export to Honeycomb:
receivers:
otlp:
protocols:
grpc:
http:
processors:
batch:
exporters:
otlp/logs:
endpoint: api.honeycomb.io:443
headers:
"x-honeycomb-team": YOUR_API_KEY
service:
pipelines:
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp/logs]
Then, run your application and OpenTelemetry Collector. Logs will be sent to Honeycomb and located in the dataset that matches your configuration’s service name.