This works!
///Help here to sort out stage.match instead of stage.drop
// https://github.com/grafana/alloy/issues/467
// https://grafana.com/docs/alloy/latest/tutorials/send-logs-to-loki/
local.file_match "local_files" {
path_targets = [{
__address__ = "localhost",
__path__ = "/var/log/28/log.log",
}]
}
loki.source.file "log_scrape" {
targets = local.file_match.local_files.targets
forward_to = [loki.process.filter_logs.receiver]
}
//drop all but selector "!~"
loki.process "filter_logs" {
stage.match {
selector = "{filename=\"/var/log/28/log.log\"} !~ \".*the_only_text_to_send_to_Loki\""
action = "drop"
}
forward_to = [loki.write.grafanacloud.receiver]
}
loki.write "grafanacloud" {
endpoint {
url = "https://logs-prod-us-central1.grafana.net/loki/api/v1/push"
basic_auth {
username = "grafanacloudusername"
password = "grafana_auth_token"
}
}
}