mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-26 20:05:36 +00:00
36 lines
791 B
Nix
36 lines
791 B
Nix
{ config, lib, ... }: {
|
|
|
|
options.metricsServer = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
description = "Hostname of the Grafana server.";
|
|
default = null;
|
|
};
|
|
|
|
config = lib.mkIf (config.metricsServer != null) {
|
|
|
|
services.grafana.enable = true;
|
|
|
|
# Required to fix error in latest nixpkgs
|
|
services.grafana.settings = { };
|
|
|
|
services.prometheus = {
|
|
enable = true;
|
|
exporters.node.enable = true;
|
|
scrapeConfigs = [{
|
|
job_name = "local";
|
|
static_configs = [{ targets = [ "127.0.0.1:9100" ]; }];
|
|
}];
|
|
};
|
|
|
|
caddy.routes = [{
|
|
match = [{ host = [ config.metricsServer ]; }];
|
|
handle = [{
|
|
handler = "reverse_proxy";
|
|
upstreams = [{ dial = "localhost:3000"; }];
|
|
}];
|
|
}];
|
|
|
|
};
|
|
|
|
}
|