Skip to content

Commit

Permalink
monitoring: separate exporters
Browse files Browse the repository at this point in the history
Signed-off-by: lucasew <lucas59356@gmail.com>
  • Loading branch information
lucasew committed Jan 3, 2025
1 parent 8c35424 commit b30d818
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 78 deletions.
77 changes: 0 additions & 77 deletions nix/nodes/whiterun/dashboards.nix

This file was deleted.

2 changes: 1 addition & 1 deletion nix/nodes/whiterun/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ in
imports = [
./hardware-configuration.nix
../gui-common
./monitoring

"${self.inputs.nixos-hardware}/common/cpu/amd/pstate.nix"
"${self.inputs.nixos-hardware}/common/gpu/amd"
"${self.inputs.nixos-hardware}/common/pc/ssd"
./nvidia.nix

./dashboards.nix
./dlna.nix
./nextcloud.nix
./sshfs.nix
Expand Down
44 changes: 44 additions & 0 deletions nix/nodes/whiterun/monitoring/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
config,
...
}:
{

imports = [
./nginx.nix
./node-exporter.nix
./zfs.nix
./postgres.nix
./nvidia.nix
];

networking.ports.grafana-web.enable = true;
# networking.ports.grafana-web.port = lib.mkDefault 49150;
services.grafana = {
enable = true;
settings.server = {
domain = "grafana.${config.services.ts-proxy.network-domain}";
http_port = config.networking.ports.grafana-web.port;
http_addr = "127.0.0.1";
};
};

services.ts-proxy.hosts = {
grafana = {
address = "127.0.0.1:${toString config.services.grafana.settings.server.http_port}";
enableTLS = true;
};
prometheus = {
address = "127.0.0.1:${toString config.services.prometheus.port}";
enableTLS = true;
};
};

networking.ports.prometheus.enable = true;
services.prometheus = {
enable = true;
inherit (config.networking.ports.prometheus) port;

webExternalUrl = "http://prometheus.${config.services.ts-proxy.network-domain}";
};
}
27 changes: 27 additions & 0 deletions nix/nodes/whiterun/monitoring/nginx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ config, ... }:

{
networking.ports.prometheus-exporter-nginx.enable = true;
services.nginx.statusPage = true;

services.prometheus = {
exporters.nginx = {
enable = true;
sslVerify = true; # internal net doesn't use ssl
inherit (config.networking.ports.prometheus-exporter-nginx) port;
};

scrapeConfigs = [
{
job_name = "nginx";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.networking.ports.prometheus-exporter-nginx.port}"
];
}
];
}
];
};
}
30 changes: 30 additions & 0 deletions nix/nodes/whiterun/monitoring/node-exporter.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ config, ... }:

{
networking.ports.prometheus-exporter-node_exporter.enable = true;

services.prometheus = {
exporters.node = {
enable = true;
inherit (config.networking.ports.prometheus-exporter-node_exporter) port;
enabledCollectors = [
"logind"
"systemd"
];
};

scrapeConfigs = [
{
job_name = "node_exporter";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.networking.ports.prometheus-exporter-node_exporter.port}"
];
}
];
}
];
};

}
34 changes: 34 additions & 0 deletions nix/nodes/whiterun/monitoring/nvidia.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


{ config, lib, pkgs, ... }:

{
networking.ports.prometheus-exporter-nvidia.enable = true;

systemd.services.prometheus-nvidia-exporter = {
script = ''
exec ${lib.getExe pkgs.unstable.prometheus-nvidia-gpu-exporter} \
--web.listen-address 127.0.0.1:${toString config.networking.ports.prometheus-exporter-nvidia.port} \
--nvidia-smi-command /run/current-system/sw/bin/nvidia-smi
'';
serviceConfig = {
PrivateDevices = false;
};
wantedBy = [ "multi-user.target" ];
};

services.prometheus = {
scrapeConfigs = [
{
job_name = "nvidia";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.networking.ports.prometheus-exporter-nvidia.port}"
];
}
];
}
];
};
}
27 changes: 27 additions & 0 deletions nix/nodes/whiterun/monitoring/postgres.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

{ config, ... }:

{
networking.ports.prometheus-exporter-postgres.enable = true;

services.prometheus = {
exporters.postgres = {
enable = true;
runAsLocalSuperUser = true;
inherit (config.networking.ports.prometheus-exporter-postgres) port;
};

scrapeConfigs = [
{
job_name = "postgres";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.networking.ports.prometheus-exporter-postgres.port}"
];
}
];
}
];
};
}
24 changes: 24 additions & 0 deletions nix/nodes/whiterun/monitoring/zfs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ config, ... }:

{
networking.ports.prometheus-exporter-zfs.enable = true;

services.prometheus = {
exporters.zfs = {
enable = true;
inherit (config.networking.ports.prometheus-exporter-zfs) port;
};
scrapeConfigs = [
{
job_name = "zfs";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.networking.ports.prometheus-exporter-zfs.port}"
];
}
];
}
];
};
}

0 comments on commit b30d818

Please sign in to comment.