Skip to content

Failing to fetch index stats metrics #38188

Open
@Bambusgamer

Description

@Bambusgamer

Component(s)

receiver/mongodb

What happened?

Description

A scraper error is being emitted while collecting index stats on the database, reporting an Location40602 error. Disabling the by default enabled index metrics did not resolve the problem.

Steps to Reproduce

Run the collector and scrape mongodb metrics. Every scrape reports an error.

Expected Result

Not getting this error.

Actual Result

Feb 25 16:47:17 mongodb otelcol-contrib[1111752]: 2025-02-25T16:47:17.804Z        error        scraperhelper/obs_metrics.go:56        Error scraping metrics        {"kind": "receiver", "name": "mongodb", "data_type": "metrics", "scraper": "mongodb", "error": "failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline"}

Collector version

v0.120.1

Environment information

Environment

OS: Ubuntu 20.04.6
MongoDB: v7.0.2 Community

OpenTelemetry Collector configuration

receivers:
  mongodb:
    hosts:
      - endpoint: localhost:27017
    collection_interval: 60s
    initial_delay: 1s
    tls:
      insecure: true
      insecure_skip_verify: true
    metrics:
      mongodb.index.access.count:
        enabled: false
      mongodb.index.count:
        enabled: false
      mongodb.index.size:
        enabled: false
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu: {}
      disk: {}
      load: {}
      filesystem: {}
      memory: {}
      network: {}
      paging: {}
      process:
        mute_process_name_error: true
        mute_process_exe_error: true
        mute_process_io_error: true
      processes: {}
  prometheus:
    config:
      global:
        scrape_interval: 30s
      scrape_configs:
        - job_name: otel-collector-binary
          static_configs:
            - targets: ['localhost:8888']
processors:
  batch:
    send_batch_size: 1000
    timeout: 10s
  resourcedetection:
    detectors: [env, system]
    timeout: 2s
    system:
      hostname_sources: [os]
extensions:
  health_check: {}
  pprof:
  zpages: {}
exporters:
  otlp:
    endpoint: "ingest.[...].net:4317"
    tls:
      insecure: true
  debug:
service:
  telemetry:
    metrics:
      address: 0.0.0.0:8888
  extensions: [health_check, pprof, zpages]
  pipelines:
    metrics:
      receivers: [mongodb]
      processors: [batch, resourcedetection]
      exporters: [otlp]
    metrics/internal:
      receivers: [prometheus, hostmetrics]
      processors: [resourcedetection, batch]
      exporters: [otlp]

Log output

Feb 25 16:47:17 mongodb otelcol-contrib[1111752]: 2025-02-25T16:47:17.804Z        error        scraperhelper/obs_metrics.go:56        Error scraping metrics        {"kind": "receiver", "name": "mongodb", "data_type": "metrics", "scraper": "mongodb", "error": "failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline; failed to fetch index stats metrics: (Location40602) $indexStats is only valid as the first stage in a pipeline"}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions