diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-01-07 12:37:37 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-01-07 12:37:37 +0100 |
commit | 6260246b4afdc5231a50209b048a92ba5b4028ea (patch) | |
tree | cd02112ba2e0429eeabb64eb7705ee639ae4242f /hosts/vidhar | |
parent | 790ddc1aba0a9e7ac75ddcc656df9c1dcd5a7f45 (diff) | |
download | nixos-6260246b4afdc5231a50209b048a92ba5b4028ea.tar nixos-6260246b4afdc5231a50209b048a92ba5b4028ea.tar.gz nixos-6260246b4afdc5231a50209b048a92ba5b4028ea.tar.bz2 nixos-6260246b4afdc5231a50209b048a92ba5b4028ea.tar.xz nixos-6260246b4afdc5231a50209b048a92ba5b4028ea.zip |
vidhar: ...
Diffstat (limited to 'hosts/vidhar')
-rw-r--r-- | hosts/vidhar/default.nix | 32 | ||||
-rw-r--r-- | hosts/vidhar/prometheus/default.nix | 2 |
2 files changed, 18 insertions, 16 deletions
diff --git a/hosts/vidhar/default.nix b/hosts/vidhar/default.nix index 2e2c9946..ad40b903 100644 --- a/hosts/vidhar/default.nix +++ b/hosts/vidhar/default.nix | |||
@@ -182,7 +182,7 @@ | |||
182 | enable_api = true; | 182 | enable_api = true; |
183 | storage = { | 183 | storage = { |
184 | type = "local"; | 184 | type = "local"; |
185 | local.directory = "/etc/loki/rules"; | 185 | local.directory = "${config.services.loki.dataDir}/rules"; |
186 | }; | 186 | }; |
187 | rule_path = "${config.services.loki.dataDir}/rules-temp"; | 187 | rule_path = "${config.services.loki.dataDir}/rules-temp"; |
188 | remote_write = { | 188 | remote_write = { |
@@ -204,20 +204,22 @@ | |||
204 | ]; | 204 | ]; |
205 | }; | 205 | }; |
206 | }; | 206 | }; |
207 | environment.etc."loki/rules/rules.yml".text = lib.generators.toYAML {} { | 207 | systemd.services.loki.preStart = let |
208 | groups = [ | 208 | rulesYaml = lib.generators.toYAML {} { |
209 | { name = "power-failures"; | 209 | groups = [ |
210 | rules = [ | 210 | { name = "power-failures"; |
211 | { record = "apcupsd_power_failures:rate_1d"; | 211 | rules = [ |
212 | expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1d])) * 86400"; | 212 | { record = "apcupsd_power_failures:rate_1d"; |
213 | } | 213 | expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1d])) * 86400"; |
214 | { record = "apcupsd_power_failures:per_week"; | 214 | } |
215 | expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1w])) * 604800"; | 215 | { record = "apcupsd_power_failures:per_week"; |
216 | } | 216 | expr = "sum by (nodename) (rate({job=\"systemd-journal\"} | json | MESSAGE = \"Power failure.\"[1w])) * 604800"; |
217 | ]; | 217 | } |
218 | } | 218 | ]; |
219 | ]; | 219 | } |
220 | }; | 220 | ]; |
221 | }; | ||
222 | in "${pkgs.coreutils}/bin/install -m 0644 -o ${config.services.loki.user} -m ${config.services.loki.group} --target-directory=${services.loki.configuration.ruler.storage.local.directory} ${pkgs.writeText "rules.yml" rulesYaml}"; | ||
221 | services.promtail = { | 223 | services.promtail = { |
222 | enable = true; | 224 | enable = true; |
223 | configuration = { | 225 | configuration = { |
diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix index f4e8d7e5..d443e991 100644 --- a/hosts/vidhar/prometheus/default.nix +++ b/hosts/vidhar/prometheus/default.nix | |||
@@ -221,7 +221,7 @@ in { | |||
221 | { record = "apcupsd_last_transfer_on_battery_counter_seconds:resets_per_day"; | 221 | { record = "apcupsd_last_transfer_on_battery_counter_seconds:resets_per_day"; |
222 | expr = "resets(apcupsd_last_transfer_on_battery_counter_seconds[1d])"; | 222 | expr = "resets(apcupsd_last_transfer_on_battery_counter_seconds[1d])"; |
223 | } | 223 | } |
224 | { record = "apcupsd_last_transfer_on_battery_counter_seconds:resets_per_wook"; | 224 | { record = "apcupsd_last_transfer_on_battery_counter_seconds:resets_per_week"; |
225 | expr = "resets(apcupsd_last_transfer_on_battery_counter_seconds[1w])"; | 225 | expr = "resets(apcupsd_last_transfer_on_battery_counter_seconds[1w])"; |
226 | } | 226 | } |
227 | ]; | 227 | ]; |