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 { 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 = { services.grafana = {
enable = true; enable = true;
settings = { settings = {
@ -170,20 +183,57 @@ in
clients = [{ clients = [{
url = "http://127.0.0.1:3100/loki/api/v1/push"; url = "http://127.0.0.1:3100/loki/api/v1/push";
}]; }];
scrape_configs = [{ scrape_configs = [
job_name = "journal"; {
journal = { job_name = "journal";
max_age = "12h"; journal = {
labels = { max_age = "12h";
job = "systemd-journal"; labels = {
host = "localhost"; job = "systemd-journal";
host = "localhost";
};
}; };
}; relabel_configs = [{
relabel_configs = [{ source_labels = [ "__journal__systemd_unit" ];
source_labels = [ "__journal__systemd_unit" ]; target_label = "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";
}
];
}
];
}; };
}; };