I have a Loki listening for logs.
Here is an excerpt from the nginx config:
log_format main escape=json '{'
.............
'}';
access_log /var/log/nginx/access.log main;
I parse the logs and add labels using Alloy.
I don’t have errors from Alloy.
local.file_match "applogs" {
path_targets = [
{
__address__ = "localhost",
__path__ = "/var/log/nginx/access.log",
job = "nginx",
instance = "localhost",
},
]
}
loki.source.file "local_files" {
targets = local.file_match.applogs.targets
tail_from_end = true
forward_to = [
loki.process.add_new_label.receiver,
]
}
loki.process "add_new_label" {
stage.labels {
values = {
test = "test",
}
}
stage.structured_metadata {
values={
test1="test1",
}
}
forward_to = [
loki.write.grafana_loki.receiver,
]
}
loki.write "grafana_loki" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}
Checking labels via the API also doesn’t lead to anything.
root@yqhkujvybp:/# curl -s ‘``http://localhost:3100/loki/api/v1/labels``’
{“status”:“success”,“data”:[“filename”,“instance”,“job”,“service_name”]}
I would be grateful for any help!