parent
80c49ec8a5
commit
250eea0c18
7 changed files with 15420 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
|||
./http
|
||||
./search
|
||||
./security
|
||||
./monitoring
|
||||
];
|
||||
system.stateVersion = "25.05";
|
||||
}
|
||||
|
|
|
|||
15275
config/monitoring/dashboards/node_exporter_full.json
Normal file
15275
config/monitoring/dashboards/node_exporter_full.json
Normal file
File diff suppressed because it is too large
Load diff
6
config/monitoring/default.nix
Normal file
6
config/monitoring/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./grafana.nix
|
||||
./prometheus.nix
|
||||
];
|
||||
}
|
||||
93
config/monitoring/grafana.nix
Normal file
93
config/monitoring/grafana.nix
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
{config, ...}: let
|
||||
cfg = config.services.grafana;
|
||||
owner = config.customOps.owner;
|
||||
domain = config.customOps.domain.fqdn;
|
||||
hostname = config.networking.hostName;
|
||||
subdomain = "${hostname}.${domain}";
|
||||
|
||||
dashboardsDir = ./dashboards;
|
||||
dashboardFiles = builtins.attrNames (builtins.readDir dashboardsDir);
|
||||
in {
|
||||
sops.secrets."grafana/admin_password".owner = "grafana";
|
||||
|
||||
services.nginx.virtualHosts."${subdomain}" = {
|
||||
locations."/" = {
|
||||
proxyPass = "http://${
|
||||
toString cfg.settings.server.http_addr
|
||||
}:${
|
||||
toString cfg.settings.server.http_port
|
||||
}";
|
||||
proxyWebsockets = true;
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
};
|
||||
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
http_addr = "127.0.0.1";
|
||||
http_port = 3030;
|
||||
domain = subdomain;
|
||||
enforce_domain = true;
|
||||
enable_gzip = true;
|
||||
};
|
||||
security = {
|
||||
disable_initial_admin_creation = false;
|
||||
admin_user = owner;
|
||||
admin_email = "admin.grafana@${domain}";
|
||||
admin_password = "$__file{${
|
||||
config.sops.secrets."grafana/admin_password".path
|
||||
}}";
|
||||
disable_brute_force_login_protection = false;
|
||||
brute_force_login_protection_max_attempts = 3;
|
||||
disable_username_login_protection = false;
|
||||
disable_ip_address_login_protection = false;
|
||||
cookie_secure = true;
|
||||
cookie_samesite = "strict";
|
||||
};
|
||||
analytics = {
|
||||
reporting_enabled = false;
|
||||
check_for_updates = false;
|
||||
};
|
||||
};
|
||||
|
||||
provision = {
|
||||
enable = true;
|
||||
dashboards.settings.providers = [
|
||||
{
|
||||
name = "dashboards";
|
||||
disableDeletion = true;
|
||||
options = {
|
||||
path = "/etc/grafana-dashboards";
|
||||
foldersFromFilesStructure = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
datasources.settings.datasources = [
|
||||
{
|
||||
name = "prometheus";
|
||||
type = "prometheus";
|
||||
url = "http://${
|
||||
config.services.prometheus.listenAddress
|
||||
}:${
|
||||
toString config.services.prometheus.port
|
||||
}";
|
||||
isDefault = true;
|
||||
editable = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc = builtins.listToAttrs (map (
|
||||
name: {
|
||||
name = "grafana-dashboards/" + name;
|
||||
value = {source = dashboardsDir + "/" + name;};
|
||||
}
|
||||
)
|
||||
dashboardFiles);
|
||||
}
|
||||
40
config/monitoring/prometheus.nix
Normal file
40
config/monitoring/prometheus.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{config, ...}: {
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
port = 9100;
|
||||
globalConfig.scrape_interval = "1m";
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [
|
||||
"localhost:${
|
||||
toString
|
||||
config.services.prometheus.exporters.node.port
|
||||
}"
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
port = 9101;
|
||||
enabledCollectors = [
|
||||
"ethtool"
|
||||
"softirqs"
|
||||
"systemd"
|
||||
"tcpstat"
|
||||
"wifi"
|
||||
];
|
||||
extraFlags = [
|
||||
"--collector.ntp.protocol-version=4"
|
||||
"--no-collector.mdadm"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ in {
|
|||
MaxAdvertisedBandwidth = "100 MB";
|
||||
BandWidthRate = "100 MB";
|
||||
RelayBandwidthRate = "100 MB";
|
||||
RelayBandwidthBurst = "100 MB";
|
||||
|
||||
CookieAuthentication = true;
|
||||
AvoidDiskWrites = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue