I am having some issues converting a working Grafana Agent (static mode) config to a working Grafana Alloy config.
The following is the working Grafana Agent (static mode) config:
configs:
- name: base
scrape_configs:
- job_name: syslog
syslog:
listen_address: localhost:1514
labels:
job: syslog
service: "{{ customer.service }}"
environment: "{{ deployment.environment }}"
relabel_configs:
- source_labels: [__syslog_message_hostname]
target_label: host
- source_labels: [__syslog_message_severity]
target_label: level
- source_labels: [__syslog_message_app_name]
target_label: application
- source_labels: [__syslog_message_facility]
target_label: facility
- source_labels: [__syslog_connection_hostname]
replacement: "{{ansible_hostname}}"
target_label: connection_hostname
This successfully scrapes the logs from the remote port configures by rsyslog and labels them in Loki.
The following Alloy config (I’ve tried several different version) is not working the same:
loki.source.syslog “remote_syslog” {
listener {
address = “0.0.0.0:1514”
labels = {
component = “loki.source.syslog”,
protocol = “tcp”,
job = “va”,
service = “{{ customer.service }}”,
environment = “{{ deployment.environment }}”,
}
}
listener {
address = “0.0.0.0:1514”
protocol = “udp”
labels = {
component = “loki.source.syslog”,
protocol = “udp”,
job = “va”,
service = “{{ customer.service }}”,
environment = “{{ deployment.environment }}”,
}
}
forward_to = [loki.write.logs_base.receiver]
}
loki.relabel “remote_syslog” {
forward_to = [loki.write.logs_base.receiver]
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 = "application"
}
rule {
source_labels = ["__syslog_message_facility"]
target_label = "facility"
}
rule {
source_labels = ["__syslog_connection_hostname"]
replacement = "{{ ansible_hostname }}"
target_label = "connection_hostname"
}
}
It simply labels the static labels provided in the “listener” block but ignored any other labels.
Any help is appreciated!