Hi,
I setup a loki instance and started ingesting the logs using kube logging operator.
But it seems the service_name is always unknown_service.
I tried sending different fields like service_name, service.name and service, but nothing works it still shows the same unknown_service.
i restarted the loki cluster also but it didnt work.
example value of my service “monitoring______grafana__prometheus“
is this a known issue? or am i missing something?
your help is deeply appreciated,
thanks
Try to send desired service.name as resource (not log line) attribute.
got it, to set service as resource, i added the below in loki configuration:
labels:
service: $.service
This resolved my issue and started grouping the logs properly.
@vipinjn24 @jangaraj , we are facing same unknown_service issue, Plugin used is fluent-plugin-grafana-loki. We tried below config in Loki chart and the other config on fluentd side, please advise:
Loki-chart-config:
limits_config:
discover_service_name:
- index
Fluentd-side config:
<label>
index $.index
service_name $.index
service $.index
</label>
full fluentd loki-config:
<label @REWRITTEN>
<match \*\*>
@type loki
url "#{ENV\['LOKI_URL'\]}"
ca_cert /secure/tls-certs/ca.crt
line_format json
\# FIX 1: Provide ONLY 'index' and 'valli'.
\# Remove 'service_name' and 'service' so Loki's chart can discover 'index' automatically.
<label>
valli $.index
index $.index
service_name $.index
service $.index
</label>
\# FIX 2: Do NOT include 'remove_keys index'.
\# If you remove it here, Fluentd's buffer chunking breaks during evaluation.
\# FIX 3: Keep $.index as the primary memory chunk routing key.
<buffer $.index>
@type memory
flush_interval 1s
retry_type periodic
retry_forever false
retry_wait 10s
retry_max_times 2
chunk_limit_size 8m
total_limit_size 256MB
overflow_action drop_oldest_chunk
flush_thread_count 16
queued_chunks_limit_size 32
flush_at_shutdown true
</buffer>
</match>
</label>