2023-05-10 00:13:30 +03:00
|
|
|
{ config, cluster, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (config.links) loki-grpc;
|
|
|
|
|
2024-08-03 01:56:13 +03:00
|
|
|
link = cluster.config.hostLinks.${config.networking.hostName}.loki;
|
2023-05-10 00:13:30 +03:00
|
|
|
|
|
|
|
cfg = config.services.loki;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
links.loki-grpc.protocol = "grpc";
|
2023-11-07 21:29:45 +02:00
|
|
|
systemd.services.loki = {
|
2024-08-03 01:56:13 +03:00
|
|
|
distributed = {
|
|
|
|
enable = true;
|
|
|
|
registerService = "loki";
|
|
|
|
};
|
2023-11-07 21:29:45 +02:00
|
|
|
after = [ "wireguard-wgmesh.service" ];
|
2024-08-03 01:37:06 +03:00
|
|
|
serviceConfig.EnvironmentFile = "/run/locksmith/garage-loki-ingest";
|
2023-11-07 21:29:45 +02:00
|
|
|
};
|
2024-08-03 01:37:06 +03:00
|
|
|
|
|
|
|
services.locksmith.waitForSecrets.loki = [
|
|
|
|
"garage-loki-ingest"
|
|
|
|
];
|
|
|
|
|
2023-05-10 00:13:30 +03:00
|
|
|
services.loki = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = "/srv/storage/private/loki";
|
2023-11-08 20:55:19 +02:00
|
|
|
extraFlags = [ "--config.expand-env=true" ];
|
2023-05-10 00:13:30 +03:00
|
|
|
configuration = {
|
|
|
|
auth_enabled = false;
|
|
|
|
server = {
|
|
|
|
log_level = "warn";
|
2024-08-03 01:56:13 +03:00
|
|
|
http_listen_address = link.ipv4;
|
|
|
|
http_listen_port = link.port;
|
2023-05-10 00:13:30 +03:00
|
|
|
grpc_listen_address = loki-grpc.ipv4;
|
|
|
|
grpc_listen_port = loki-grpc.port;
|
|
|
|
};
|
|
|
|
frontend_worker.frontend_address = loki-grpc.tuple;
|
|
|
|
ingester = {
|
|
|
|
lifecycler = {
|
|
|
|
address = "127.0.0.1";
|
|
|
|
ring = {
|
|
|
|
kvstore.store = "inmemory";
|
|
|
|
replication_factor = 1;
|
|
|
|
};
|
|
|
|
final_sleep = "0s";
|
|
|
|
};
|
|
|
|
chunk_idle_period = "5m";
|
|
|
|
chunk_retain_period = "30s";
|
|
|
|
};
|
|
|
|
schema_config.configs = [
|
|
|
|
{
|
|
|
|
from = "2022-05-14";
|
|
|
|
store = "boltdb";
|
|
|
|
object_store = "filesystem";
|
|
|
|
schema = "v11";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "168h";
|
|
|
|
};
|
|
|
|
}
|
2023-11-07 21:29:45 +02:00
|
|
|
{
|
|
|
|
from = "2023-11-08";
|
|
|
|
store = "boltdb-shipper";
|
|
|
|
object_store = "s3";
|
|
|
|
schema = "v11";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "24h";
|
|
|
|
};
|
|
|
|
}
|
2024-06-07 02:11:41 +03:00
|
|
|
{
|
|
|
|
from = "2024-06-10";
|
|
|
|
store = "tsdb";
|
|
|
|
object_store = "s3";
|
|
|
|
schema = "v13";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "24h";
|
|
|
|
};
|
|
|
|
}
|
2023-05-10 00:13:30 +03:00
|
|
|
];
|
|
|
|
storage_config = {
|
|
|
|
boltdb.directory = "${cfg.dataDir}/boltdb-index";
|
|
|
|
filesystem.directory = "${cfg.dataDir}/storage-chunks";
|
2023-11-07 21:29:45 +02:00
|
|
|
boltdb_shipper = {
|
|
|
|
active_index_directory = "${cfg.dataDir}/boltdb-shipper-index";
|
|
|
|
cache_location = "${cfg.dataDir}/boltdb-shipper-cache";
|
|
|
|
};
|
2024-06-07 02:11:41 +03:00
|
|
|
tsdb_shipper = {
|
|
|
|
active_index_directory = "${cfg.dataDir}/tsdb-shipper-index";
|
|
|
|
cache_location = "${cfg.dataDir}/tsdb-shipper-cache";
|
|
|
|
};
|
2023-11-07 21:29:45 +02:00
|
|
|
aws = {
|
|
|
|
endpoint = cluster.config.links.garageS3.url;
|
|
|
|
s3forcepathstyle = true;
|
|
|
|
bucketnames = "loki-chunks";
|
|
|
|
region = "us-east-1";
|
|
|
|
access_key_id = "\${AWS_ACCESS_KEY_ID}";
|
|
|
|
secret_access_key = "\${AWS_SECRET_ACCESS_KEY}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
compactor = {
|
|
|
|
working_directory = "${cfg.dataDir}/compactor-work";
|
2023-05-10 00:13:30 +03:00
|
|
|
};
|
|
|
|
limits_config = {
|
|
|
|
reject_old_samples = true;
|
|
|
|
reject_old_samples_max_age = "168h";
|
2024-06-07 02:11:41 +03:00
|
|
|
allow_structured_metadata = false;
|
2023-05-10 00:13:30 +03:00
|
|
|
};
|
2024-06-07 02:11:41 +03:00
|
|
|
query_scheduler.max_outstanding_requests_per_tenant = 32768;
|
|
|
|
querier.max_concurrent = 16;
|
2023-05-10 00:13:30 +03:00
|
|
|
};
|
|
|
|
};
|
2024-08-03 01:12:15 +03:00
|
|
|
|
|
|
|
consul.services.loki = {
|
2024-08-03 01:56:13 +03:00
|
|
|
mode = "manual";
|
2024-08-03 01:12:15 +03:00
|
|
|
definition = {
|
|
|
|
name = "loki";
|
2024-08-03 01:56:13 +03:00
|
|
|
address = link.ipv4;
|
|
|
|
inherit (link) port;
|
2024-08-03 01:12:15 +03:00
|
|
|
checks = [
|
|
|
|
{
|
|
|
|
name = "Loki";
|
|
|
|
id = "service:loki:backend";
|
|
|
|
interval = "5s";
|
2024-08-03 01:56:13 +03:00
|
|
|
http = "${link.url}/ready";
|
2024-08-03 01:12:15 +03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-05-10 00:13:30 +03:00
|
|
|
}
|