treewide: monitoring init
This commit is contained in:
parent
26206aabc2
commit
6424f8e7b1
4 changed files with 70 additions and 0 deletions
|
@ -22,5 +22,7 @@
|
||||||
|
|
||||||
networking.domain = "hijiri";
|
networking.domain = "hijiri";
|
||||||
networking.hostName = "vm";
|
networking.hostName = "vm";
|
||||||
|
|
||||||
|
services.prometheus.exporters.node.enable = lib.mkForce false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
./ntfy.nix
|
./ntfy.nix
|
||||||
./zitadel.nix
|
./zitadel.nix
|
||||||
./forgejo.nix
|
./forgejo.nix
|
||||||
|
./prometheus.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.hostPlatform = "aarch64-linux";
|
nixpkgs.hostPlatform = "aarch64-linux";
|
||||||
|
|
62
hosts/kazuki/prometheus.nix
Normal file
62
hosts/kazuki/prometheus.nix
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
age.secrets.rab-lol-cf = {
|
||||||
|
file = ../../secrets/rab-lol-cf.age;
|
||||||
|
owner = config.services.nginx.user;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.prometheus = {
|
||||||
|
enable = true;
|
||||||
|
scrapeConfigs =
|
||||||
|
let
|
||||||
|
nodeExporter = nixos: nixos.config.services.prometheus.exporters.node;
|
||||||
|
configurations = lib.filterAttrs (
|
||||||
|
_: nixos: (nodeExporter nixos).enable
|
||||||
|
) inputs.settei.nixosConfigurations;
|
||||||
|
in
|
||||||
|
lib.mapAttrsToList (name: nixos: {
|
||||||
|
job_name = "${name}-node";
|
||||||
|
static_configs = [ { targets = [ "${name}:${toString (nodeExporter nixos).port}" ]; } ];
|
||||||
|
}) configurations;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.grafana = {
|
||||||
|
enable = true;
|
||||||
|
settings.server.http_port = 3030;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
recommendedProxySettings = true;
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedTlsSettings = true;
|
||||||
|
virtualHosts."monitor.rab.lol" = {
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
acmeRoot = null;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://grafana";
|
||||||
|
proxyWebsockets = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
upstreams.grafana.servers =
|
||||||
|
let
|
||||||
|
inherit (config.services.grafana.settings.server) http_addr http_port;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"${http_addr}:${toString http_port}" = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
security.acme.certs."monitor.rab.lol" = {
|
||||||
|
dnsProvider = "cloudflare";
|
||||||
|
credentialsFile = config.age.secrets.rab-lol-cf.path;
|
||||||
|
};
|
||||||
|
}
|
|
@ -52,6 +52,11 @@ let
|
||||||
settei.user.config = {
|
settei.user.config = {
|
||||||
services.ssh-agent.enable = true;
|
services.ssh-agent.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.prometheus.exporters.node = {
|
||||||
|
enable = true;
|
||||||
|
enabledCollectors = [ "systemd" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
darwinConfig = lib.optionalAttrs (!isLinux) {
|
darwinConfig = lib.optionalAttrs (!isLinux) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue