Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opentelemetry-collector-contrib vs opentelemetry-collector http receiver doesn't work for /v1/logs returns 404 in contrib #29447

Closed
truestep opened this issue Nov 22, 2023 · 1 comment
Labels
question Further information is requested

Comments

@truestep
Copy link

truestep commented Nov 22, 2023

Component(s)

No response

What happened?

the logs endpoint doesn't work for contrib, but works for original openetelemetry-collector

Description

Steps to Reproduce

docker-compose.yaml

version: "3"

networks:
  netwrk:

services:
  otel-collector:
    image: otel/opentelemetry-collector-contrib
    volumes:
      - ./zotel-collector-config.yaml:/etc/otelcol/config.yaml
    ports:
      - 4318:4318 # OTLP http receiver
    networks:
      - netwrk                                                                                

zotel-collector-config.yaml

receivers:
  otlp:
    protocols:
      http:

exporters:
  debug:
    verbosity: detailed
service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [debug]

curl

curl -i -X POST -H "Content-Type: application/json" "http://localhost:4318/v1/logs" -d '{
    "resource_logs": [
        {
            "resource": {
                "attributes": [
                    {
                        "key": "service.name",
                        "value":{
                            "string_value":"my-app"
                        }
                    }
                ]
            },
            "scope_logs": [
                {
                    "scope": {"version":"1"},
                    "log_records":[
                        {
                            "time_unix_nano":1675091081000000000,
                            "attributes":[
                                {
                                    "key": "event.domain",
                                    "value":{
                                        "string_value":"browser"
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}'

Do the curl provided and observe the 404 error

in the docker-compose replace the
image: otel/opentelemetry-collector-contrib
with
image: otel/opentelemetry-collector
Do the curl again and observe the 200 OK

Expected Result

for image: otel/opentelemetry-collector-contrib the curl should return 200

Actual Result

404

Collector version

0.89.0

Environment information

docker

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      http:

exporters:
  debug:
    verbosity: detailed
service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [debug]

Log output

not sure if relevant:
2023-11-22T11:18:01.637Z        info    service@v0.89.0/telemetry.go:85 Setting up own telemetry...
2023-11-22T11:18:01.638Z        info    service@v0.89.0/telemetry.go:202        Serving Prometheus metrics      {"address": ":8888", "level": "Basic"}
2023-11-22T11:18:01.638Z        info    exporter@v0.89.0/exporter.go:275        Deprecated component. Will be removed in future releases.    {"kind": "exporter", "data_type": "traces", "name": "logging"}
2023-11-22T11:18:01.638Z        info    exporter@v0.89.0/exporter.go:275        Deprecated component. Will be removed in future releases.    {"kind": "exporter", "data_type": "metrics", "name": "logging"}
2023-11-22T11:18:01.638Z        warn    jaegerreceiver@v0.89.0/factory.go:49    jaeger receiver will deprecate Thrift-gen and replace it with Proto-gen to be compatbible to jaeger 1.42.0 and higher. See https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/18485 for more details.   {"kind": "receiver", "name": "jaeger", "data_type": "traces"}
2023-11-22T11:18:01.639Z        info    service@v0.89.0/service.go:143  Starting otelcol-contrib...     {"Version": "0.89.0", "NumCPU": 4}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:34     Starting extensions...
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:37     Extension is starting...        {"kind": "extension", "name": "pprof"}
2023-11-22T11:18:01.639Z        info    pprofextension@v0.89.0/pprofextension.go:60     Starting net/http/pprof server  {"kind": "extension", "name": "pprof", "config": {"TCPAddr":{"Endpoint":"0.0.0.0:1777"},"BlockProfileFraction":0,"MutexProfileFraction":0,"SaveToFile":""}}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:45     Extension started.      {"kind": "extension", "name": "pprof"}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:37     Extension is starting...        {"kind": "extension", "name": "health_check"}
2023-11-22T11:18:01.639Z        info    healthcheckextension@v0.89.0/healthcheckextension.go:35 Starting health_check extension {"kind": "extension", "name": "health_check", "config": {"Endpoint":"0.0.0.0:13133","TLSSetting":null,"CORS":null,"Auth":null,"MaxRequestBodySize":0,"IncludeMetadata":false,"ResponseHeaders":null,"Path":"/","ResponseBody":null,"CheckCollectorPipeline":{"Enabled":false,"Interval":"5m","ExporterFailureThreshold":5}}}
2023-11-22T11:18:01.639Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "extension", "name": "health_check", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:45     Extension started.      {"kind": "extension", "name": "health_check"}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:37     Extension is starting...        {"kind": "extension", "name": "zpages"}
2023-11-22T11:18:01.639Z        info    zpagesextension@v0.89.0/zpagesextension.go:53   Registered zPages span processor on tracer provider  {"kind": "extension", "name": "zpages"}
2023-11-22T11:18:01.639Z        info    zpagesextension@v0.89.0/zpagesextension.go:63   Registered Host's zPages        {"kind": "extension", "name": "zpages"}
2023-11-22T11:18:01.639Z        info    zpagesextension@v0.89.0/zpagesextension.go:75   Starting zPages extension       {"kind": "extension", "name": "zpages", "config": {"TCPAddr":{"Endpoint":"0.0.0.0:55679"}}}
2023-11-22T11:18:01.639Z        info    extensions/extensions.go:45     Extension started.      {"kind": "extension", "name": "zpages"}
2023-11-22T11:18:01.639Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "opencensus", "data_type": "metrics", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.640Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "jaeger", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.640Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "jaeger", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.640Z        info    prometheusreceiver@v0.89.0/metrics_receiver.go:239      Starting discovery manager      {"kind": "receiver", "name": "prometheus", "data_type": "metrics"}
2023-11-22T11:18:01.640Z        info    prometheusreceiver@v0.89.0/metrics_receiver.go:230      Scrape job added        {"kind": "receiver", "name": "prometheus", "data_type": "metrics", "jobName": "otel-collector"}
2023-11-22T11:18:01.640Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "zipkin", "data_type": "traces", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.641Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "otlp", "data_type": "metrics", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.641Z        info    otlpreceiver@v0.89.0/otlp.go:83 Starting GRPC server    {"kind": "receiver", "name": "otlp", "data_type": "metrics", "endpoint": "0.0.0.0:4317"}
2023-11-22T11:18:01.641Z        warn    internal@v0.89.0/warning.go:40  Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks      {"kind": "receiver", "name": "otlp", "data_type": "metrics", "documentation": "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks"}
2023-11-22T11:18:01.641Z        info    otlpreceiver@v0.89.0/otlp.go:101        Starting HTTP server    {"kind": "receiver", "name": "otlp", "data_type": "metrics", "endpoint": "0.0.0.0:4318"}
2023-11-22T11:18:01.641Z        info    prometheusreceiver@v0.89.0/metrics_receiver.go:281      Starting scrape manager {"kind": "receiver", "name": "prometheus", "data_type": "metrics"}
2023-11-22T11:18:01.641Z        info    healthcheck/handler.go:132      Health Check state change       {"kind": "extension", "name": "health_check", "status": "ready"}
2023-11-22T11:18:01.641Z        info    service@v0.89.0/service.go:169  Everything is ready. Begin running and processing data.

Additional context

No response

@truestep truestep added bug Something isn't working needs triage New item requiring triage labels Nov 22, 2023
@crobert-1
Copy link
Member

crobert-1 commented Nov 22, 2023

Hello @truestep, I was able to reproduce this and was confused as well. It turns out that the default path for the contrib config is different in the dockerfile than core.

I was confused as to why your logs were showing extensions and receivers that aren't in your config file (jaeger, pprof, zpages, prometheus, etc), and this is why, your config was not being used, it was using the default contrib docker config.

The solution is simply to mount your config file at the proper path:

version: "3"

networks:
  netwrk:

services:
  otel-collector:
    image: otel/opentelemetry-collector-contrib
    volumes:
      - ./zotel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
    ports:
      - 4318:4318 # OTLP http receiver
    networks:
      - netwrk                   

I was able to test and saw that the curl command was working after updating the mount path.

@crobert-1 crobert-1 added question Further information is requested and removed needs triage New item requiring triage bug Something isn't working labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants