feat(server/grafana): add grafana module and enable it on apollo
This commit is contained in:
parent
a668db89b3
commit
d9f2603f4b
2 changed files with 34 additions and 0 deletions
30
modules/nixos/server/monitoring/grafana/default.nix
Normal file
30
modules/nixos/server/monitoring/grafana/default.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) singleton mkEnableOption mkIf;
|
||||
inherit (lib.pantheon) mkRootDomain mkPortOption mkStrOption;
|
||||
cfg = config.server.monitoring.grafana;
|
||||
in
|
||||
{
|
||||
options.server.monitoring.grafana = {
|
||||
enable = mkEnableOption "";
|
||||
url = mkStrOption;
|
||||
port = mkPortOption 3000;
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
server.networking.ddns.domains = singleton (mkRootDomain cfg.url);
|
||||
server.web-servers.nginx.proxies = mkIf config.server.web-servers.nginx.enable (singleton {
|
||||
source = cfg.url;
|
||||
target = "http://${config.system.hostname}:${builtins.toString cfg.port}";
|
||||
extraConfig.proxyWebsockets = true;
|
||||
});
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings.server = {
|
||||
domain = cfg.url;
|
||||
http_port = cfg.port;
|
||||
http_addr = "0.0.0.0";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -20,6 +20,10 @@
|
|||
};
|
||||
|
||||
server = {
|
||||
monitoring.grafana = {
|
||||
enable = true;
|
||||
url = "grafana.bwfiq.com";
|
||||
};
|
||||
networking.ddns = {
|
||||
enable = true;
|
||||
domains = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue