Can't set logs service_name for docker logs #336
Replies: 3 comments
-
@cyrille-leclerc can you give a recommendation? |
Beta Was this translation helpful? Give feedback.
-
I think this is a question for https://github.com/grafana/alloy?tab=readme-ov-file#community |
Beta Was this translation helpful? Give feedback.
-
@fcortes Basically define relabeling rules. Then use the exported fields in Here's config snippet that did the trick for me:
Here's the backlink to the solution: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not really sure if this is a problem with this setup, Loki's OTLP endpoint, Alloy, me, or somewhere in-between, but I've been struggling for a while to make the following (seemingly simple) setup work
grafana/otel-lgtm
imageFor the log ingestion and service discoverability I'm using Alloy and everything seem to work fine except the
service_name
attribute in the stored logs. For some reason, loki is adding its ownservice_name=unknown_service
label even if I try to explicitly set it. This is pretty important when trying to correlate traces as it is the only filter that grafana automatically applies when clicking on the "Go to logs" button (there's probably a way to configure this in grafana itself but following the philosophy of the repository, I don't want to start messing with each service config).I found a couple of threads with similar problems but could't use any proposed solution successfully (like this one and this one)
Am I doing something wrong? Or is this too much to ask for this no-config repository?
Setup to reproduce the behavior
Use this compose file
Things I have tried
Default options
config.alloy
No
service_name
detected (expected)Add a docker processor
Thinking that it may be able to infer some names from the integration
config.alloy
No

service_name
either (kind of expected too)Explicitly set the label in the docker processor
config.alloy
Completely ignored the

service_name
label. It did set the other non-standard label correctlyExplicitly set it as a static_label instead
config.alloy
The label is added, but Loki appends
_extracted
to the key and sets its ownservice_name
tounknown_service
Add relabeling rules in the discovery level
config.alloy
Pretty much the same behavior.

service_name
being ignored and redefined.Set attributes using a
otelcol.processor.attributes
(this way I could set
service.name
instead ofservice_name
which was proposed somewhere)config.alloy
Same thing
Try to disable Loki trying to infer the service name
https://grafana.com/docs/loki/latest/setup/upgrade/#service_name-label
config.alloy
You get the point...
Beta Was this translation helpful? Give feedback.
All reactions