mirror of
https://github.com/Stunkymonkey/nixos.git
synced 2025-05-24 01:44:40 +02:00
service/node-exporter: seperate from prometheus
This commit is contained in:
parent
797261aad1
commit
21c5160a1d
3 changed files with 78 additions and 41 deletions
|
@ -24,6 +24,7 @@
|
||||||
./navidrome
|
./navidrome
|
||||||
./nextcloud
|
./nextcloud
|
||||||
./nginx
|
./nginx
|
||||||
|
./node-exporter
|
||||||
./octoprint
|
./octoprint
|
||||||
./paperless
|
./paperless
|
||||||
./passworts
|
./passworts
|
||||||
|
|
75
modules/services/node-exporter/default.nix
Normal file
75
modules/services/node-exporter/default.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# monitoring system services
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.services.node-exporter;
|
||||||
|
domain = config.networking.domain;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.services.node-exporter = with lib; {
|
||||||
|
enable = mkEnableOption "Node-Exporter for monitoring";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
services.prometheus = {
|
||||||
|
exporters = {
|
||||||
|
node = {
|
||||||
|
enable = true;
|
||||||
|
enabledCollectors = [ "systemd" ];
|
||||||
|
port = 9100;
|
||||||
|
listenAddress = "127.0.0.1";
|
||||||
|
};
|
||||||
|
systemd = {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = "127.0.0.1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = "node";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
|
||||||
|
labels = {
|
||||||
|
instance = config.networking.hostName;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
job_name = "systemd";
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ];
|
||||||
|
labels = {
|
||||||
|
instance = config.networking.hostName;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.grafana.provision = {
|
||||||
|
dashboards.settings.providers = [
|
||||||
|
{
|
||||||
|
name = "Node Exporter";
|
||||||
|
options.path = pkgs.grafana-dashboards.node-exporter;
|
||||||
|
disableDeletion = true;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "Systemd";
|
||||||
|
options.path = pkgs.grafana-dashboards.node-systemd;
|
||||||
|
disableDeletion = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
my.services.prometheus.rules = {
|
||||||
|
disk_will_fill_in_4_hours = {
|
||||||
|
condition = "predict_linear(node_filesystem_free[1h], 4 * 3600) < 0";
|
||||||
|
time = "5m";
|
||||||
|
description = "Disk would fill up in 4 hours. Please check the disk space";
|
||||||
|
labels = {
|
||||||
|
severity = "page";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -85,19 +85,6 @@ in
|
||||||
|
|
||||||
inherit (cfg) retentionTime;
|
inherit (cfg) retentionTime;
|
||||||
|
|
||||||
exporters = {
|
|
||||||
node = {
|
|
||||||
enable = true;
|
|
||||||
enabledCollectors = [ "systemd" ];
|
|
||||||
port = 9100;
|
|
||||||
listenAddress = "127.0.0.1";
|
|
||||||
};
|
|
||||||
systemd = {
|
|
||||||
enable = true;
|
|
||||||
listenAddress = "127.0.0.1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
globalConfig = {
|
globalConfig = {
|
||||||
scrape_interval = cfg.scrapeInterval;
|
scrape_interval = cfg.scrapeInterval;
|
||||||
};
|
};
|
||||||
|
@ -131,27 +118,11 @@ in
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
{
|
|
||||||
job_name = "node";
|
|
||||||
static_configs = [{
|
|
||||||
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
|
|
||||||
labels = {
|
|
||||||
instance = config.networking.hostName;
|
|
||||||
};
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
job_name = "systemd";
|
|
||||||
static_configs = [{
|
|
||||||
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ];
|
|
||||||
labels = {
|
|
||||||
instance = config.networking.hostName;
|
|
||||||
};
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my.services.node-exporter.enable = true;
|
||||||
|
|
||||||
services.grafana.provision = {
|
services.grafana.provision = {
|
||||||
datasources.settings.datasources = [
|
datasources.settings.datasources = [
|
||||||
{
|
{
|
||||||
|
@ -167,21 +138,11 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
dashboards.settings.providers = [
|
dashboards.settings.providers = [
|
||||||
{
|
|
||||||
name = "Node Exporter";
|
|
||||||
options.path = pkgs.grafana-dashboards.node-exporter;
|
|
||||||
disableDeletion = true;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
name = "Prometheus";
|
name = "Prometheus";
|
||||||
options.path = pkgs.grafana-dashboards.prometheus;
|
options.path = pkgs.grafana-dashboards.prometheus;
|
||||||
disableDeletion = true;
|
disableDeletion = true;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
name = "Systemd";
|
|
||||||
options.path = pkgs.grafana-dashboards.node-systemd;
|
|
||||||
disableDeletion = true;
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue