I am trying to setup the Serilog OpenTelemetry sink to send logs to my Otel Collector using the HttpProtobuf protocol.
My logs don't seem to be arriving, so I turned on Serilog self logging and see the following in the console:
Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Bad gRPC response. HTTP status code: 405") at Serilog.Core.Sinks.Batching.BatchingSink.LoopAsync()
This would seem to suggest the protocol is not being supported and the sink is still trying to send as Grpc.
My setup is as follows:
builder.Host.UseSerilog((ctx, serviceProvider, lc) =>
{
lc = lc.ReadFrom.Configuration(ctx.Configuration)
.WriteTo.Console();
var otlpEndpoint = builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"];
if (!string.IsNullOrWhiteSpace(otlpEndpoint))
{
lc.WriteTo.OpenTelemetry(cfg =>
{
cfg.Endpoint = $"{otlpEndpoint}/v1/logs";
cfg.Protocol = OtlpProtocol.HttpProtobuf;
});
}
});
I am trying to setup the Serilog OpenTelemetry sink to send logs to my Otel Collector using the HttpProtobuf protocol.
My logs don't seem to be arriving, so I turned on Serilog self logging and see the following in the console:
Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Bad gRPC response. HTTP status code: 405") at Serilog.Core.Sinks.Batching.BatchingSink.LoopAsync()
This would seem to suggest the protocol is not being supported and the sink is still trying to send as Grpc.
My setup is as follows:
builder.Host.UseSerilog((ctx, serviceProvider, lc) =>
{
lc = lc.ReadFrom.Configuration(ctx.Configuration)
.WriteTo.Console();
var otlpEndpoint = builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"];
if (!string.IsNullOrWhiteSpace(otlpEndpoint))
{
lc.WriteTo.OpenTelemetry(cfg =>
{
cfg.Endpoint = $"{otlpEndpoint}/v1/logs";
cfg.Protocol = OtlpProtocol.HttpProtobuf;
});
}
});
Share
Improve this question
asked 2 days ago
SteveSteve
9,58110 gold badges53 silver badges84 bronze badges
2
|
1 Answer
Reset to default 0Pass ignoreEnvironment: true
to WriteTo.OpenTelemetry()
to ignore any environment variable overrides set in your environment:
builder.Host.UseSerilog((ctx, serviceProvider, lc) =>
{
lc = lc.ReadFrom.Configuration(ctx.Configuration)
.WriteTo.Console();
var otlpEndpoint = builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"];
if (!string.IsNullOrWhiteSpace(otlpEndpoint))
{
lc.WriteTo.OpenTelemetry(cfg =>
{
cfg.Endpoint = $"{otlpEndpoint}/v1/logs";
cfg.Protocol = OtlpProtocol.HttpProtobuf;
// Add this arg:
}, ignoreEnvironment: true);
}
});
OTEL_EXPORTER_OTLP_PROTOCOL
is defined as an environment variable? This would override your configuration-in-code if so. – Nicholas Blumhardt Commented yesterday