diff --git a/nixos/modules/services/monitoring/netdata.nix b/nixos/modules/services/monitoring/netdata.nix index cbcfc2d008d55..01abc3807faf2 100644 --- a/nixos/modules/services/monitoring/netdata.nix +++ b/nixos/modules/services/monitoring/netdata.nix @@ -24,7 +24,7 @@ let mkdir $out ${lib.concatStringsSep "\n" (lib.mapAttrsToList (path: file: '' mkdir -p "$out/$(dirname ${path})" - ln -s "${file}" "$out/${path}" + ${if path == "apps_groups.conf" then "cp" else "ln -s"} "${file}" "$out/${path}" '') cfg.configDir)} ''; diff --git a/nixos/tests/netdata.nix b/nixos/tests/netdata.nix index df4d342905c68..0ae1f9c137fee 100644 --- a/nixos/tests/netdata.nix +++ b/nixos/tests/netdata.nix @@ -14,6 +14,10 @@ import ./make-test-python.nix ({ pkgs, ...} : { services.netdata = { enable = true; python.recommendedPythonPackages = true; + + configDir."apps_groups.conf" = pkgs.writeText "apps_groups.conf" '' + netdata_test: netdata + ''; }; }; }; @@ -33,12 +37,20 @@ import ./make-test-python.nix ({ pkgs, ...} : { # check if netdata can read disk ops for root owned processes. # if > 0, successful. verifies both netdata working and # apps.plugin has elevated capabilities. - url = "http://localhost:19999/api/v1/data\?chart=user.root_disk_physical_io" + url = "http://localhost:19999/api/v1/data?chart=user.root_disk_physical_io" filter = '[.data[range(10)][2]] | add | . < 0' cmd = f"curl -s {url} | jq -e '{filter}'" netdata.wait_until_succeeds(cmd) # check if the control socket is available netdata.succeed("sudo netdatacli ping") + + # check that custom groups in apps_groups.conf are used. + # if > 0, successful. verifies that user-specified apps_group.conf + # is used. + url = "http://localhost:19999/api/v1/data?chart=app.netdata_test_cpu_utilization" + filter = '[.data[range(10)][2]] | add | . > 0' + cmd = f"curl -s {url} | jq -e '{filter}'" + netdata.wait_until_succeeds(cmd, timeout=30) ''; })