From afa03e6f6ea66f5568805ebd73b8c38f008c3c8b Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 10 Mar 2024 15:24:58 +0300 Subject: 2024-03-10 --- modules/nixos/monitoring/default.nix | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'modules/nixos/monitoring') diff --git a/modules/nixos/monitoring/default.nix b/modules/nixos/monitoring/default.nix index fbc0e60..5aed215 100644 --- a/modules/nixos/monitoring/default.nix +++ b/modules/nixos/monitoring/default.nix @@ -32,27 +32,27 @@ in { # https://grafana.com/docs/grafana/latest/administration/provisioning/#data-sources datasources.settings.datasources = with config.nixfiles.modules; [ - { + (mkIf alertmanager.enable { name = "Alertmanager"; type = "alertmanager"; access = "proxy"; - jsonData.implementation = "prometheus"; url = "https://${alertmanager.domain}"; - } - { + jsonData.implementation = "prometheus"; + }) + (mkIf loki.enable { name = "Loki"; type = "loki"; access = "proxy"; url = "https://${loki.domain}"; isDefault = true; - } - { + }) + (mkIf prometheus.enable { name = "Prometheus"; type = "prometheus"; access = "proxy"; url = "https://${prometheus.domain}"; - } - (mkIf config.nixfiles.modules.redis.enable { + }) + (mkIf redis.enable { name = "Redis"; type = "redis-datasource"; access = "proxy"; @@ -60,11 +60,23 @@ in { jsonData.client = "standalone"; }) ]; - datasources.settings.deleteDatasources = [ - { - name = "PostgreSQL"; + datasources.settings.deleteDatasources = with config.nixfiles.modules; [ + (mkIf (!alertmanager.enable) { + name = "Alertmanager"; orgId = 1; - } + }) + (mkIf (!loki.enable) { + name = "Loki"; + orgId = 1; + }) + (mkIf (!prometheus.enable) { + name = "Prometheus"; + orgId = 1; + }) + (mkIf (!redis.enable) { + name = "Redis"; + orgId = 1; + }) ]; # https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards -- cgit 1.4.1