mirror of
https://git.sr.ht/~rouven/nixos-config
synced 2025-04-25 08:06:19 +02:00
add grafana and prometheus
This commit is contained in:
parent
78b1a5761c
commit
862e8ecfb2
8 changed files with 94 additions and 20 deletions
|
@ -7,7 +7,8 @@
|
|||
# ./modules/adguard
|
||||
./modules/networks
|
||||
# ./modules/backup
|
||||
# ./modules/hydra
|
||||
./modules/grafana
|
||||
./modules/prometheus
|
||||
./modules/matrix
|
||||
./modules/nextcloud
|
||||
./modules/seafile
|
||||
|
|
|
@ -25,13 +25,10 @@
|
|||
];
|
||||
encryption_passcommand = "${pkgs.coreutils}/bin/cat ${config.sops.secrets."borg/passphrase".path}";
|
||||
compression = "lz4";
|
||||
retention = {
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 12;
|
||||
keep_yearly = 3;
|
||||
|
||||
};
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 12;
|
||||
keep_yearly = 3;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
44
hosts/nuc/modules/grafana/default.nix
Normal file
44
hosts/nuc/modules/grafana/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ config, ... }:
|
||||
let
|
||||
domain = "monitoring.${config.networking.domain}";
|
||||
in
|
||||
{
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
inherit domain;
|
||||
http_addr = "127.0.0.1";
|
||||
http_port = 3000;
|
||||
};
|
||||
database = {
|
||||
type = "postgres";
|
||||
user = "grafana";
|
||||
host = "/run/postgresql";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureUsers = [
|
||||
{
|
||||
name = "grafana";
|
||||
ensurePermissions = {
|
||||
"DATABASE grafana" = "ALL PRIVILEGES";
|
||||
};
|
||||
}
|
||||
];
|
||||
ensureDatabases = [ "grafana" ];
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${domain}" = {
|
||||
addSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
}
|
35
hosts/nuc/modules/prometheus/default.nix
Normal file
35
hosts/nuc/modules/prometheus/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ config, ... }:
|
||||
let
|
||||
exportersConfig = config.services.prometheus.exporters;
|
||||
in
|
||||
{
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
enabledCollectors = [ "systemd" ];
|
||||
};
|
||||
postgres.enable = true;
|
||||
};
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:${toString exportersConfig.node.port}" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "postgres";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:${toString exportersConfig.postgres.port}" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{ config, ... }:
|
||||
let
|
||||
domain = "monitoring.${config.networking.domain}";
|
||||
domain = "uptime.${config.networking.domain}";
|
||||
in
|
||||
{
|
||||
services.uptime-kuma = {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
services.borgmatic = {
|
||||
enable = true;
|
||||
settings = {
|
||||
location = { };
|
||||
source_directories = [
|
||||
"/var/lib"
|
||||
"/var/log"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue