C
C#7mo ago
Denis

✅ Setting up WPF logging to OTLP collector

My docker compose:
version: '3'

services:
loki:
container_name: "loki"
image: grafana/loki:latest
ports:
- "3100:3100"
networks:
- telemetry

grafana:
container_name: "grafana"
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
networks:
- telemetry
depends_on:
- loki

collector:
container_name: "collector"
hostname: "collector"
image: otel/opentelemetry-collector:latest
command: '--config=/etc/otelcol/otel-collector-config.yml'
volumes:
- ./configs:/etc/otelcol
ports:
- "8888:8888"
- "8889:8889"
- "4317:4317"
- "4318:4318"
networks:
- telemetry

networks:
telemetry:
driver: bridge
external: true
version: '3'

services:
loki:
container_name: "loki"
image: grafana/loki:latest
ports:
- "3100:3100"
networks:
- telemetry

grafana:
container_name: "grafana"
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
networks:
- telemetry
depends_on:
- loki

collector:
container_name: "collector"
hostname: "collector"
image: otel/opentelemetry-collector:latest
command: '--config=/etc/otelcol/otel-collector-config.yml'
volumes:
- ./configs:/etc/otelcol
ports:
- "8888:8888"
- "8889:8889"
- "4317:4317"
- "4318:4318"
networks:
- telemetry

networks:
telemetry:
driver: bridge
external: true
My otel config:
receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318
processors:
batch:
send_batch_size: 4
timeout: 10s
exporters:
otlphttp:
endpoint: "http://loki:3100/otlp/v1/logs"
service:
pipelines:
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317
http:
endpoint: localhost:4318
processors:
batch:
send_batch_size: 4
timeout: 10s
exporters:
otlphttp:
endpoint: "http://loki:3100/otlp/v1/logs"
service:
pipelines:
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp]
My WPF app config
services.AddLogging(builder =>
builder.AddOpenTelemetry(options =>
options.SetResourceBuilder(
ResourceBuilder
.CreateDefault()
.AddService(APP_NAME))
.AddConsoleExporter()
.AddOtlpExporter(o =>
{
o.Endpoint = new Uri("http://localhost:4318/v1/logs");
o.Protocol = OtlpExportProtocol.HttpProtobuf;
})));
services.AddLogging(builder =>
builder.AddOpenTelemetry(options =>
options.SetResourceBuilder(
ResourceBuilder
.CreateDefault()
.AddService(APP_NAME))
.AddConsoleExporter()
.AddOtlpExporter(o =>
{
o.Endpoint = new Uri("http://localhost:4318/v1/logs");
o.Protocol = OtlpExportProtocol.HttpProtobuf;
})));
But... no logs are received by the collector. Why and how do I fix it? Or at least the running collector instance isn't logging anything when my app is producing logs.
7 Replies
Pobiega
Pobiega7mo ago
if you start them via docker compose, they need to refer to eachother by the service name
Denis
DenisOP7mo ago
The wpf app is local, outside of docker
Pobiega
Pobiega7mo ago
ah okay can you verify that the collector is up and running and can be connected to? monitor its log traffic while starting the wpf app or something
Denis
DenisOP7mo ago
The collector logs its startup sequence, so I see no issue there. I'm not sure how I can send a test log outside of my WPF app, by directly accessing the exposed endpoint. Or even how to check whether the collector is accessible outside of docker Grafana and loki are accessible via the respective localhost addresses
Pobiega
Pobiega7mo ago
hm, no obvious ideas from me then
Denis
DenisOP7mo ago
No description
Denis
DenisOP7mo ago
Here§s what the collector logs It appears that my custom otel config is causing the issues. If I remove it, everything works. Maybe I need to add more things to the config to display debug tracing and health checks? Progress: exporterhelper/queue_sender.go:101 Exporting failed. Dropping data. {"kind": "exporter", "data_type": "logs", "name": "otlphttp", "error": "not retryable error: Permanent error: rpc error: code = Unimplemented desc = error exporting items, request to http://loki:3100/otlp/v1/logs responded with HTTP Status Code 404", "dropped_items": 3} with the following config for OTLP:
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679

receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

opencensus:
endpoint: 0.0.0.0:55678

# Collect own metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: ['0.0.0.0:8888']

jaeger:
protocols:
grpc:
endpoint: 0.0.0.0:14250
thrift_binary:
endpoint: 0.0.0.0:6832
thrift_compact:
endpoint: 0.0.0.0:6831
thrift_http:
endpoint: 0.0.0.0:14268

zipkin:
endpoint: 0.0.0.0:9411

processors:
batch:

exporters:
debug:
verbosity: detailed
otlphttp:
endpoint: "http://loki:3100/otlp/"

service:
pipelines:
traces:
receivers: [otlp, opencensus, jaeger, zipkin]
processors: [batch]
exporters: [debug]

metrics:
receivers: [otlp, opencensus, prometheus]
processors: [batch]
exporters: [debug]

logs:
receivers: [otlp]
processors: [batch]
exporters: [debug,otlphttp]

extensions: [health_check, pprof, zpages]
extensions:
health_check:
pprof:
endpoint: 0.0.0.0:1777
zpages:
endpoint: 0.0.0.0:55679

receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

opencensus:
endpoint: 0.0.0.0:55678

# Collect own metrics
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: ['0.0.0.0:8888']

jaeger:
protocols:
grpc:
endpoint: 0.0.0.0:14250
thrift_binary:
endpoint: 0.0.0.0:6832
thrift_compact:
endpoint: 0.0.0.0:6831
thrift_http:
endpoint: 0.0.0.0:14268

zipkin:
endpoint: 0.0.0.0:9411

processors:
batch:

exporters:
debug:
verbosity: detailed
otlphttp:
endpoint: "http://loki:3100/otlp/"

service:
pipelines:
traces:
receivers: [otlp, opencensus, jaeger, zipkin]
processors: [batch]
exporters: [debug]

metrics:
receivers: [otlp, opencensus, prometheus]
processors: [batch]
exporters: [debug]

logs:
receivers: [otlp]
processors: [batch]
exporters: [debug,otlphttp]

extensions: [health_check, pprof, zpages]
I had to change the image to the contrib, and use the loki receiver
Want results from more Discord servers?
Add your server