dotfiles/modules/nixos/services/prometheus.nix

36 lines
791 B
Nix
Raw Normal View History

2023-02-21 01:45:56 +00:00
{ config, lib, ... }: {
2022-10-14 04:01:41 +00:00
options.metricsServer = lib.mkOption {
2023-01-21 14:29:03 +00:00
type = lib.types.nullOr lib.types.str;
2022-10-14 04:01:41 +00:00
description = "Hostname of the Grafana server.";
2022-12-21 21:18:03 +00:00
default = null;
2022-10-14 04:01:41 +00:00
};
2022-12-21 21:38:34 +00:00
config = lib.mkIf (config.metricsServer != null) {
2022-10-14 04:01:41 +00:00
services.grafana.enable = true;
# Required to fix error in latest nixpkgs
services.grafana.settings = { };
2022-10-14 04:01:41 +00:00
services.prometheus = {
enable = true;
exporters.node.enable = true;
scrapeConfigs = [{
job_name = "local";
static_configs = [{ targets = [ "127.0.0.1:9100" ]; }];
}];
};
2022-12-21 21:18:03 +00:00
caddy.routes = [{
2022-10-14 04:01:41 +00:00
match = [{ host = [ config.metricsServer ]; }];
handle = [{
handler = "reverse_proxy";
upstreams = [{ dial = "localhost:3000"; }];
}];
}];
};
}