From 4fb6c04299abb82b7a4d3f2f9fb62317800f896a Mon Sep 17 00:00:00 2001 From: James Walker Date: Mon, 10 May 2021 21:42:30 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8A=20prometheus=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hosts/aristotle/configuration.nix | 18 +++++++++++++- hosts/plato/configuration.nix | 39 +++++++++++++++++++++++++++++++ modules/coredns/default.nix | 1 + nix/sources.json | 6 ++--- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/hosts/aristotle/configuration.nix b/hosts/aristotle/configuration.nix index 53fc7bc..8a1b1d0 100644 --- a/hosts/aristotle/configuration.nix +++ b/hosts/aristotle/configuration.nix @@ -32,7 +32,23 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ0mE4MyMnfd1b2nlBJT7kpZ6Vov+ILuGNfzdp5ZBNQe walkah@walkah.net" ]; - services.tailscale.enable = true; + environment.systemPackages = with pkgs; [ libraspberrypi ]; + + services = { + prometheus = { + enable = true; + port = 9090; + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + openFirewall = true; + port = 9100; + }; + }; + }; + tailscale = { enable = true; }; + }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/hosts/plato/configuration.nix b/hosts/plato/configuration.nix index 89f2ce4..b6d315c 100644 --- a/hosts/plato/configuration.nix +++ b/hosts/plato/configuration.nix @@ -76,6 +76,45 @@ # Or disable the firewall altogether. networking.firewall.enable = false; + services = { + grafana = { + enable = true; + domain = "plato.walkah.lab"; + port = 2342; + addr = "0.0.0.0"; + }; + prometheus = { + enable = true; + port = 9090; + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 9100; + }; + }; + + scrapeConfigs = [ + { + job_name = "node"; + static_configs = [{ + targets = [ + "plato:9100" + "agent:9100" + "form:9100" + "matter:9100" + "purpose:9100" + ]; + }]; + } + { + job_name = "coredns"; + static_configs = [{ targets = [ "plato:9153" ]; }]; + } + ]; + }; + }; + # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave diff --git a/modules/coredns/default.nix b/modules/coredns/default.nix index f3f7599..13669b2 100644 --- a/modules/coredns/default.nix +++ b/modules/coredns/default.nix @@ -9,6 +9,7 @@ errors cache dnssec + prometheus 0.0.0.0:9153 forward . tls://1.1.1.1 tls://1.0.0.1 { tls_servername cloudflare-dns.com } diff --git a/nix/sources.json b/nix/sources.json index 414aa01..063e136 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -17,10 +17,10 @@ "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "55fafd9e23aa3e674a8db89013a004512ec5d2a9", - "sha256": "02vy0544zvh7j6azmg35az0za55m2pyczb2361w0awriz2ckbpav", + "rev": "1c16013bd6e94da748b41cc123c6b509a23eb440", + "sha256": "1m2wif0qnci0q14plbqlb95vx214pxqgw5li86lyw6hsiy7y3zfn", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/55fafd9e23aa3e674a8db89013a004512ec5d2a9.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/1c16013bd6e94da748b41cc123c6b509a23eb440.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } }