dotfiles/nixos/services/prometheus.nix

36 lines
780 B
Nix
Raw Normal View History

2022-10-14 04:01:41 +00:00
{ config, pkgs, lib, ... }: {
options.metricsServer = lib.mkOption {
type = lib.types.str;
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"; }];
}];
}];
};
}