I would like to setup Grafana alloy to forward logs from a third-party application to my Grafana Loki log server. The application outputs logs in a rolling file format that must be scraped. I would like to add two labels to the log entries scraped: server
for the hostname and app
for the name of the application. My current alloy setup does forward logs, but not as expected. When I explore logs in Loki, I don’t see the labels I’ve added in the alloy config. Additionally, there are 3 other labels, which I assume alloy scraper adds by default: filename
, server
, and service_name
. Is it possible to remove these labels and have alloy transmit only the labels I want?
Here is my current config:
local.file_match "local_files" {
path_targets = [{"__path__" = "D:/log/*.log"}]
sync_period = "5s"
}
loki.source.file "log_scrape" {
targets = local.file_match.local_files.targets
forward_to = [loki.process.add_labels.receiver]
tail_from_end = true
}
loki.process "add_labels" {
forward_to = [loki.write.grafana_loki.receiver]
stage.labels {
values = {
server = "my-server",
app = "my-app",
}
}
}
loki.write "grafana_loki" {
endpoint {
url = "http://my-log-server:3100/loki/api/v1/push"
}
}
I took this config from the post add_labels so very confused why it doesn’t seem to work here.