feat: grafana loki
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
lokiPort = config.m3ta.ports.get "loki";
|
||||
alloyPort = config.m3ta.ports.get "alloy";
|
||||
in {
|
||||
services.alloy = {
|
||||
enable = true;
|
||||
configPath = "/etc/alloy";
|
||||
extraFlags = [
|
||||
"--server.http.listen-addr=127.0.0.1:${toString alloyPort}"
|
||||
"--disable-reporting"
|
||||
];
|
||||
};
|
||||
|
||||
environment.etc."alloy/config.alloy".text = ''
|
||||
loki.relabel "journal" {
|
||||
forward_to = []
|
||||
|
||||
rule {
|
||||
source_labels = ["__journal__systemd_unit"]
|
||||
target_label = "unit"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__journal_priority_keyword"]
|
||||
target_label = "level"
|
||||
}
|
||||
|
||||
rule {
|
||||
source_labels = ["__journal_syslog_identifier"]
|
||||
target_label = "syslog_identifier"
|
||||
}
|
||||
}
|
||||
|
||||
loki.source.journal "system" {
|
||||
forward_to = [loki.process.journal.receiver]
|
||||
relabel_rules = loki.relabel.journal.rules
|
||||
labels = {
|
||||
host = "AZ-PRM-1",
|
||||
environment = "prod",
|
||||
}
|
||||
}
|
||||
|
||||
loki.process "journal" {
|
||||
forward_to = [loki.write.local.receiver]
|
||||
|
||||
stage.json {
|
||||
expressions = {
|
||||
app = "app",
|
||||
service = "service",
|
||||
level = "level",
|
||||
trace_id = "trace_id",
|
||||
session_id = "session_id",
|
||||
n8n_execution_id = "execution_id",
|
||||
workflow_id = "workflow_id",
|
||||
execution_id = "execution_id",
|
||||
message = "message",
|
||||
}
|
||||
drop_malformed = false
|
||||
}
|
||||
|
||||
stage.labels {
|
||||
values = {
|
||||
app = "",
|
||||
service = "",
|
||||
level = "",
|
||||
}
|
||||
}
|
||||
|
||||
stage.structured_metadata {
|
||||
values = {
|
||||
trace_id = "",
|
||||
session_id = "",
|
||||
n8n_execution_id = "",
|
||||
workflow_id = "",
|
||||
execution_id = "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loki.write "local" {
|
||||
endpoint {
|
||||
url = "http://127.0.0.1:${toString lokiPort}/loki/api/v1/push"
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
||||
systemd.services.alloy.serviceConfig.SupplementaryGroups = lib.mkAfter ["adm"];
|
||||
}
|
||||
Reference in New Issue
Block a user