I am using loki.source.syslog to process syslogs from various targets. I want to add custom labels based on the ip_address that is passed in the syslog. I have successfully pulled out the ip_address from the log and used loki.process with stage.match and stage.static_labels to assign the custom labels.
loki.process “syslog_add_labels” {
stage.match {
selector = “{sourceip="10.0.0.0"}”
stage.static_labels {
values = {
“location” = “test1”,
“environment” = “test2”,
“application” = “findme”,
}
}
}
stage.match {
selector = “{sourceip="9.2.3.4.5"}”
stage.static_labels {
values = {
“location” = “chicago”,
“environment” = “production”,
“application” = “app1”,
}
}
}
stage.match {
selector = “{sourceip="4.5.6.7.8"}”
stage.static_labels {
values = {
“location” = “indianapolis”,
“environment” = “development”,
“application” = “app2”,
}
}
}
forward_to = [loki.write.grafana_cloud_loki.receiver]
}
As I add more targets, I need to deploy a new river file each time. Is there a way to use a file to lists the map? That way I only need to deploy a new file and the river will pick up the changes.