Hello Grafana Community,
Pushing app logs from local grafana alloy to Grafana cloud.
Service name of the logs shows up as unknown_service in the logs ui.
How to fix this?
Thank you.
Hello Grafana Community,
Pushing app logs from local grafana alloy to Grafana cloud.
Service name of the logs shows up as unknown_service in the logs ui.
How to fix this?
Thank you.
I had this same problem. at first i used
stage.labels {
values = {
job = "my_job_name",
service_name = "my_job_name",
}
from this answer but it did not work for me. I then tried
stage.static_labels {
values = {
job = "nginx",
service_name = "nginx",
}
this seemed to do the trick, i was able to see nginx in grafana cloud explorer for loki logs.
Here is the full config
otelcol.auth.basic "grafana_auth" {
username = env("BASIC_AUTH_GRAFANA_USERNAME")
password = env("BASIC_AUTH_GRAFANA_PASSWORD")
}
local.file_match "nginx_logs" {
path_targets = [
{__path__ = "/var/log/nginx/*.log"},
]
}
loki.source.file "nginx_logfiles" {
targets = local.file_match.nginx_logs.targets
forward_to = [loki.process.labels.receiver]
}
loki.process "labels" {
forward_to = [loki.write.grafanacloud.receiver]
stage.static_labels {
values = {
job = "nginx",
service_name = "nginx",
}
}
}
loki.write "grafanacloud" {
max_streams = 10
endpoint {
url = "https://logs-prod3.grafana.net/loki/api/v1/push"
batch_wait = "5s"
batch_size = "1MiB"
min_backoff_period = "1s"
basic_auth {
username = "xxxxxx"
password = env("BASIC_AUTH_GRAFANA_LOKI")
}
}
}
Awesome. Thank you very much for this solution
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.