summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorKFears <kfearsoff@gmail.com>2022-09-20 00:56:07 +0400
committerKFears <kfearsoff@gmail.com>2022-10-22 23:54:31 +0400
commit34c2ea6750b976ad85410ea3964184567aaecec0 (patch)
treed81f2523516073edfc01696a798a0e7c7a16c6d6 /nixos
parent0852dc859ea344d9e127c9160f0aec523218cfe5 (diff)
downloadnixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar.gz
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar.bz2
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar.lz
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar.xz
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.tar.zst
nixpkgs-34c2ea6750b976ad85410ea3964184567aaecec0.zip
nixos/grafana: deprecate notifiers
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/grafana.nix16
-rw-r--r--nixos/tests/grafana/default.nix1
-rw-r--r--nixos/tests/grafana/provision-notifiers.nix63
3 files changed, 78 insertions, 2 deletions
diff --git a/nixos/modules/services/monitoring/grafana.nix b/nixos/modules/services/monitoring/grafana.nix
index 2cea038b861..f8af84c4085 100644
--- a/nixos/modules/services/monitoring/grafana.nix
+++ b/nixos/modules/services/monitoring/grafana.nix
@@ -250,7 +250,13 @@ let
       secure_settings = mkOption {
         type = types.nullOr types.attrs;
         default = null;
-        description = lib.mdDoc "Secure settings for the notifier type.";
+        description = lib.mdDoc ''
+          Secure settings for the notifier type. Please note that the contents of this option
+          will end up in a world-readable Nix store. Use the file provider
+          pointing at a reasonably secured file in the local filesystem
+          to work around that. Look at the documentation for details:
+          <https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#file-provider>
+        '';
       };
     };
   };
@@ -775,7 +781,7 @@ in {
       ) "Datasource passwords will be stored as plaintext in the Nix store! Use file provider instead.")
       (optional (
         any (x: x.secure_settings != null) cfg.provision.notifiers
-      ) "Notifier secure settings will be stored as plaintext in the Nix store!")
+      ) "Notifier secure settings will be stored as plaintext in the Nix store! Use file provider instead.")
       (optional (
         builtins.isList cfg.provision.datasources
       ) ''
@@ -790,6 +796,12 @@ in {
           Use `services.grafana.provision.dashboards.settings` or
           `services.grafana.provision.dashboards.path` instead.
         '')
+      (optional (
+        cfg.provision.notifiers != []
+        ) ''
+            Notifiers are deprecated upstream and will be removed in Grafana 10.
+            Use `services.grafana.provision.alerting.contactPoints` instead.
+        '')
     ];
 
     environment.systemPackages = [ cfg.package ];
diff --git a/nixos/tests/grafana/default.nix b/nixos/tests/grafana/default.nix
index 011600b0103..9b299cc6aa5 100644
--- a/nixos/tests/grafana/default.nix
+++ b/nixos/tests/grafana/default.nix
@@ -7,4 +7,5 @@
   basic = import ./basic.nix { inherit system pkgs; };
   provision-datasources = import ./provision-datasources { inherit system pkgs; };
   provision-dashboards = import ./provision-dashboards { inherit system pkgs; };
+  provision-notifiers = import ./provision-notifiers.nix { inherit system pkgs; };
 }
diff --git a/nixos/tests/grafana/provision-notifiers.nix b/nixos/tests/grafana/provision-notifiers.nix
new file mode 100644
index 00000000000..2419a458c00
--- /dev/null
+++ b/nixos/tests/grafana/provision-notifiers.nix
@@ -0,0 +1,63 @@
+args@{ pkgs, ... }:
+
+(import ../make-test-python.nix ({ lib, pkgs, ... }:
+
+let
+  inherit (lib) mkMerge nameValuePair maintainers;
+
+  baseGrafanaConf = {
+    services.grafana = {
+      enable = true;
+      addr = "localhost";
+      analytics.reporting.enable = false;
+      domain = "localhost";
+      security = {
+        adminUser = "testadmin";
+        adminPassword = "snakeoilpwd";
+      };
+      provision.enable = true;
+    };
+  };
+
+  extraNodeConfs = {
+    provisionNotifiers = {
+      services.grafana.provision = {
+        notifiers = [{
+          uid = "test_notifiers";
+          name = "Test Notifiers";
+          type = "email";
+          settings = {
+            singleEmail = true;
+            addresses = "test@test.com";
+          };
+        }];
+      };
+    };
+  };
+
+  nodes = builtins.listToAttrs (map (provisionType:
+    nameValuePair provisionType (mkMerge [
+    baseGrafanaConf
+    (extraNodeConfs.${provisionType} or {})
+  ])) [ "provisionNotifiers" ]);
+
+in {
+  name = "grafana-provision-notifiers";
+
+  meta = with maintainers; {
+    maintainers = [ kfears willibutz ];
+  };
+
+  inherit nodes;
+
+  testScript = ''
+    start_all()
+    with subtest("Successful notifiers provision with Nix"):
+        provisionNotifiers.wait_for_unit("grafana.service")
+        provisionNotifiers.wait_for_open_port(3000)
+        provisionNotifiers.succeed(
+            "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/alert-notifications/uid/test_notifiers | grep Test\ Notifiers"
+        )
+        provisionNotifiers.shutdown()
+  '';
+})) args