Skip to content
27 changes: 27 additions & 0 deletions modules/alloy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ pkgs, ... }: {
services.alloy = {
enable = true;
configPath = pkgs.writeText "config.alloy" ''
loki.relabel "journal" {
forward_to = []

rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}
}

loki.source.journal "read" {
forward_to = [loki.write.endpoint.receiver]
relabel_rules = loki.relabel.journal.rules
labels = {component = "loki.source.journal"}
}

loki.write "endpoint" {
endpoint {
url = "tgsatan.tg.lan:3100/api/v1/push"
}
}
'';
};
}
1 change: 1 addition & 0 deletions modules/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
imports = [
./node-exporter.nix
./systemd-exporter.nix
./alloy.nix
];

environment.variables."FLAKE" = "${self}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@
type = "prometheus";
access = "proxy";
url = "http://tgsatan.tg.lan:9090"; # Change when prometheus is moved
isDefault = true;
isDefault = true; # dead var?
}
{
name = "loki";
type = "loki";
proxy = "proxy";
url = "http://tgsatan.tg.lan:3100"; # Change when Loki is moved
}
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{...}: {
imports = [
./prometheus.nix
./loki.nix
];
}
41 changes: 41 additions & 0 deletions systems/game-servers/systems/tgsatan/modules/monitoring/loki.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ ... }: {
services.loki = {
enable = true;
dataDir = "/persist/loki";
configuration = {
auth_enabled = false;
server = {
http_listen_port = 3100;
};
common = {
instance_addr = "127.0.0.1";
path_prefix = "/tmp/loki";
storage.filesystem = {
chunks_directory = "/tmp/loki/chunks";
rules_directory = "/tmp/loki/rules";
};
replication_factor = 1;
ring.kvstore.store = "inmemory";
};
query_range.results_cache.cache.embedded_cache = {
enabled = true;
max_size_mb = 100;
};
schema_config.configs = [
{
from = "2020-10-24";
store = "tsdb";
object_store = "filesystem";
schema = "v13";
index = {
prefix = "index_";
period = "24h";
};
}
];
# Enable this if we ever use services.prometheus.alertManager.enable = true;
# ruler.alertmanager_url = "http://localhost:9093";
frontend.encoding = "protobuf";
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ in {
job_name = "caddy";
static_configs = [{targets = ["tgsatan.tg.lan:2019"];}];
}
{
job_name = "loki";
metrics_path = "/metrics";
static_configs = [{targets = ["tgsatan.tg.lan:3100"];}];
}
# {
# job_name = "tgsatan_forgejo";
# static_configs [ { targets= [ "tgsatan.tg.lan:9001" ]; } ];
Expand Down