From b1cff18da30978652b1b54c88330c099794430c3 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 7 Jan 2022 01:09:31 +0100 Subject: vidhar: loki: ... --- hosts/vidhar/default.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hosts/vidhar/default.nix b/hosts/vidhar/default.nix index 5665c419..9bc33077 100644 --- a/hosts/vidhar/default.nix +++ b/hosts/vidhar/default.nix @@ -178,6 +178,17 @@ }; }; }; + ruler = { + storage = { + type = "local"; + local.directory = "/etc/loki/rules"; + }; + remote_write = { + enabled = true; + client.url = "http://localhost:9090/api/v1/write"; + }; + ring.kvstore.store = "inmemory"; + }; schema_config.configs = [ { from = "2022-01-01"; store = "boltdb-shipper"; @@ -191,6 +202,20 @@ ]; }; }; + environment.etc."loki/rules/rules.yml".text = lib.generators.toYAML {} { + groups = [ + { name = "power-failures"; + rules = [ + { record = "apcupsd_power_failures:rate_1d"; + expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1d])) * 86400"; + } + { record = "apcupsd_power_failures:per_week"; + expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1w])) * 604800"; + } + ]; + }; + ]; + }; services.promtail = { enable = true; configuration = { -- cgit v1.2.3