From 5889b175df3d9fb53901fdf3899afd08123e8a08 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Tue, 29 Oct 2024 00:51:16 +0530 Subject: [PATCH] rico1: use redis for blocky --- hosts/rico1/services/apps/prometheus.nix | 8 ++++++++ hosts/rico1/services/apps/redis.nix | 23 ++++++++++++++++------- hosts/shared/blocky.nix | 3 +++ hosts/shared/prometheus-exporters.nix | 6 ++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/hosts/rico1/services/apps/prometheus.nix b/hosts/rico1/services/apps/prometheus.nix index 38541c5..abf4ff4 100644 --- a/hosts/rico1/services/apps/prometheus.nix +++ b/hosts/rico1/services/apps/prometheus.nix @@ -103,6 +103,14 @@ in { targets = [ "blocky.rico2.labs.adtya.xyz" ]; } ]; } + { + job_name = "redis"; + scheme = "https"; + metrics_path = "/redis-metrics"; + static_configs = [ + { targets = [ "rico1.labs.adtya.xyz" ]; } + ]; + } ]; }; }; diff --git a/hosts/rico1/services/apps/redis.nix b/hosts/rico1/services/apps/redis.nix index d33e268..206dfdf 100644 --- a/hosts/rico1/services/apps/redis.nix +++ b/hosts/rico1/services/apps/redis.nix @@ -1,12 +1,21 @@ _: { - services.redis.servers = { - blocky = { - bind = "10.10.10.11"; - port = 6379; + services = { + prometheus.exporters.redis = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9121; }; - caddy = { - bind = "10.10.10.11"; - port = 6380; + redis.servers = { + blocky = { + enable = true; + bind = "10.10.10.11"; + port = 6379; + }; + caddy = { + enable = true; + bind = "10.10.10.11"; + port = 6380; + }; }; }; } diff --git a/hosts/shared/blocky.nix b/hosts/shared/blocky.nix index 582c515..d08b897 100644 --- a/hosts/shared/blocky.nix +++ b/hosts/shared/blocky.nix @@ -115,6 +115,9 @@ enable = true; path = "/metrics"; }; + redis = { + address = "10.10.10.11:6379"; + }; log = { level = "warn"; format = "json"; diff --git a/hosts/shared/prometheus-exporters.nix b/hosts/shared/prometheus-exporters.nix index 42978c5..629d735 100644 --- a/hosts/shared/prometheus-exporters.nix +++ b/hosts/shared/prometheus-exporters.nix @@ -31,6 +31,12 @@ in reverse_proxy ${config.services.prometheus.exporters.postgres.listenAddress}:${toString config.services.prometheus.exporters.postgres.port} } ''} + ${lib.optionalString config.services.prometheus.exporters.redis.enable '' + handle /redis-metrics { + uri replace /redis-metrics /metrics + reverse_proxy ${config.services.prometheus.exporters.redis.listenAddress}:${toString config.services.prometheus.exporters.redis.port} + } + ''} ''; }; };