Skip to content

[exporter/otlp] port is not recognized correctly #12536

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

Closed
JPeer264 opened this issue Mar 3, 2025 · 5 comments
Closed

[exporter/otlp] port is not recognized correctly #12536

JPeer264 opened this issue Mar 3, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@JPeer264
Copy link

JPeer264 commented Mar 3, 2025

Component(s)

exporter/otlp

What happened?

Describe the bug

When using the config from below it wouldn't see the port in the correct place. Adding or removing the port would result in either port is missing or invalid port. The collector can't start since the port is expected to be at the very end of the URL.

Steps to reproduce

  1. Create a file config.yaml in any directory
  2. Copy/Paste the collector config from below
  3. Execute docker run --rm -v $(pwd)/config.yaml:/etc/otel/config.yaml otel/opentelemetry-collector:0.120.0 --config /etc/otel/config.yaml

What did you expect to see?
I actually expected that it would recognize the port correctly (without the pathname). The example with otel/tempo is actually working, since there is no pathname needed.

What did you see instead?

Following error was seen instead:

invalid port "443/api/prom/push"

(maybe related #10488)

Collector version

v0.120.0 (asuming docker has the same version)

Environment information

Environment

OS: MacOS 15.3.1 (not sure if needed if it is running within Docker)

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
exporters:
  otlp/tempo:
    # URL ending with :443
    endpoint: https://tempo-prod-xxx.grafana.net:443
  otlp/loki:
    # URL without port
    endpoint: https://logs-prod-xxx.grafana.net/loki/api/v1/push
  otlp/metrics:
    # URL with port directly after domain
    endpoint: https://prometheus-prod-xxx.grafana.net:443/api/prom/push
  otlp/withouthttps:
    # URL with port directly after domain
    endpoint: otlp-gateway-prod-xxx.grafana.net:443/otlp
service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters:
        - otlp/loki
    metrics:
      receivers: [otlp]
      exporters:
        - otlp/metrics
        - otlp/withouthttps
    traces:
      receivers: [otlp]
      exporters:
        - otlp/tempo

Log output

Explicit log output:

Error: invalid configuration: exporters::otlp/loki: address logs-prod-xxx.grafana.net/loki/api/v1/push: missing port in address
exporters::otlp/metrics: invalid port "443/api/prom/push"
exporters::otlp/withouthttps: invalid port "443/otlp"
2025/03/03 19:03:35 collector server run finished with error: invalid configuration: exporters::otlp/loki: address logs-prod-xxx.grafana.net/loki/api/v1/push: missing port in address
exporters::otlp/metrics: invalid port "443/api/prom/push"
exporters::otlp/withouthttps: invalid port "443/otlp"

Additional context

No response

@JPeer264 JPeer264 added the bug Something isn't working label Mar 3, 2025
@jade-guiton-dd
Copy link
Contributor

Are you sure you want to use the OTLP over gRPC exporter (exporter/otlp), not the OTLP over HTTP exporter (exporter/otlphttp)?

I don't think gRPC supports a path on the endpoint.

We [strip out](https://github.com/open-telemetry/opentelemetry-collector/blob/72a8471b96ad5df66c7a0671fcde7217b263acaa/config/configgrpc/configgrpc.go#L212) any `http://` or `https://` prefix, then feed it to gRPC. Looking at [this doc](https://github.com/grpc/grpc/blob/master/doc/naming.md), it looks like without a prefix, the endpoint is interpreted as a DNS URI, which I don't think has a concept of a path, and no example in that doc contains a path. Another piece of evidence to that effect is [this (admittedly quite old) thread](https://groups.google.com/g/grpc-io/c/e1041Rw2mQI), where it is said that it's not planned to be supported either.

So if you are given an OTLP URL with a path to send data to, I suspect it may be for OTLP over HTTP, not OTLP over gRPC.

In that regard, I think it is correct to reject these endpoints, but we should probably be emitting a clearer error message ("paths are not supported for OTLP over gRPC" for example).

@wilsc-tech
Copy link

I am also facing the same issue when using otlp/http with port. Trying out using OCI APM and the endpoint provided does not come with a port.

exporters:
otlp/http:
endpoint: "https://xxxx.oci.oraclecloud.com"
headers:
Authorization: 'dataKey '

Error message: invalid configuration: exporters::otlp/http: address xxxx.oci.oraclecloud.com: missing port in address

@jade-guiton-dd
Copy link
Contributor

@wilsc-tech Writing otlp/http instantiates the otlp exporter, with the http config name (as you can have multiple configs for the same exporter). What you want is probably the otlphttp exporter (with no slash).

@jade-guiton-dd
Copy link
Contributor

So if you are given an OTLP URL with a path to send data to, I suspect it may be for OTLP over HTTP, not OTLP over gRPC.

@JPeer264 I'm not very familiar with Grafana, but checking the docs quickly, I found this page which mentions OTEL_EXPORTER_OTLP_PROTOCOL being set to http/protobuf, and this page which explicitly mentions using the otlphttp exporter, which seems to confirm my previous guess that you are using the wrong exporter.

@JPeer264
Copy link
Author

JPeer264 commented Mar 8, 2025

@jade-guiton-dd you are totally right otlphttp makes absolutely more sense here - thanks for pointing to the right direction. I think this can be closed.

In that regard, I think it is correct to reject these endpoints, but we should probably be emitting a clearer error message ("paths are not supported for OTLP over gRPC" for example).

Regarding the error improvement, I think this is a better fit in #10488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants