I have a logfile with lots of messages, but I only want to forward the lines that got the word “Accepted” (or if possile also “Rejected”) in the logline
This is what I tried, but alloy does not accept it:
loki.process "filter_logs" {
stage.match {
// Valid LogQL: match all streams, then lines that do NOT contain "Accepted"
selector = "{} !~ \"Accepted\""
action = "keep"
// For lines that matched the selector above, drop them all
stage.drop {
expression = ".*"
drop_counter_reason = "not_accepted"
}
}
stage.static_labels {
values = {
"location" = "greenhouse north",
"line" = "carrot",
}
}
forward_to = [loki.write.grafana_loki.receiver]
}
How can I do this without forwarding he whole log to loki and filter in grafana