mirror of
https://github.com/Stunkymonkey/nixos.git
synced 2025-05-24 09:54:40 +02:00
service/prometheus: init
This commit is contained in:
parent
e4db4699fd
commit
caf9bce3b2
2 changed files with 89 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
||||||
./paperless
|
./paperless
|
||||||
./passworts
|
./passworts
|
||||||
./photoprism
|
./photoprism
|
||||||
|
./prometheus
|
||||||
./prowlarr
|
./prowlarr
|
||||||
./radarr
|
./radarr
|
||||||
./rss-bridge
|
./rss-bridge
|
||||||
|
|
88
modules/services/prometheus/default.nix
Normal file
88
modules/services/prometheus/default.nix
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
# monitoring system services
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.services.prometheus;
|
||||||
|
domain = config.networking.domain;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.services.prometheus = with lib; {
|
||||||
|
enable = mkEnableOption "Prometheus for monitoring";
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
default = 9090;
|
||||||
|
example = 3002;
|
||||||
|
description = "Internal port";
|
||||||
|
};
|
||||||
|
|
||||||
|
scrapeInterval = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "15s";
|
||||||
|
example = "1m";
|
||||||
|
description = "Scrape interval";
|
||||||
|
};
|
||||||
|
|
||||||
|
retentionTime = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "2y";
|
||||||
|
example = "1m";
|
||||||
|
description = "retention time";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
services.prometheus = {
|
||||||
|
enable = true;
|
||||||
|
inherit (cfg) port;
|
||||||
|
listenAddress = "127.0.0.1";
|
||||||
|
|
||||||
|
inherit (cfg) retentionTime;
|
||||||
|
|
||||||
|
exporters = {
|
||||||
|
node = {
|
||||||
|
enable = true;
|
||||||
|
enabledCollectors = [ "systemd" ];
|
||||||
|
port = 9100;
|
||||||
|
listenAddress = "127.0.0.1";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
globalConfig = {
|
||||||
|
scrape_interval = cfg.scrapeInterval;
|
||||||
|
};
|
||||||
|
|
||||||
|
scrapeConfigs = [
|
||||||
|
{
|
||||||
|
job_name = config.networking.hostName;
|
||||||
|
static_configs = [{
|
||||||
|
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.grafana.provision.dashboards.settings.providers = [
|
||||||
|
{
|
||||||
|
name = "Node Exporter";
|
||||||
|
options.path = pkgs.node-exporter-dashboard;
|
||||||
|
disableDeletion = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
my.services.nginx.virtualHosts = [
|
||||||
|
{
|
||||||
|
subdomain = "monitoring";
|
||||||
|
inherit (cfg) port;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
webapps.apps.prometheus = {
|
||||||
|
dashboard = {
|
||||||
|
name = "Monitoring";
|
||||||
|
category = "infra";
|
||||||
|
icon = "heart-pulse";
|
||||||
|
link = "https://monitoring.${domain}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue