main
nix 49 lines 1.2 KB
Raw
1 { lib, pkgs, ... }:
2
3 let
4 channels = pkgs.writeText "channels.json" (
5 builtins.toJSON (import ../../../../channels.nix).channels
6 );
7 in
8 {
9 systemd.services.channel-update-exporter = {
10 description = "Check all active channels' last-update times";
11 path = [
12 (pkgs.python3.withPackages (
13 pypkgs: with pypkgs; [
14 requests
15 prometheus-client
16 python-dateutil
17 ]
18 ))
19 ];
20 wantedBy = [ "multi-user.target" ];
21 serviceConfig = {
22 DynamicUser = true;
23 ExecStart = "${./channel-exporter.py} ${channels}";
24 };
25 };
26
27 services.prometheus.scrapeConfigs = [
28 {
29 job_name = "channel-updates";
30 metrics_path = "/";
31 static_configs = [ { targets = [ "127.0.0.1:9402" ]; } ];
32 }
33 ]
34 ++ lib.mapAttrsToList (name: value: {
35 job_name = "channel-job-${name}";
36 scheme = "https";
37 scrape_interval = "5m";
38 metrics_path = "/job/${value.job}/prometheus";
39 static_configs = [
40 {
41 labels = {
42 current = if value.status != "unmaintained" then "1" else "0";
43 channel = name;
44 };
45 targets = [ "hydra.nixos.org:443" ];
46 }
47 ];
48 }) (import ../../../../channels.nix).channels;
49 }