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

Question on basicauth extension usage #17532

Closed
pkalvagit opened this issue Jan 11, 2023 · 5 comments
Closed

Question on basicauth extension usage #17532

pkalvagit opened this issue Jan 11, 2023 · 5 comments
Labels
extension/basicauth question Further information is requested

Comments

@pkalvagit
Copy link

Component(s)

extension/basicauth

Describe the issue you're reporting

I configured to use basic authentication extension sever authentication as follows. That is starting successfully. how to configure exporter with basicauth/client? getting below error. any help appreciated.

`
extensions:
basicauth/server:
inline: |
test:test123

receivers:
otlp/auth:
protocols:
grpc:
auth:
authenticator: basicauth/server
endpoint: 0.0.0.0:40000

  http:
    auth:
      authenticator: basicauth/server
    endpoint: 0.0.0.0:40001

exporters:
logging:
loglevel: debug

service:
extensions: [basicauth/server]
pipelines:
traces:
receivers: [otlp/auth]
processors: []
exporters: [logging]
`

Expoter with basicauth/client

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

extensions:
basicauth/client:
client_auth:
username: admin
password: admin123

exporters:
otlp:
endpoint: "monocleotelcolcustom:40000"
auth:
authenticator: basicauth/client
logging:
loglevel: debug

processors:
batch:
timeout: 2s

