-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[exporter/loki] Loki v3.0's generated service_name
is invalid when service.namespace
is defined
#32497
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
@cyrille-leclerc Thanks |
Hello Aloisio, As discussed with @sandeepsukhani and the Loki team, the solution is to adopt the new Loki OTLP Endpoint as a replacement to the OpenTelemetry Collector Loki Exporter. Using the Loki OTLP Endpoint is documented in Ingesting logs to Loki using OpenTelemetry Collector Here is an example of OTel Collector config that sends all OTel traces, metrics, and Logs to Grafana Cloud using the Grafana Cloud OTLP endpoint rather converting to Prometheus and Loki in the OTel Collector. The same type of config works with Mimir, Loki, and Tempo; you just have to spcify one OTLP endpoint for each Telemetry type. # Tested with Otel Collector Contrib v0.100.0
receivers:
otlp:
protocols:
grpc:
http:
hostmetrics:
scrapers:
load:
memory:
#...
processors:
batch:
resourcedetection:
# Enriches telemetry data with resource information from the host
detectors: ["env", "system"]
override: false
transform/add_resource_attributes_as_metric_attributes:
# add context labels to Prometheus metrics in order to enable group-by and filter-by on metrics
error_mode: ignore
metric_statements:
- context: datapoint
statements:
- set(attributes["deployment.environment"], resource.attributes["deployment.environment"])
- set(attributes["service.version"], resource.attributes["service.version"])
transform/truncate_attributes:
# As Mimir label and Loki metad ta values are limited to 2048 characters
# truncate:
# - metrics: attributes and resource atributes
# - span: resource attributes in case some metrics are derived from spans in Tempo / Grafana Cloud
# - logs: resource attributes
error_mode: ignore
trace_statements:
- context: resource
statements:
- truncate_all(attributes, 2048)
- context: span
statements:
- truncate_all(attributes, 2048)
metric_statements:
- context: resource
statements:
- truncate_all(attributes, 2048)
- context: datapoint
statements:
- truncate_all(attributes, 2048)
log_statements:
- context: resource
statements:
- truncate_all(attributes, 2048)
exporters:
otlphttp/grafana_cloud:
endpoint: "${env:OTEL_EXPORTER_OTLP_ENDPOINT}"
auth:
authenticator: basicauth/grafana_cloud
extensions:
basicauth/grafana_cloud:
client_auth:
username: "${env:GRAFANA_CLOUD_INSTANCE_ID}"
password: "${env:GRAFANA_CLOUD_API_KEY}"
service:
extensions: [basicauth/grafana_cloud]
pipelines:
traces:
receivers: [otlp, jaeger]
processors:
- resourcedetection
- transform/truncate_attributes
- batch
exporters: [otlphttp/grafana_cloud]
metrics:
receivers: [otlp, hostmetrics]
processors:
- resourcedetection
- transform/add_resource_attributes_as_metric_attributes
- transform/truncate_attributes
- batch
exporters: [otlphttp/grafana_cloud]
logs:
receivers: [otlp]
processors:
- resourcedetection
- transform/truncate_attributes
- batch
exporters: [otlphttp/grafana_cloud] |
Component(s)
Loki Exporter
What happened?
Description
Loki v3.0, as part of its OpenTelemetry support, generates a
service_name
label if none is provided and the current heuristic (here) contradicts the Prometheus and OpenMetrics Compatibility specification for logs emitted by the OTel Collector Loki Exporter using the value of thejob
label ignoring that thisjob
label could be the composition ofservice.name
withservice.namespace
.Ideas to fix the problem:
service_name
andservice_namespace
labels so that Loki's defaulting heuristic doesn't use thejob
valueservice_name
default heuristic to detect messages withexporter=OTLP
and then getservice_name
parsing the json payload and extract the fieldresources/service.name
Steps to Reproduce
For example, the OTel logs emitted from a service identified by (
service.namespace=ecommerce
,service.name=frontend
) and exported by the OTel Collector Loki exporter will produce logs with:job=ecommerce/frontend
service_name=ecommerce/frontend
<-- added by Loki's defaultservice_name
heuristic, invalid, expected value isfrontend
exporter=OTLP
{"body": "the message", "resources":{"service.name"="frontend", "service.namespace"="ecommerce"...}}
Expected Result
The generated label
service_name
should be set tofrontend
.Actual Result
The generated label
service_name
is set toecommerce/frontend
instead offrontend
.Collector version
v0.98
Environment information
Environment
OS: MacOS
OpenTelemetry Collector configuration
Log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: