The OpenTelemetry collector failed to detect any resources because the necessary environment variables or configuration were not present, preventing it from identifying the service and its environment.

Common Causes and Fixes

1. Missing OTEL_SERVICE_NAME Environment Variable

  • Diagnosis: Check if the OTEL_SERVICE_NAME environment variable is set in the environment where the OpenTelemetry collector or application is running.
    echo $OTEL_SERVICE_NAME
    
  • Fix: Set the OTEL_SERVICE_NAME environment variable to a descriptive name for your service.
    export OTEL_SERVICE_NAME="my-awesome-service"
    
  • Why it works: This variable is the most fundamental piece of information for resource detection, acting as a primary identifier for the service.

2. Incorrectly Configured resource.attributes in Collector Configuration

  • Diagnosis: If you’re relying on the collector’s configuration to define resources, inspect the resource section of your otel-collector-config.yaml.
    # Example of incorrect or missing configuration
    receivers:
      otlp:
        protocols:
          grpc:
          http:
    
    processors:
      resource:
        # Missing or incorrect attributes
        attributes:
          - key: service.instance.id
            value: some-instance-id
          - key: environment
            value: production
    
    exporters:
      logging:
        loglevel: debug
    
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [resource]
          exporters: [logging]
    
  • Fix: Ensure you have at least a service.name attribute defined within the resource processor’s configuration.
    # Example of corrected configuration
    receivers:
      otlp:
        protocols:
          grpc:
          http:
    
    processors:
      resource:
        attributes:
          - key: service.name
            value: "my-collector-service" # Corrected to service.name
          - key: service.instance.id
            value: "instance-123"
          - key: environment
            value: "staging"
    
    exporters:
      logging:
        loglevel: debug
    
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [resource]
          exporters: [logging]
    
  • Why it works: The resource processor in the collector explicitly adds or overrides attributes for the detected resource. The service.name attribute is a standard and critical resource attribute.

3. Missing OTEL_RESOURCE_ATTRIBUTES Environment Variable

  • Diagnosis: Similar to OTEL_SERVICE_NAME, check for the OTEL_RESOURCE_ATTRIBUTES environment variable.
    echo $OTEL_RESOURCE_ATTRIBUTES
    
  • Fix: Set OTEL_RESOURCE_ATTRIBUTES with a comma-separated list of key-value pairs.
    export OTEL_RESOURCE_ATTRIBUTES="environment=development,cloud.provider=aws,region=us-east-1"
    
  • Why it works: This environment variable allows for defining multiple resource attributes directly, which the OpenTelemetry SDK or collector will pick up.

4. Kubernetes Environment Without Service Name in Pod Spec

  • Diagnosis: If running in Kubernetes, the resource detector often relies on pod metadata. Check your Kubernetes deployment YAML for the metadata.name of the pod.
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-app-deployment
    spec:
      template:
        metadata:
          labels:
            app: my-app
        spec:
          containers:
          - name: app-container
            image: my-docker-image
            env:
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: "http://otel-collector:4317"
            # Missing service name definition
    
  • Fix: Ensure your pod template has a metadata.name or metadata.labels that can be translated into a service name, or explicitly set OTEL_SERVICE_NAME within the pod’s environment variables. The Kubernetes resource detector can infer service.name from the deployment name or pod name if it’s not explicitly set.
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-app-deployment # This can be used as service.name
    spec:
      template:
        metadata:
          labels:
            app: my-app
        spec:
          containers:
          - name: app-container
            image: my-docker-image
            env:
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: "http://otel-collector:4317"
            - name: OTEL_SERVICE_NAME # Explicitly set
              value: "my-kubernetes-service"
    
  • Why it works: The Kubernetes resource detector uses Kubernetes API information to populate resource attributes. A missing or unresolvable service name means this detector cannot provide the essential service.name attribute.

5. Docker Environment Without Service Name or Labels

  • Diagnosis: If running in Docker without explicit environment variables, the default resource detection might fail to infer a meaningful service name.
    docker ps
    # Observe container names, but they might not be directly used for service.name
    
  • Fix: Set OTEL_SERVICE_NAME or OTEL_RESOURCE_ATTRIBUTES when running your Docker container.
    docker run -e OTEL_SERVICE_NAME="my-docker-app" my-docker-image
    
  • Why it works: Similar to Kubernetes, Docker resource detection can use container metadata. Explicitly providing the service name ensures it’s available.

6. Unconfigured or Disabled Resource Detector in Collector

  • Diagnosis: The OpenTelemetry Collector has a built-in resource detector. If it’s not enabled or configured, it won’t add resource attributes. Check your collector’s configuration for the resource processor.
    # Example collector config where resource processor might be missing or commented out
    processors:
      # batch:
      # resource: # This processor might be missing
      #   # attributes:
      #   #   - key: service.name
      #   #     value: "my-collector-service"
      #   #   - key: env
      #   #     value: "prod"
      #   #   - key: deployment.environment
      #   #     value: "production"
    
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [] # Resource processor not listed here
          exporters: [logging]
    
  • Fix: Ensure the resource processor is included in your collector’s configuration and that it’s listed in the relevant pipeline. You can configure it to add default attributes if environment variables are not set.
    processors:
      batch:
      resource:
        attributes:
          - key: service.name
            value: "default-collector-service" # Default value if none is found
          - key: deployment.environment
            value: "unknown"
          - key: telemetry.sdk.language
            value: "go" # Example
    
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [batch, resource] # Ensure resource processor is in pipeline
          exporters: [logging]
    
  • Why it works: The resource processor is responsible for detecting and adding resource attributes to telemetry data flowing through the collector. Without it, or if it’s not in the pipeline, these attributes won’t be populated by the collector itself.

After fixing these, you’ll likely encounter a "No Exporter Found" error if your exporter configuration is also missing or misconfigured.

Want structured learning?

Take the full Opentelemetry course →