service:
extensions: [basicauth/client]
pipelines:
traces:
receivers: [otlp]
processors: [batch,]
exporters: [logging, otlp]`
getting below error:

goroutine 1 [running]:
google.golang.org/grpc.(*ClientConn).Close(0x0)
google.golang.org/[email protected]/clientconn.go:1016 +0x4b
go.opentelemetry.io/collector/exporter/otlpexporter.(*exporter).shutdown(0x6907297?, {0x4?, 0xc00061f701?})
go.opentelemetry.io/collector/exporter/[email protected]/otlp.go:93 +0x1d
go.opentelemetry.io/collector/component.ShutdownFunc.Shutdown(...)
go.opentelemetry.io/collector/[email protected]/component.go:95
go.opentelemetry.io/collector/exporter/exporterhelper.newBaseExporter.func2({0x75de9c0, 0xc000210000})
go.opentelemetry.io/[email protected]/exporter/exporterhelper/common.go:182 +0x5a
go.opentelemetry.io/collector/component.ShutdownFunc.Shutdown(...)
go.opentelemetry.io/collector/[email protected]/component.go:95
go.opentelemetry.io/collector/service/internal/pipelines.(*Pipelines).ShutdownAll(0xc000bf3db0, {0x75de9c0, 0xc000210000})
go.opentelemetry.io/[email protected]/service/internal/pipelines/pipelines.go:135 +0x36b
go.opentelemetry.io/collector/service.(*service).Shutdown(0xc0001b4500, {0x75de9c0, 0xc000210000})
go.opentelemetry.io/[email protected]/service/service.go:121 +0xd4
go.opentelemetry.io/collector/service.(*Collector).shutdownServiceAndTelemetry(0xc00143fa88, {0x75de9c0?, 0xc000210000?})
go.opentelemetry.io/[email protected]/service/collector.go:264 +0x36
go.opentelemetry.io/collector/service.(*Collector).setupConfigurationComponents(0xc00143fa88, {0x75de9c0, 0xc000210000})
go.opentelemetry.io/[email protected]/service/collector.go:166 +0x286
go.opentelemetry.io/collector/service.(*Collector).Run(0xc00143fa88, {0x75de9c0, 0xc000210000})
go.opentelemetry.io/[email protected]/service/collector.go:190 +0x46
go.opentelemetry.io/collector/service.NewCommand.func1(0xc000242600, {0x69107b9?, 0x1?, 0x1?})
go.opentelemetry.io/[email protected]/service/command.go:53 +0x479
github.com/spf13/cobra.(*Command).execute(0xc000242600, {0xc000222010, 0x1, 0x1})
github.com/spf13/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000242600)
github.com/spf13/[email protected]/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:968
main.runInteractive({{0xc000678330, 0xc000679500, 0xc000678750, 0xc000af5fb0}, {{0x69388ae, 0xf}, {0x69b56ff, 0x1f}, {0x690a299, 0x6}}, ...})
github.com/open-telemetry/opentelemetry-collector-releases/contrib/main.go:32 +0x5d
main.run(...)
github.com/open-telemetry/opentelemetry-collector-releases/contrib/main_others.go:11
main.main()
github.com/open-telemetry/opentelemetry-collector-releases/contrib/main.go:25 +0x1d8

@pkalvagit pkalvagit added the needs triage New item requiring triage label Jan 11, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

Pinging code owners for extension/basicauth: @jpkrohling @svrakitin. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@frzifus
Copy link
Member

frzifus commented Jan 12, 2023

Hi @pkalvagit could you maybe format your reported configs? Its quite hard to read and test it on my system.

@pkalvagit
Copy link
Author

pkalvagit commented Jan 12, 2023

hi @frzifus , please below format.
Server auth config, want to validate basic auth on receiver:

extensions:
  basicauth/server:
      inline: |
        test:test123

receivers:
  otlp/auth:
    protocols:
      grpc:
        auth:
          authenticator: basicauth/server
        endpoint: 0.0.0.0:40000
        
      http:
        auth:
          authenticator: basicauth/server
        endpoint: 0.0.0.0:40001
        
exporters:
  logging:
    loglevel: debug

service:
  extensions: [basicauth/server]
  pipelines:
    traces:
      receivers: [otlp/auth]
      processors: []
      exporters: [logging]

client the exporter with basic auth, export traces with basic auth username and password. want to export with otlp and otlp httlp both

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

extensions:
  basicauth/client:
    client_auth: 
      username: test
      password: test123

exporters:
  otlp:
    endpoint: "monocleotelcolcustom:40000"
    auth:
      authenticator: basicauth/client
 otlphttp:
    endpoint: "monocleotelcolcustom:40001"
    auth:
      authenticator: basicauth/client
  logging:
    loglevel: debug

processors:
  batch:
    timeout: 2s


service:
  extensions: [basicauth/client]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [logging, otlp]

Please let me know for any additional details needed. Thank you so much!

@frzifus frzifus added question Further information is requested and removed needs triage New item requiring triage labels Jan 12, 2023
@frzifus
Copy link
Member

frzifus commented Jan 12, 2023

Seems there are some ident issues in the config. Thats the config i used:

server.yaml
extensions:
  basicauth/server:
    htpasswd:
      inline: |
        test:test123

receivers:
  otlp/auth:
    protocols:
      grpc:
        auth:
          authenticator: basicauth/server
        endpoint: 0.0.0.0:40000
        
      http:
        auth:
          authenticator: basicauth/server
        endpoint: 0.0.0.0:40001
        
exporters:
  logging:
    loglevel: debug

service:
  extensions: [basicauth/server]
  pipelines:
    traces:
      receivers: [otlp/auth]
      processors: []
      exporters: [logging]
client.yaml
receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318
      grpc:
        endpoint: 0.0.0.0:4317

extensions:
  basicauth/client:
    client_auth: 
      username: test
      password: test123

exporters:
  otlp:
    endpoint: "127.0.0.1:40000"
    auth:
      authenticator: basicauth/client
    tls:
      insecure: true
  otlphttp:
    endpoint: "127.0.0.1:40001"
    auth:
      authenticator: basicauth/client
    tls:
      insecure: true
  logging:
    loglevel: debug

processors:
  batch:
    timeout: 2s


service:
  extensions: [basicauth/client]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [logging, otlp]

Running this locally using docker:

# server
docker run --rm -it --network=host -v $(pwd)/server.yaml:/config.yaml:z otel/opentelemetry-collector-contrib:0.66.0 --config=/config.yaml
# client
docker run --rm -it --network=host -v $(pwd)/client.yaml:/config.yaml:z otel/opentelemetry-collector-contrib:0.66.0 --config=/config.yaml

It crashes with the same stacktrace:

2023-01-12T13:21:50.688Z	info	service/telemetry.go:111	Setting up own telemetry...
2023-01-12T13:21:50.688Z	info	service/telemetry.go:141	Serving Prometheus metrics	{"address": ":8888", "level": "Basic"}
2023-01-12T13:21:50.688Z	info	components/components.go:30	Development component. May change in the future.	{"kind": "exporter", "data_type": "traces", "name": "logging", "stability": "Development"}
2023-01-12T13:21:50.688Z	warn	loggingexporter@v0.66.0/factory.go:110	'loglevel' option is deprecated in favor of 'verbosity'. Set 'verbosity' to equivalent value to preserve behavior.	{"kind": "exporter", "data_type": "traces", "name": "logging", "loglevel": "debug", "equivalent verbosity level": "Detailed"}
2023-01-12T13:21:50.689Z	info	service/service.go:89	Starting otelcol-contrib...	{"Version": "0.66.0", "NumCPU": 8}
2023-01-12T13:21:50.689Z	info	extensions/extensions.go:41	Starting extensions...
2023-01-12T13:21:50.689Z	info	extensions/extensions.go:44	Extension is starting...	{"kind": "extension", "name": "basicauth/client"}
2023-01-12T13:21:50.689Z	info	extensions/extensions.go:48	Extension started.	{"kind": "extension", "name": "basicauth/client"}
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:74	Starting exporters...
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:78	Exporter is starting...	{"kind": "exporter", "data_type": "traces", "name": "logging"}
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:82	Exporter started.	{"kind": "exporter", "data_type": "traces", "name": "logging"}
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:78	Exporter is starting...	{"kind": "exporter", "data_type": "traces", "name": "otlp"}
2023-01-12T13:21:50.689Z	info	service/service.go:115	Starting shutdown...
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:118	Stopping receivers...
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:125	Stopping processors...
2023-01-12T13:21:50.689Z	info	pipelines/pipelines.go:132	Stopping exporters...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9c232b]

goroutine 1 [running]:
google.golang.org/grpc.(*ClientConn).Close(0x0)
	google.golang.org/grpc@v1.51.0/clientconn.go:1016 +0x4b
go.opentelemetry.io/collector/exporter/otlpexporter.(*exporter).shutdown(0x6907297?, {0x4?, 0x8e40c01?})
	go.opentelemetry.io/collector/exporter/otlpexporter@v0.66.0/otlp.go:93 +0x1d
go.opentelemetry.io/collector/component.ShutdownFunc.Shutdown(...)
	go.opentelemetry.io/collector/component@v0.66.0/component.go:95
go.opentelemetry.io/collector/exporter/exporterhelper.newBaseExporter.func2({0x75de9c0, 0xc000214000})
	go.opentelemetry.io/collector@v0.66.0/exporter/exporterhelper/common.go:182 +0x5a
go.opentelemetry.io/collector/component.ShutdownFunc.Shutdown(...)
	go.opentelemetry.io/collector/component@v0.66.0/component.go:95
go.opentelemetry.io/collector/service/internal/pipelines.(*Pipelines).ShutdownAll(0xc000ca4370, {0x75de9c0, 0xc000214000})
	go.opentelemetry.io/collector@v0.66.0/service/internal/pipelines/pipelines.go:135 +0x36b
go.opentelemetry.io/collector/service.(*service).Shutdown(0xc000231e00, {0x75de9c0, 0xc000214000})
	go.opentelemetry.io/collector@v0.66.0/service/service.go:121 +0xd4
go.opentelemetry.io/collector/service.(*Collector).shutdownServiceAndTelemetry(0xc0010c7a88, {0x75de9c0?, 0xc000214000?})
	go.opentelemetry.io/collector@v0.66.0/service/collector.go:264 +0x36
go.opentelemetry.io/collector/service.(*Collector).setupConfigurationComponents(0xc0010c7a88, {0x75de9c0, 0xc000214000})
	go.opentelemetry.io/collector@v0.66.0/service/collector.go:166 +0x286
go.opentelemetry.io/collector/service.(*Collector).Run(0xc0010c7a88, {0x75de9c0, 0xc000214000})
	go.opentelemetry.io/collector@v0.66.0/service/collector.go:190 +0x46
go.opentelemetry.io/collector/service.NewCommand.func1(0xc000242c00, {0x69107b9?, 0x1?, 0x1?})
	go.opentelemetry.io/collector@v0.66.0/service/command.go:53 +0x479
github.com/spf13/cobra.(*Command).execute(0xc000242c00, {0xc000224010, 0x1, 0x1})
	github.com/spf13/cobra@v1.6.1/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000242c00)
	github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.1/command.go:968
main.runInteractive({{0xc0007bde00, 0xc0007daff0, 0xc0007da240, 0xc0007bdaa0}, {{0x69388ae, 0xf}, {0x69b56ff, 0x1f}, {0x690a299, 0x6}}, ...})
	github.com/open-telemetry/opentelemetry-collector-releases/contrib/main.go:32 +0x5d
main.run(...)
	github.com/open-telemetry/opentelemetry-collector-releases/contrib/main_others.go:11
main.main()
	github.com/open-telemetry/opentelemetry-collector-releases/contrib/main.go:25 +0x1d8

Seem the be related to open-telemetry/opentelemetry-collector#6619.

Using a newer version, it terminates without a panic:

Error: cannot start pipelines: grpc: the credentials require transport level security (use grpc.WithTransportCredentials() to set)
2023/01/12 13:28:35 collector server run finished with error: cannot start pipelines: grpc: the credentials require transport level security (use grpc.WithTransportCredentials() to set)

Seems you need to enable tls. Hope that helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension/basicauth question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants