cluster/services/monitoring: make loki HA

This commit is contained in:
Max Headroom 2024-08-03 00:56:13 +02:00
parent 201f07efc3
commit 7ca4cead09
4 changed files with 18 additions and 17 deletions

View file

@ -26,7 +26,7 @@ in {
name = "logging";
positions.filename = "\${STATE_DIRECTORY:/tmp}/logging-positions.yaml";
clients = singleton {
url = "${cluster.config.links.loki-ingest.url}/loki/api/v1/push";
url = "${cluster.config.ways.monitoring-logs.url}/loki/api/v1/push";
};
scrape_configs = singleton {
job_name = "journal";

View file

@ -14,14 +14,6 @@ in
];
links = {
loki-ingest = {
protocol = "http";
ipv4 = meshIpFor "logging";
};
loki = {
protocol = "http";
ipv4 = meshIpFor "logging";
};
prometheus-ingest = {
protocol = "http";
ipv4 = meshIpFor "server";
@ -58,7 +50,7 @@ in
client = [ "checkmate" "grail" "thunderskin" "VEGAS" "prophet" ];
blackbox = [ "checkmate" "grail" "prophet" ];
grafana = [ "VEGAS" "prophet" ];
logging = [ "VEGAS" ];
logging = [ "VEGAS" "grail" ];
server = [ "VEGAS" ];
};
nixos = {
@ -74,6 +66,10 @@ in
./tracing.nix
];
};
meshLinks.logging = {
name = "loki";
link.protocol = "http";
};
};
garage = {

View file

@ -2,7 +2,7 @@
let
inherit (depot.lib.meta) domain;
inherit (cluster.config.links) loki-ingest prometheus-ingest;
inherit (cluster.config.links) prometheus-ingest;
inherit (cluster.config) hostLinks;

View file

@ -3,13 +3,17 @@
let
inherit (config.links) loki-grpc;
inherit (cluster.config.links) loki-ingest;
link = cluster.config.hostLinks.${config.networking.hostName}.loki;
cfg = config.services.loki;
in
{
links.loki-grpc.protocol = "grpc";
systemd.services.loki = {
distributed = {
enable = true;
registerService = "loki";
};
after = [ "wireguard-wgmesh.service" ];
serviceConfig.EnvironmentFile = "/run/locksmith/garage-loki-ingest";
};
@ -26,8 +30,8 @@ in
auth_enabled = false;
server = {
log_level = "warn";
http_listen_address = loki-ingest.ipv4;
http_listen_port = loki-ingest.port;
http_listen_address = link.ipv4;
http_listen_port = link.port;
grpc_listen_address = loki-grpc.ipv4;
grpc_listen_port = loki-grpc.port;
};
@ -110,16 +114,17 @@ in
};
consul.services.loki = {
mode = "manual";
definition = {
name = "loki";
address = loki-ingest.ipv4;
inherit (loki-ingest) port;
address = link.ipv4;
inherit (link) port;
checks = [
{
name = "Loki";
id = "service:loki:backend";
interval = "5s";
http = "${loki-ingest.url}/ready";
http = "${link.url}/ready";
}
];
};