open-telemetry / community

OpenTelemetry community content
https://opentelemetry.io
Apache License 2.0
758 stars 230 forks source link

Contributing- Unable to log to file using Otel Collector exporter #2054

Closed SantoshAvaji closed 5 months ago

SantoshAvaji commented 5 months ago

I have created new file and provided all permission then given that path in yml config (It's in Ubuntu machine) exporters: file: path: ./filename.json

But facing an issue permission denied Unable to write file, please help me to resolve this issue asap

JaredTan95 commented 5 months ago

This problem is more appropriate in the otel col contrib repo, However, I think you should read the fileexporter's readme.md carefully first: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/fileexporter

The official opentelemetry-collector-contrib container does not have a writable filesystem by default since it's built on the scratch layer. As such, you will need to create a writable directory for the path, potentially by mounting writable volumes or creating a custom image.

svrnm commented 5 months ago

as @JaredTan95 said, this is a good question for the collector community, #otel-collector channel on CNCF Slack might be a good place to ask this. If there is any docs related issue please update accordingly

SantoshAvaji commented 5 months ago

myconfig.yaml receivers:

otlp:

protocols:

grpc:

  endpoint: [0.0.0.0:4317](http://0.0.0.0:4317/)

http:

  endpoint: [0.0.0.0:4318](http://0.0.0.0:4318/)

processors:

batch: exporters:

file:

path: ./logs/test.txt extensions:

health_check:

pprof:

zpages:

service:

extensions: [health_check, pprof, zpages]

pipelines:

traces:

    receivers: [otlp]

    processors: [batch]

    exporters: [file]

metrics:

    receivers: [otlp]

    processors: [batch]

    exporters: [file]

                        logs:

  receivers: [otlp]

  processors: [batch]

  exporters: [file]

Command Executed :sudo docker run -v ./myconfig.yaml:/etc/otelcol-contrib/config.yaml -v ./te./logs:/logs otel/opentelemetry-collector-contrib:0.97.0 Error: cannot start pipelines: open ./logs/test.txt: permission denied

2024/04/15 17:23:54 collector server run finished with error: cannot start pipelines: open ./logs/test.txt: permission denied