telemetry: removed promtail in favor of Alloy

This commit is contained in:
Tigor Hutasuhut 2024-09-09 17:53:38 +07:00
parent 4da42e98a0
commit 0f45241285
2 changed files with 42 additions and 70 deletions

View file

@ -94,19 +94,59 @@ in
loki.write "default" { loki.write "default" {
endpoint { endpoint {
url = "http://${lokiConfig.server.http_listen_address}:${toString lokiConfig.server.http_listen_port}" url = "http://${lokiConfig.server.http_listen_address}:${toString lokiConfig.server.http_listen_port}/loki/api/v1/push"
} }
} }
loki.relabel "journal" {
forward_to = []
rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}
rule {
source_labels = ["__journal__hostname"]
target_label = "host"
}
rule {
source_labels = [ "__journal__systemd_user_unit" ]
target_label = "user_unit"
}
rule {
source_labels = [ "__journal__transport" ]
target_label = "transport"
}
rule {
source_labels = [ "__journal_priority_keyword" ]
target_label = "severity"
}
}
loki.source.journal "read" {
forward_to = [loki.write.default.receiver]
relabel_rules = loki.relabel.journal.rules
labels = {
job = "systemd-journal",
component = "loki.source.journal",
}
}
otelcol.exporter.otlp "tempo" { otelcol.exporter.otlp "tempo" {
client { client {
endpoint = "${tempoServer.http_listen_address}:${toString tempoServer.http_listen_port}" endpoint = "${tempoServer.http_listen_address}:${toString tempoServer.http_listen_port}"
} }
} }
prometheus.exporter.unix "system" {}
prometheus.scrape "system" {
targets = prometheus.exporter.unix.system.targets
forward_to = [prometheus.remote_write.mimir.receiver]
}
prometheus.remote_write "mimir" { prometheus.remote_write "mimir" {
endpoint { endpoint {
url = "http://${mimirServer.http_listen_address}:${toString mimirServer.http_listen_port}" url = "http://${mimirServer.http_listen_address}:${toString mimirServer.http_listen_port}/api/v1/push"
} }
} }
''; '';

View file

@ -39,74 +39,6 @@ in
reverse_proxy ${server.http_listen_address}:${toString server.http_listen_port} reverse_proxy ${server.http_listen_address}:${toString server.http_listen_port}
''; '';
systemd.tmpfiles.settings = {
"promtail-dir" = {
"/var/lib/promtail" = {
d = {
group = "promtail";
mode = "0755";
user = "promtail";
};
};
};
};
services.promtail = {
enable = true;
configuration = {
server = {
http_listen_port = 3031;
grpc_listen_port = 0;
};
clients = [
{
url = "http://${server.http_listen_address}:${toString server.http_listen_port}/loki/api/v1/push";
}
];
positions = {
filename = "/var/lib/promtail/positions.yaml";
};
scrape_configs = [
{
job_name = "systemd-journal";
relabel_configs = [
{
source_labels = [ "__journal__hostname" ];
target_label = "host";
}
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "systemd_unit";
regex = ''(.+)'';
}
{
source_labels = [ "__journal__systemd_user_unit" ];
target_label = "systemd_user_unit";
regex = ''(.+)'';
}
{
source_labels = [ "__journal__transport" ];
target_label = "transport";
regex = ''(.+)'';
}
{
source_labels = [ "__journal_priority_keyword" ];
target_label = "severity";
regex = ''(.+)'';
}
];
journal = {
labels = {
job = "systemd-journal";
};
path = "/var/log/journal";
};
}
];
};
};
services.loki = services.loki =
let let
dataDir = config.services.loki.dataDir; dataDir = config.services.loki.dataDir;