Add rsyslog / promtail log relay
This commit is contained in:
parent
3a0a383b77
commit
c256a6ee06
1 changed files with 64 additions and 14 deletions
|
@ -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,20 +183,57 @@ in
|
|||
clients = [{
|
||||
url = "http://127.0.0.1:3100/loki/api/v1/push";
|
||||
}];
|
||||
scrape_configs = [{
|
||||
job_name = "journal";
|
||||
journal = {
|
||||
max_age = "12h";
|
||||
labels = {
|
||||
job = "systemd-journal";
|
||||
host = "localhost";
|
||||
scrape_configs = [
|
||||
{
|
||||
job_name = "journal";
|
||||
journal = {
|
||||
max_age = "12h";
|
||||
labels = {
|
||||
job = "systemd-journal";
|
||||
host = "localhost";
|
||||
};
|
||||
};
|
||||
};
|
||||
relabel_configs = [{
|
||||
source_labels = [ "__journal__systemd_unit" ];
|
||||
target_label = "unit";
|
||||
}];
|
||||
}];
|
||||
relabel_configs = [{
|
||||
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";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue