Revert "Reuse prometheus-exporters from nixpkgs"
Graham Christensen committed
Dec 19, 2021 at 13:12 UTC
0e417ce9c9ef9939e2942f975cf4977668c28572
5 files changed
+97
-10
delft/eris.nix
+20
-10
@@ -560,14 +560,16 @@ in {
560
"f /var/lib/packet-sd/packet-sd.json 0644 packet-sd - -"
561
];
562
563
- systemd.services.prometheus-packet-sd = {
563
+ systemd.services.prometheus-packet-sd = let
564
+ sd = pkgs.callPackage ./prometheus/packet-sd.nix {};
565
+ in {
566
wantedBy = [ "multi-user.target" "prometheus.service" ];
567
after = [ "network.target" ];
568
569
serviceConfig = {
570
User = "packet-sd";
571
Group = "keys";
570
- ExecStart = "${pkgs.packet-sd}/bin/prometheus-packet-sd --output.file=/var/lib/packet-sd/packet-sd.json";
572
+ ExecStart = "${sd}/bin/prometheus-packet-sd --output.file=/var/lib/packet-sd/packet-sd.json";
573
EnvironmentFile = "/run/keys/packet-sd-env";
574
Restart = "always";
575
RestartSec = "60s";
@@ -578,14 +580,22 @@ in {
580
keyFile = /home/deploy/src/nixos-org-configurations/fastly-read-only-api-token;
581
};
582
581
- services.prometheus.exporters.fastly = {
582
- enable = true;
583
- listenAddress = "127.0.0.1";
584
- tokenPath = "/run/keys/fastly-read-only-api-token";
585
- };
583
+ systemd.services.prometheus-fastly-exporter = let
584
+ fastly = pkgs.callPackage ./prometheus/fastly.nix {};
585
+ in {
586
+ wantedBy = [ "multi-user.target" "prometheus.service" ];
587
+ after = [ "network.target" ];
588
+
589
+ script = ''
590
+ export FASTLY_API_TOKEN=$(cat /run/keys/fastly-read-only-api-token)
591
+ ${fastly}/bin/fastly-exporter \
592
+ -endpoint http://127.0.0.1:9118/metrics
593
+ '';
594
587
- systemd.services.prometheus-fastly-exporter.serviceConfig = {
588
- SupplementaryGroups = [ "keys" ];
589
- RestartSec = "60s";
595
+ serviceConfig = {
596
+ Group = "keys";
597
+ Restart = "always";
598
+ RestartSec = "60s";
599
+ };
600
};
601
}
delft/network.nix
+5
@@ -1,6 +1,10 @@
1
flakes:
2
3
let
4
+ networkoverlay = self: super: {
5
+ prometheus-postgres-exporter = self.callPackage ./prometheus/postgres-exporter.nix {};
6
+ };
7
+
8
makeMac = { ip, extra }: {
9
deployment = {
10
targetHost = ip;
@@ -49,6 +53,7 @@ in {
53
or (throw "Cannot deploy from an unclean source tree!");
54
nixpkgs.overlays = [
55
flakes.nix.overlay
56
+ networkoverlay
57
];
58
nix.registry.nixpkgs.flake = flakes.nixpkgs;
59
nix.nixPath = [ "nixpkgs=${flakes.nixpkgs}" ];
delft/prometheus/fastly.nix
new
+23
@@ -0,0 +1,23 @@
1
+{ lib, buildGoModule, fetchFromGitHub }:
2
+# Introduced in PR #133726 and should be removed when the network updates
3
+# to 21.11 or later.
4
+buildGoModule rec {
5
+ pname = "fastly-exporter";
6
+ version = "6.1.0";
7
+
8
+ src = fetchFromGitHub {
9
+ owner = "peterbourgon";
10
+ repo = pname;
11
+ rev = "v${version}";
12
+ sha256 = "0my0pcxix5rk73m5ciz513nwmjcm7vjs6r8wg3vddm0xixv7zq94";
13
+ };
14
+
15
+ vendorSha256 = "1w9asky8h8l5gc0c6cv89m38qw50hyhma8qbsw3zirplhk9mb3r2";
16
+
17
+ meta = with lib; {
18
+ description = "Prometheus exporter for the Fastly Real-time Analytics API";
19
+ homepage = "https://github.com/peterbourgon/fastly-exporter";
20
+ license = licenses.asl20;
21
+ maintainers = teams.deshaw.members;
22
+ };
23
+}
delft/prometheus/packet-sd.nix
new
+23
@@ -0,0 +1,23 @@
1
+{ buildGoModule, fetchFromGitHub, lib }:
2
+buildGoModule rec {
3
+ pname = "prometheus-packet-sd";
4
+ version = "v0.0.3";
5
+
6
+ src = fetchFromGitHub {
7
+ owner = "packethost";
8
+ repo = "prometheus-packet-sd";
9
+ rev = "v0.0.3";
10
+ sha256 = "sha256-2k8AsmyhQNNZCzpVt6JdgvI8IFb5pRi4ic6Yn2NqHMM=";
11
+ };
12
+
13
+ vendorSha256 = null;
14
+
15
+ subPackages = [ "." ];
16
+
17
+ meta = with lib; {
18
+ description = "Prometheus service discovery for Packet.";
19
+ homepage = "https://github.com/packethost/prometheus-packet-sd";
20
+ license = licenses.asl20;
21
+ platforms = platforms.linux;
22
+ };
23
+}
delft/prometheus/postgres-exporter.nix
new
+26
@@ -0,0 +1,26 @@
1
+{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
2
+
3
+buildGoModule rec {
4
+ pname = "postgres_exporter";
5
+ version = "0.9.0";
6
+
7
+ src = fetchFromGitHub {
8
+ owner = "wrouesnel";
9
+ repo = "postgres_exporter";
10
+ rev = "v${version}";
11
+ sha256 = "sha256-Kv+sjqhlmH36L4YvDuGYODR/eTHA2TKQ6IUCXAiItyo=";
12
+ };
13
+
14
+ vendorSha256 = "sha256-yMcoUl9NsiiZQyEHlLu79DzIyl6BbhLZ/xNFavaGrEs=";
15
+
16
+ doCheck = true;
17
+
18
+ passthru.tests = { inherit (nixosTests.prometheus-exporters) postgres; };
19
+
20
+ meta = with lib; {
21
+ inherit (src.meta) homepage;
22
+ description = "A Prometheus exporter for PostgreSQL";
23
+ license = licenses.asl20;
24
+ maintainers = with maintainers; [ fpletz globin willibutz ma27 ];
25
+ };
26
+}