prom: monitor nixos/nix nixos/nixpkgs projects on github
Eelco Dolstra committed
Dec 10, 2019 at 02:38 UTC
a85277055595e4088aa7b780cf08c9470208d360
2 files changed
+51
delft/eris.nix
+13
@@ -7,6 +7,7 @@ in {
7
imports = [
8
../modules/prometheus
9
./eris/packet-spot-market-prices.nix
10
+ ./eris/github-project-monitor.nix
11
./eris/alertmanager-irc-forwarder.nix
12
];
13
deployment.targetEnv = "hetzner";
@@ -318,6 +319,18 @@ in {
319
];
320
}
321
322
+ {
323
+ job_name = "prometheus-github-exporter";
324
+ metrics_path = "/";
325
+ static_configs = [
326
+ {
327
+ targets = [
328
+ "127.0.0.1:9401"
329
+ ];
330
+ }
331
+ ];
332
+ }
333
+
334
];
335
};
336
delft/eris/github-project-monitor.nix
new
+38
@@ -0,0 +1,38 @@
1
+{ config, pkgs, ... }:
2
+let
3
+ exporter = pkgs.fetchFromGitHub {
4
+ owner = "grahamc";
5
+ repo = "prometheus-github-exporter";
6
+ rev = "01b6f8ef06b694411baf10f49e7b05afb26ab307";
7
+ sha256 = "sha256-Sk/ynhPeXQVIgyZJ3Gj1VynJhPWmBHjrRnGYLjnJvio=";
8
+ };
9
+
10
+ config = pkgs.writeText "config.json" (builtins.toJSON {
11
+ port = 9401;
12
+ repos = [
13
+ "NixOS/nixpkgs"
14
+ "NixOS/nix"
15
+ ];
16
+ });
17
+in {
18
+ users.extraUsers.github-exporter = {
19
+ description = "Prometheus Github Exporter";
20
+ };
21
+
22
+ systemd.services.prometheus-github-exporter = {
23
+ wantedBy = [ "multi-user.target" ];
24
+ after = [ "network.target" ];
25
+ serviceConfig = {
26
+ User = "github-exporter";
27
+ Restart = "always";
28
+ RestartSec = "60s";
29
+ PrivateTmp = true;
30
+ };
31
+
32
+ path = [
33
+ (pkgs.python3.withPackages (p: [ p.prometheus_client p.requests ]))
34
+ ];
35
+
36
+ script = "exec python3 ${exporter}/scrape.py ${config}";
37
+ };
38
+}