Initial grafana setup

This commit is contained in:
daragh 2024-05-21 02:23:10 +01:00
parent da721924e4
commit 519e907278
No known key found for this signature in database
3 changed files with 84 additions and 0 deletions

63
applications/grafana.nix Normal file
View file

@ -0,0 +1,63 @@
{lib, ...}:
with lib; let
name = "grafana-server";
cfg = config.server.grafana;
in {
imports = [
./acme.nix
./dns.nix
];
options.services.skynet.grafana = {
enable = mkEnableOption "Grafana Server";
host = {
ip = mkOption {
type = types.str;
};
name = mkOption {
type = types.str;
};
};
ip = mkOption {
type = types.str;
default = cfg.host.ip;
};
port = mkOption {
type = types.port;
default = 4444;
};
};
config = {
services.grafana = {
enable = true;
domain = "grafana.skynet.ie";
port = cfg.port;
addr = cfg.host.ip;
};
services.nginx.virtualHosts."${name}.skynet.ie" = {
forceSSL = true;
useACMEHost = "skynet";
locations."/" = {
proxyPass = "https://localhost:${toString cfg.port}";
proxyWebsockets = true;
};
};
skynet_dns.records = [
{
record = "${name}";
r_type = "CNAME";
value = cfg.host.name;
}
];
skynet_acme.domains = [
"${name}.skynet.ie"
];
};
}

View file

@ -116,6 +116,17 @@ in {
]; ];
}; };
services.prometheus = {
exporters = {
node = {
enable = true;
# most of the collectors should be on by default
enabledCollectors = ["systemd"];
port = 9002;
};
};
};
# time on vendetta is strangely out of sync # time on vendetta is strangely out of sync
networking.timeServers = options.networking.timeServers.default ++ ["ie.pool.ntp.org"]; networking.timeServers = options.networking.timeServers.default ++ ["ie.pool.ntp.org"];
services.ntp.enable = true; services.ntp.enable = true;

View file

@ -25,6 +25,7 @@ Notes:
groups_trusted = map (x: "@${x}") groups; groups_trusted = map (x: "@${x}") groups;
in { in {
imports = [ imports = [
../applications/grafana.nix
]; ];
deployment = { deployment = {
@ -49,6 +50,15 @@ in {
sudo_groups = groups; sudo_groups = groups;
}; };
services.skynet.grafana = {
enable = true;
host = {
ip = ip_pub;
name = name;
};
};
skynet_dns.records = [ skynet_dns.records = [
{ {
record = name; record = name;