93 lines
2.2 KiB
Nix
93 lines
2.2 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
{
|
|
sops = {
|
|
defaultSopsFile = ../../secrets/passwords.yaml;
|
|
secrets."services/grafana/admin_password" = {
|
|
mode = "0440";
|
|
owner = "grafana";
|
|
group = "grafana";
|
|
restartUnits = [ "grafana.service" ];
|
|
};
|
|
secrets."services/loki/basic_auth" = {
|
|
mode = "0777";
|
|
};
|
|
};
|
|
|
|
# configure static IP address
|
|
networking.useDHCP = false;
|
|
systemd.network = {
|
|
enable = true;
|
|
networks = {
|
|
"10-mgmtNet" = {
|
|
matchConfig.MACAddress = "BC:24:11:FC:C2:26";
|
|
address = [ "10.20.25.4/24" ];
|
|
gateway = [ "10.20.25.2" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
services.alloy = {
|
|
enable = true;
|
|
configPath = "/etc/alloy/config.alloy";
|
|
};
|
|
|
|
environment.etc."alloy/config.alloy" = {
|
|
text = ''
|
|
prometheus.remote_write "default" {
|
|
endpoint {
|
|
url = "http://127.0.0.1:9009/api/v1/push"
|
|
}
|
|
}
|
|
loki.write "default" {
|
|
endpoint {
|
|
url = "http://127.0.0.1:3100/loki/api/v1/push"
|
|
}
|
|
}
|
|
|
|
loki.relabel "journal" {
|
|
forward_to = []
|
|
|
|
rule {
|
|
source_labels = ["__journal__systemd_unit"]
|
|
target_label = "unit"
|
|
}
|
|
}
|
|
|
|
loki.source.journal "read_journal" {
|
|
forward_to = [loki.write.default.receiver]
|
|
relabel_rules = loki.relabel.journal.rules
|
|
labels = {component = "loki.source.journal", host = "${config.networking.hostName}"}
|
|
}
|
|
|
|
logging {
|
|
level = "info"
|
|
format = "logfmt"
|
|
}
|
|
|
|
prometheus.exporter.unix "local_system" { }
|
|
|
|
prometheus.scrape "scrape_metrics" {
|
|
targets = prometheus.exporter.unix.local_system.targets
|
|
forward_to = [prometheus.remote_write.default.receiver]
|
|
scrape_interval = "10s"
|
|
}
|
|
'';
|
|
};
|
|
|
|
imports = [
|
|
./grafana.nix
|
|
./mimir.nix
|
|
./loki.nix
|
|
];
|
|
|
|
# DO NOT CHANGE
|
|
# this defines the first version of NixOS that was installed on the machine so that programs with non-migratable data files are kept compatible
|
|
home-manager.users.noc.home.stateVersion = "24.11";
|
|
system.stateVersion = "24.11";
|
|
}
|