2023-12-05 12:53:33 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
flake,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
2024-06-04 23:59:25 +00:00
|
|
|
# Only expose loki port via wireguard interface
|
|
|
|
networking.firewall.interfaces.wg-ssh.allowedTCPPorts = [ 3100 ];
|
|
|
|
|
2023-12-05 12:53:33 +00:00
|
|
|
# source: https://gist.github.com/rickhull/895b0cb38fdd537c1078a858cf15d63e
|
|
|
|
# https://grafana.com/docs/loki/latest/configure/examples/#1-local-configuration-exampleyaml
|
|
|
|
services.loki = {
|
|
|
|
enable = true;
|
|
|
|
configuration = {
|
|
|
|
server.http_listen_port = 3100;
|
|
|
|
auth_enabled = false;
|
|
|
|
common = {
|
|
|
|
ring = {
|
2024-06-01 12:46:29 +00:00
|
|
|
instance_interface_names = [ "wg-ssh" ];
|
|
|
|
instance_enable_ipv6 = true;
|
2023-12-05 12:53:33 +00:00
|
|
|
kvstore = {
|
|
|
|
store = "inmemory";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
replication_factor = 1;
|
|
|
|
path_prefix = "/var/lib/loki";
|
|
|
|
storage = {
|
|
|
|
filesystem = {
|
|
|
|
chunks_directory = "chunks/";
|
|
|
|
rules_directory = "rules/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-06-08 21:53:43 +00:00
|
|
|
ingester = {
|
|
|
|
chunk_encoding = "snappy";
|
|
|
|
chunk_idle_period = "1h";
|
|
|
|
};
|
|
|
|
query_range = {
|
|
|
|
results_cache = {
|
|
|
|
cache = {
|
|
|
|
embedded_cache = {
|
|
|
|
enabled = true;
|
|
|
|
max_size_mb = 500;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
chunk_store_config = {
|
|
|
|
max_look_back_period = "0s";
|
|
|
|
chunk_cache_config = {
|
|
|
|
embedded_cache = {
|
|
|
|
enabled = true;
|
|
|
|
max_size_mb = 500;
|
|
|
|
ttl = "24h";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-12-08 16:31:03 +00:00
|
|
|
# Keep logs for 4 weeks
|
|
|
|
# https://grafana.com/docs/loki/latest/operations/storage/retention/
|
2024-06-08 21:53:43 +00:00
|
|
|
limits_config = {
|
|
|
|
retention_period = "4w";
|
|
|
|
split_queries_by_interval = "0";
|
|
|
|
};
|
2023-12-08 16:31:03 +00:00
|
|
|
compactor = {
|
|
|
|
compaction_interval = "10m";
|
2024-06-12 11:07:11 +00:00
|
|
|
delete_request_store = "filesystem";
|
2023-12-08 16:31:03 +00:00
|
|
|
retention_enabled = true;
|
|
|
|
retention_delete_delay = "2h";
|
|
|
|
retention_delete_worker_count = 150;
|
|
|
|
};
|
2023-12-05 12:53:33 +00:00
|
|
|
schema_config = {
|
|
|
|
configs = [
|
|
|
|
{
|
|
|
|
from = "2020-05-15";
|
|
|
|
store = "boltdb-shipper";
|
|
|
|
object_store = "filesystem";
|
|
|
|
schema = "v11";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "24h";
|
|
|
|
};
|
|
|
|
}
|
2024-06-12 11:07:11 +00:00
|
|
|
{
|
|
|
|
from = "2024-05-31";
|
|
|
|
store = "tsdb";
|
|
|
|
object_store = "filesystem";
|
|
|
|
schema = "v13";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "24h";
|
|
|
|
};
|
|
|
|
}
|
2023-12-05 12:53:33 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.promtail = {
|
|
|
|
enable = true;
|
|
|
|
configuration = {
|
|
|
|
server = {
|
|
|
|
http_listen_port = 9080;
|
|
|
|
grpc_listen_port = 0;
|
|
|
|
};
|
|
|
|
positions = {
|
|
|
|
filename = "/tmp/positions.yaml";
|
|
|
|
};
|
|
|
|
clients = [
|
|
|
|
{
|
2024-06-01 12:46:29 +00:00
|
|
|
url = "http://flora-6.wg.pub.solar:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push";
|
2023-12-05 12:53:33 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
scrape_configs = [
|
|
|
|
{
|
|
|
|
job_name = "journal";
|
|
|
|
journal = {
|
|
|
|
max_age = "24h";
|
|
|
|
labels = {
|
|
|
|
job = "systemd-journal";
|
|
|
|
host = "flora-6";
|
2024-05-08 20:57:07 +00:00
|
|
|
};
|
2023-12-05 12:53:33 +00:00
|
|
|
};
|
|
|
|
relabel_configs = [
|
|
|
|
{
|
|
|
|
source_labels = [ "__journal__systemd_unit" ];
|
|
|
|
target_label = "unit";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|