diff options
author | Azat Bahawi <azat@bahawi.net> | 2024-03-10 15:24:58 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2024-03-10 15:24:58 +0300 |
commit | afa03e6f6ea66f5568805ebd73b8c38f008c3c8b (patch) | |
tree | 271471cb94b9cce6968492ac64e0c7f02ddda5ae /modules/nixos/monitoring/default.nix | |
parent | 2024-03-08 (diff) |
2024-03-10
Diffstat (limited to '')
-rw-r--r-- | modules/nixos/monitoring/default.nix | 36 |
1 files changed, 24 insertions, 12 deletions
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 |