From a33c46e4f5678a3bf57c1cf0c45f28eb8484d0da Mon Sep 17 00:00:00 2001 From: oddlama Date: Fri, 12 Jul 2024 15:39:18 +0200 Subject: [PATCH] chore: prepare monitoring config via globals --- hosts/sire/guests/influxdb.nix | 11 +++++++++++ modules/globals.nix | 10 +++++++--- nix/globals.nix | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hosts/sire/guests/influxdb.nix b/hosts/sire/guests/influxdb.nix index e97ac5f..95d462e 100644 --- a/hosts/sire/guests/influxdb.nix +++ b/hosts/sire/guests/influxdb.nix @@ -29,6 +29,17 @@ in { meta.telegraf.secrets."@GITHUB_ACCESS_TOKEN@" = config.age.secrets.github-access-token.path; services.telegraf.extraConfig.outputs.influxdb_v2.urls = lib.mkForce ["http://localhost:${toString influxdbPort}"]; + + globals.monitoring.ping.cloudflare-dns = { + host = "1.1.1.1"; + location = "external"; + }; + + globals.monitoring.ping.google-dns = { + host = "8.8.8.8"; + location = "external"; + }; + services.telegraf.extraConfig.inputs = { ping = [ { diff --git a/modules/globals.nix b/modules/globals.nix index 9efe88c..ad45d17 100644 --- a/modules/globals.nix +++ b/modules/globals.nix @@ -98,10 +98,14 @@ in { ping = mkOption { type = types.attrsOf (types.submodule { options = { - fromNetwork = mkOption { + host = mkOption { type = types.str; - description = "The network from which this service is reachable."; - default = "external"; + description = "The IP/hostname to ping."; + }; + + location = mkOption { + type = types.str; + description = "A location tag added to this metric."; }; }; }); diff --git a/nix/globals.nix b/nix/globals.nix index 0e7243e..30c59cb 100644 --- a/nix/globals.nix +++ b/nix/globals.nix @@ -26,7 +26,7 @@ in { # Make sure the keys of this attrset are trivially evaluatable to avoid infinite recursion, # therefore we inherit relevant attributes from the config. - inherit (globalsSystem.config.globals) net services; + inherit (globalsSystem.config.globals) net services monitoring; }; }; }