Add rsyslog / promtail log relay

This commit is contained in:
Théo Barnouin 2024-10-07 12:23:45 +02:00
parent 3a0a383b77
commit c256a6ee06

View file

@ -15,7 +15,20 @@ in
};
};
config = lib.mkIf cfg.enable {
services.rsyslogd.enable = true;
services.rsyslogd = {
enable = true;
extraConfig = ''
ruleset(name="remote"){
action(type="omfwd" Target="localhost" Port="1514" Protocol="tcp" Template="RSYSLOG_SyslogProtocol23Format" TCP_Framing="octet-counted")
}
module(load="imudp")
input(type="imudp" port="514" ruleset="remote")
module(load="imtcp")
input(type="imtcp" port="514" ruleset="remote")
'';
};
services.grafana = {
enable = true;
settings = {
@ -170,7 +183,8 @@ in
clients = [{
url = "http://127.0.0.1:3100/loki/api/v1/push";
}];
scrape_configs = [{
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
@ -183,7 +197,43 @@ in
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}];
}];
}
{
job_name = "syslog";
syslog = {
listen_address = "0.0.0.0:1514";
labels = {
job = "syslog";
};
};
relabel_configs = [
{
source_labels = [ "__syslog_message_hostname" ];
target_label = "host";
}
{
source_labels = [ "__syslog_message_hostname" ];
target_label = "hostname";
}
{
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" ];
target_label = "connection_hostname";
}
];
}
];
};
};