This commit is contained in:
Sandro - 2022-12-19 23:36:57 +01:00
parent 86f2edb5dd
commit 003e37582c
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -7,33 +7,30 @@
isInHq = false;
};
networking.hostName = "grafana";
environment.systemPackages = with pkgs; [ influxdb ];
networking = {
firewall = {
# http https influxdb
networking.firewall.allowedTCPPorts = [ 80 443 8086 ];
allowedTCPPorts = [ 80 443 8086 ];
# collectd
networking.firewall.allowedUDPPorts = [ 25826 ];
allowedUDPPorts = [ 25826 ];
};
hostName = "grafana";
};
services.nginx = {
enable = true;
virtualHosts = {
"grafana.hq.c3d2.de" = {
default = true;
enableACME = true;
forceSSL = true;
locations = { "/".proxyPass = "http://localhost:3000/"; };
};
};
};
services.grafana = {
services = {
grafana = {
enable = true;
provision = {
enable = true;
# curl https://root:SECRET@grafana.hq.c3d2.de/api/datasources | jq > hosts/grafana/datasources.json
datasources.settings.datasources = map (datasource: {
datasources.settings.datasources = map
(datasource: {
inherit (datasource) name type access orgId url password user database isDefault jsonData;
}) (with builtins; fromJSON (readFile ./datasources.json));
})
(with builtins; fromJSON (readFile ./datasources.json));
dashboards.settings.providers = [{
settings = {
apiVersion = 1;
@ -59,13 +56,15 @@
users.allow_sign_up = false;
};
};
services.influxdb = let
influxdb =
let
collectdTypes = pkgs.runCommand "collectd-types" { } ''
mkdir -p $out/share/collectd
cat ${pkgs.collectd-data}/share/collectd/types.db >> $out/share/collectd/types.db
echo "stations value:GAUGE:0:U" >> $out/share/collectd/types.db
'';
in {
in
{
enable = true;
extraConfig = {
logging.level = "debug";
@ -78,22 +77,18 @@
}];
};
};
systemd.services =
builtins.foldl' (services: service:
services // {
"${service}".serviceConfig = {
RestartSec = 60;
Restart = "always";
nginx = {
enable = true;
virtualHosts = {
"grafana.hq.c3d2.de" = {
default = true;
enableACME = true;
forceSSL = true;
locations = { "/".proxyPass = "http://localhost:3000/"; };
};
};
};
}
) {} [ "grafana" "influxdb" ]
// {
# work around our slow storage that can't keep up
influxdb.serviceConfig.LimitNOFILE = "1048576:1048576";
influxdb.serviceConfig.TimeoutStartSec = "infinity";
};
environment.systemPackages = with pkgs; [ influxdb ];
sops = {
defaultSopsFile = ./secrets.yaml;
@ -109,5 +104,22 @@
};
};
systemd.services =
builtins.foldl'
(services: service:
services // {
"${service}".serviceConfig = {
RestartSec = 60;
Restart = "always";
};
}
)
{ } [ "grafana" "influxdb" ]
// {
# work around our slow storage that can't keep up
influxdb.serviceConfig.LimitNOFILE = "1048576:1048576";
influxdb.serviceConfig.TimeoutStartSec = "infinity";
};
system.stateVersion = "22.05";
}