diff options
Diffstat (limited to 'hosts/vidhar/default.nix')
-rw-r--r-- | hosts/vidhar/default.nix | 32 |
1 files changed, 17 insertions, 15 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 = { |