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

[receiver/mongodbreceiver] Unauthorized to collect index stats on local db with proper role access #21114

Closed
JonathanWamsley opened this issue Apr 24, 2023 · 2 comments
Assignees
Labels
bug Something isn't working receiver/mongodb

Comments

@JonathanWamsley
Copy link
Contributor

Component(s)

receiver/mongodb

What happened?

Description

A scraper error is being emitted while collecting index stats on local database, reporting an Unauthorized error. Adding in the clusterMonitor role and even trying clusterAdmin role does not solve this problem. This error has also been reported here.

Steps to Reproduce

Run the collector and scrape mongodb metrics with a replica set. Every scrape reports an Unauthorized error.

Expected Result

To not get any errors.

Actual Result

Mar 31 16:35:23 custom.env.com otelcol-contrib[1970123]: 2023-03-31T16:35:23.168Z        error        scraperhelper/scrapercontroller.go:212        Error scraping metrics        {"kind": "receiver", "name": "mongodb", "data_type": "metrics", "error": "failed to fetch index stats metrics: (Unauthorized) not authorized on local to execute command { aggregate: \"system.replset\", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID(\"ABC123-4567-891011\") }, $clusterTime: { clusterTime: Timestamp(1680280515, 1), signature: { hash: BinData(0, AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA), keyId: 11111111111111111 } }, $db: \"local\", $readPreference: { mode: \"primary\" } }", "scraper": "mongodb"}

Collector version

0.73.0

Environment information

Environment

A MongoDB env with a replica set.

OpenTelemetry Collector configuration

receivers:
  mongodb:
    hosts:
      - endpoint: custom.env.com
    username: user
    password: pass
    collection_interval: 60s
    replica_set: rep0
    tls:
      ca_file: /etc/mongo/ssl/mongodb-ca.crt
      cert_file: /etc/mongo/ssl/mongodb.pem
      key_file: /etc/mongo/ssl/mongodb-cert.key
      insecure: false
      insecure_skip_verify: true

exporters:
  googlecloud:
      enabled: false
    log:
      default_log_name: opentelemetry.io/collector-exported-log


processors:
  batch:

service:
  pipelines:
    metrics:
      receivers: [mongodb]
      processors: [batch]
      exporters: [googlecloud]

Log output

Mar 31 16:35:23 custom.env.com otelcol-contrib[1970123]: 2023-03-31T16:35:23.168Z        error        scraperhelper/scrapercontroller.go:212        Error scraping metrics        {"kind": "receiver", "name": "mongodb", "data_type": "metrics", "error": "failed to fetch index stats metrics: (Unauthorized) not authorized on local to execute command { aggregate: \"system.replset\", pipeline: [ { $indexStats: {} } ], cursor: {}, lsid: { id: UUID(\"ABC123-4567-891011\") }, $clusterTime: { clusterTime: Timestamp(1680280515, 1), signature: { hash: BinData(0, AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA), keyId: 11111111111111111 } }, $db: \"local\", $readPreference: { mode: \"primary\" } }", "scraper": "mongodb"}

Additional context

I can work on this.

@JonathanWamsley JonathanWamsley added bug Something isn't working needs triage New item requiring triage labels Apr 24, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@JonathanWamsley
Copy link
Contributor Author

Resolved with #21116

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

No branches or pull requests

2 participants