open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
3.11k stars 2.39k forks source link

Update Example for Loki Exporter to new OTLP standard #35770

Open lucalamalfa91 opened 1 month ago

lucalamalfa91 commented 1 month ago

Component(s)

exporter/loki

Details

The current example for the Loki exporter in the otelcol-contrib repository is not outdated but will be deprecated from 2024 November 1. It uses the loki exporter with the following configuration:

receivers:
  journald:
    directory: /var/log/journal/a04e3a44cdd740f88d6a7ae3bb8c70cf

exporters:
  debug:
    verbosity: detailed
  loki:
    endpoint: http://localhost:3100/loki/api/v1/push
    tls:
      insecure: true

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

    - action: insert
      key: http_status_code
      value: 500

  resource:
    attributes:
    - action: insert
      key: loki.resource.labels
      value: host_name, pod_name

    - action: insert
      key: host_name
      value: guarana
    - action: insert
      key: pod_name
      value: guarana-pod-01

extensions:

service:
  extensions:
  pipelines:
    logs:
      receivers: [journald]
      processors: [resource, attributes]
      exporters: [debug, loki]

Proposed Changes The example should be updated to reflect the new configuration using the otlphttp/loki exporter as follows:

receivers:
  journald:
    directory: /var/log/journal/a04e3a44cdd740f88d6a7ae3bb8c70cf

exporters:
  debug:
    verbosity: detailed
  otlphttp/loki:
    endpoint: "http://localhost:3100/otlp"
    tls:
      insecure: true

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

  resource:
    attributes:
    - action: insert
      key: loki.resource.labels
      value: host_name, pod_name

extensions:

service:
  extensions:
  pipelines:
    logs:
      receivers: [journald]
      processors: [resource, attributes]
      exporters: [debug, otlphttp/loki]

This update is important because the new version of Loki (>= 3.0) supports the OTLP standard. By using the otlphttp/loki exporter, users can take advantage of the latest features and improvements in Loki, ensuring a more streamlined and effective logging experience. The current configuration will no longer be supported after November 1, making this update essential for users.

github-actions[bot] commented 1 month ago

Pinging code owners:

mar4uk commented 1 month ago

Hello, thank you for reporting the issue! I think the example directory should contain the config showing deprecated loki exporter usage, since it is loki exporter dedicated folder.

We already have an example of using otlphttp exporter instead of loki exporter in the README. We can add additional config with otlphttp exporter usage to the example directory so it has both variants: the old one and the new one. Would it be sufficient?