I’m trying to put in the geoIP component with your config example here (which is working excellently), but as a beginner to Alloy, I’m having some trouble debugging why it’s not working. I’ve had several iterations where Alloy won’t start, but this current version is running fine, I just never get the fields populated. The live debugging isn’t helpful either because it’s not working.
logging {
level = "info"
format = "logfmt"
}
loki.source.syslog "receiver" {
listener {
address = "0.0.0.0:514"
protocol = "udp"
labels = {
component = "loki.source.syslog",
}
}
relabel_rules = loki.relabel.syslog.rules
forward_to = [loki.process.syslog.receiver]
}
loki.relabel "syslog" {
forward_to = []
rule {
source_labels = ["__syslog_message_hostname"]
target_label = "host"
}
rule {
source_labels = ["__syslog_message_severity"]
target_label = "level"
}
rule {
source_labels = ["__syslog_message_app_name"]
target_label = "syslog_app"
}
rule {
source_labels = ["__syslog_message_facility"]
target_label = "facility"
}
rule {
source_labels = ["__syslog_message_proc_id"]
target_label = "proc_id"
}
rule {
source_labels = ["__syslog_message_msg_id"]
target_label = "msg_id"
}
}
loki.process "syslog" {
forward_to = [loki.write.endpoint.receiver]
stage.match {
selector = "{syslog_app=\"filterlog\"}"
pipeline_name = "filterlog_parsing"
stage.regex {
expression = string.join(
[
"^(?P<rule>[^,]*)",
"(?P<subrule>[^,]*)",
"(?P<anchor>[^,]*)",
"(?P<tracker>[^,]*)",
"(?P<interface>[^,]*)",
"(?P<reason>[^,]*)",
"(?P<action>[^,]*)",
"(?P<direction>[^,]*)",
"(?P<ip_version>[^,]*)",
"(?P<remainder>.*)$",
], ",",
)
}
stage.labels {
values = {
ip_version = "",
}
}
}
stage.match {
selector = "{ip_version=\"4\"}"
pipeline_name = "filterlog_ipv4_parsing"
stage.regex {
source = "remainder"
expression = string.join(
[
"^(?P<tos>[^,]*)",
"(?P<ecn>[^,]*)",
"(?P<ttl>[^,]*)",
"(?P<id>[^,]*)",
"(?P<offset>[^,]*)",
"(?P<flags>[^,]*)",
"(?P<proto_id>[^,]*)",
"(?P<proto>[^,]*)",
"(?P<length>[^,]*)",
"(?P<source_ip>[^,]*)",
"(?P<dest_ip>[^,]*)",
"(?P<ip_remainder>.*)$",
], ",",
)
}
stage.labels {
values = {
proto_id = "",
}
}
}
stage.match {
selector = "{ip_version=\"6\"}"
pipeline_name = "filterlog_ipv6_parsing"
stage.regex {
source = "remainder"
expression = string.join(
[
"^(?P<class>[^,]*)",
"(?P<flow_label>[^,]*)",
"(?P<hop_limit>[^,]*)",
"(?P<proto>[^,]*)",
"(?P<proto_id>[^,]*)",
"(?P<length>[^,]*)",
"(?P<source_ip>[^,]*)",
"(?P<dest_ip>[^,]*)",
"(?P<ip_remainder>.*)$",
], ",",
)
}
stage.labels {
values = {
proto_id = "",
}
}
}
stage.match {
selector = "{proto_id=~\"6|17\"}"
pipeline_name = "filterlog_port_parsing"
stage.regex {
source = "ip_remainder"
expression = "^(?P<source_port>[^,]*),(?P<dest_port>[^,]*),"
}
}
stage.label_drop {
values = ["proto_id"]
}
stage.match {
selector = "{source_ip!=\"\"}"
pipeline_name = "source_ip_geo"
stage.geoip {
db = "/etc/alloy/geoip/GeoLite2-Country.mmdb"
db_type = "country"
source = "source_ip"
}
stage.labels {
values = {
geoip_country_name = "source_country",
}
}
}
stage.match {
selector = "{dest_ip!=\"\"}"
pipeline_name = "dest_ip_geo"
stage.geoip {
db = "/etc/alloy/geoip/GeoLite2-Country.mmdb"
db_type = "country"
source = "dest_ip"
}
stage.labels {
values = {
geoip_country_name = "dest_country",
}
}
}
stage.structured_metadata {
values = {
proc_id = "",
msg_id = "",
facility = "",
action = "",
direction = "",
interface = "",
reason = "",
proto = "",
source_ip = "",
dest_ip = "",
source_port = "",
dest_port = "",
source_country = "",
dest_country = "",
}
}
}
loki.write "endpoint" {
endpoint {
url ="http://localhost:3100/loki/api/v1/push"
}
}
Any thoughts?