add NixOS/nixos-metrics metrics via VictoriaMetrics
Taeer Bar-Yam committed
Nov 17, 2022 at 09:31 UTC
2d2426f29ae99e4a4ab031b3ca84f45361e4100c
1 file changed
+22
delft/eris.nix
+22
@@ -590,6 +590,28 @@ in
590
(import ../channels.nix).channels;
591
};
592
593
+ # pull nixos metrics from github:NixOS/nixos-metrics to local VictoriaMetrics
594
+ # every day at 09.00
595
+ services.cron = {
596
+ enable = true;
597
+ systemCronJobs = let
598
+ inherit (config.services.victoriametrics) listenAddress;
599
+ importURL = "http://localhost:${listenAddress}/api/v1/import";
600
+ resetURL = "http://localhost:${listenAddress}/internal/resetRollupResultCache";
601
+ dataURL = "https://raw.githubusercontent.com/NixOS/nixos-metrics/data/victoriametrics.jsonl";
602
+ pull-mterics = pkgs.writeShellScript "pull-metrics.sh" ''
603
+ curl -X POST ${importURL} -T <(curl ${dataURL})
604
+ curl -G ${resetURL}
605
+ '';
606
+ in
607
+ [ "0 9 * * * root ${pull-metrics}" ];
608
+ };
609
+
610
+ services.victoriametrics = {
611
+ enable = true;
612
+ retentionPeriod = 1200; # 100 years
613
+ };
614
+
615
services.grafana = {
616
enable = true;
617
auth.anonymous.enable = true;