Using OpenTelemetry Collector and Loki

Hello Everyone,

Recently I’m trying to connect Loki as a datasource to grafana but I’m receiving this error:

Data source connected, but no labels received. Verify that Loki and Promtail is configured properly.

This is my opentelemetry collector configuration:

receivers:
  otlp:
    protocols:
      grpc:
      http:

processors:
  
  attributes:
    actions:
    - action: insert
      key: loki.attribute.labels
      value: http.status_code

  resource:
    attributes:
    - action: insert
      key: loki.attribute.labels
      value: http.status
    - action: insert
      key: loki.resource.labels
      value: host.name, pod.name
  
  batch:
  
  memory_limiter:
    # 80% of maximum memory up to 2G
    limit_mib: 1500
    # 25% of limit up to 2G
    spike_limit_mib: 512
    check_interval: 5s

extensions:
  zpages: {}
  memory_ballast:
    # Memory Ballast size should be max 1/3 to 1/2 of memory.
    size_mib: 683
exporters:
  otlp:
    endpoint: "grafana-tempo.grafana-labs:4317" # Replace with a real endpoint.
    tls:
      insecure: true

  prometheus:
    endpoint: "0.0.0.0:8889"
    namespace: "default"

  jaeger:
    endpoint: "jaegertracing.jaeger:14250"
    tls:
      insecure: true
  loki:
    endpoint: "http://loki-nodeport.grafana-labs:3100/loki/api/v1/push"
    tls:
      insecure: true
service:
  extensions: [zpages, memory_ballast]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, batch]
      exporters: [otlp,jaeger]
    logs:
      receivers: [otlp]
      processors:  [memory_limiter, batch, attributes, resource]
      exporters: [otlp,loki]
    metrics:
      receivers: [otlp]
      processors:  [memory_limiter, batch]
      exporters: [prometheus]

The questions are:

Is there something else to configure here in this configuration?

Opentelemetry collector can send data directly to Loki without Promtail? If no what exporter should I use?.

Thanks in Advance.

I would use logging exporter in the logs pipeline, to see how logs are processed by processors.

I’m not sure about correct processor configuration/ I know, it is a copy&paste from Loki exporter doc, but all these components are in the beta state. I would use from_attribute instead of value. Of course check doc for used processor/exporter.