Compare commits

...

3 commits

Author SHA1 Message Date
290f541c5f loki/module.nix: init 2025-04-18 15:51:28 +02:00
1142f10c18 prometheus/module.nix: add nginx 2025-04-18 15:51:08 +02:00
9454d21bbd grafana: disable signup, add provisioning 2025-04-18 15:50:39 +02:00
3 changed files with 57 additions and 5 deletions

View file

@ -44,7 +44,28 @@ in {
check_for_updates = false;
};
# users.allow_signup = false;
users.allow_signup = false;
};
provision = {
enable = true;
datasources.settings = {
datasources = [
(mkIf config.modules.system.services.database.postgresql.enable {
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "http://127.0.0.1:4024";
isDefault = true;
})
(mkIf config.modules.system.services.prometheus.enable {
name = "PostgreSQL";
type = "postgres";
access = "proxy";
url = "http://127.0.0.1:${toString config.services.prometheus.port}";
})
];
};
};
};
services.nginx = {

View file

@ -0,0 +1,26 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.services.loki;
port = 4026;
dataDir = "/srv/data/loki";
in {
options.modules.system.services.loki.enable = mkEnableOption "Grafana, a graphing service";
config = mkIf cfg.enable {
services.loki = {
enable = true;
package = pkgs.loki;
configuration = {
};
};
};
}

View file

@ -13,10 +13,6 @@ in {
options.modules.system.services.prometheus.enable = mkEnableOption "Grafana, a graphing service";
config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [config.services.grafana.settings.server.http_port];
modules.system.services.database.postgresql.enable = true;
services.prometheus = {
enable = true;
package = pkgs.prometheus;
@ -34,6 +30,10 @@ in {
port = 4024;
user = "postgres";
};
nginx = {
enable = true;
port = 4025;
};
};
scrapeConfigs = [
{
@ -51,6 +51,11 @@ in {
scrape_interval = "30s";
static_configs = [{targets = ["localhost:${toString config.services.prometheus.exporters.postgres.port}"];}];
}
{
job_name = "nginx";
scrape_interval = "30s";
static_configs = [{targets = ["localhost:${toString config.services.prometheus.exporters.nginx.port}"];}];
}
];
};
};