2024-09-09 00:22:14 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-13 01:50:53 +00:00
|
|
|
with lib; let
|
2024-09-09 00:22:14 +00:00
|
|
|
cfg = config.custom.services.netdata;
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
2024-09-09 00:22:14 +00:00
|
|
|
options.custom.services.netdata = {
|
2024-09-13 01:50:53 +00:00
|
|
|
enable = mkOption {default = false;};
|
|
|
|
parent = mkOption {default = false;};
|
|
|
|
child = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
|
2024-09-13 01:50:53 +00:00
|
|
|
config = let
|
|
|
|
role =
|
|
|
|
if cfg.parent
|
|
|
|
then "parent"
|
|
|
|
else if cfg.child
|
|
|
|
then "child"
|
|
|
|
else "";
|
|
|
|
in
|
2024-09-09 00:22:14 +00:00
|
|
|
mkIf cfg.enable {
|
|
|
|
# https://github.com/netdata/netdata
|
|
|
|
# https://wiki.nixos.org/wiki/Netdata
|
|
|
|
services.netdata = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# Override package to include v2 dashboard
|
|
|
|
# https://learn.netdata.cloud/docs/developer-and-contributor-corner/redistributed-software
|
2024-09-13 01:50:53 +00:00
|
|
|
package = mkIf cfg.parent pkgs.netdata.override {withCloudUi = true;}; # !! NCUL1 non-free license
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
# Minimize overhead for children
|
|
|
|
# https://learn.netdata.cloud/docs/netdata-agent/configuration/daemon-configuration
|
|
|
|
# https://learn.netdata.cloud/docs/netdata-agent/configuration/how-to-optimize-the-netdata-agent-s-performance
|
|
|
|
config = {
|
|
|
|
global."memory mode" = mkIf cfg.child "ram";
|
|
|
|
health.enabled = mkIf cfg.child "no";
|
|
|
|
ml.enabled = mkIf cfg.child "no";
|
|
|
|
|
|
|
|
web = {
|
|
|
|
mode = mkIf cfg.child "none";
|
|
|
|
"enable gzip compression" = "no";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-13 01:50:53 +00:00
|
|
|
configDir."stream.conf" =
|
|
|
|
mkIf (
|
|
|
|
role != ""
|
|
|
|
)
|
|
|
|
config.age.secrets."${config.custom.profile}/netdata/${role}.conf".path;
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
|
2024-09-13 01:50:53 +00:00
|
|
|
age.secrets = let
|
|
|
|
secret = filename: {
|
|
|
|
file = "${inputs.self}/secrets/${filename}";
|
|
|
|
owner = "netdata";
|
|
|
|
group = "netdata";
|
|
|
|
};
|
|
|
|
in
|
2024-09-09 00:22:14 +00:00
|
|
|
mkIf (role != "") {
|
|
|
|
"${config.custom.profile}/netdata/${role}.conf" = secret "${config.custom.profile}/netdata/${role}.conf";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|