summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hosts/p-body/default.nix4
-rw-r--r--hosts/p-body/prometheus.nix13
-rw-r--r--hosts/p-body/promtail.nix37
-rw-r--r--hosts/profiles.nix9
-rw-r--r--modules/nixos/server/services/default.nix2
-rw-r--r--modules/nixos/server/services/loki.nix (renamed from hosts/p-body/loki.nix)22
-rw-r--r--modules/nixos/server/services/promtail.nix56
7 files changed, 96 insertions, 47 deletions
diff --git a/hosts/p-body/default.nix b/hosts/p-body/default.nix
index ad88a7c..10abfac 100644
--- a/hosts/p-body/default.nix
+++ b/hosts/p-body/default.nix
@@ -9,10 +9,8 @@
(modulesPath + "/virtualisation/digital-ocean-image.nix")
./forgejo.nix
./grafana.nix
- ./loki.nix
./nginx.nix
./prometheus.nix
- ./promtail.nix
];
_module.args.nixinate = {
@@ -23,6 +21,8 @@
hermetic = false;
};
+ getchoo.server.services.loki.enable = true;
+
networking = {
domain = "mydadleft.me";
hostName = "p-body";
diff --git a/hosts/p-body/prometheus.nix b/hosts/p-body/prometheus.nix
index a0d272d..56e05a9 100644
--- a/hosts/p-body/prometheus.nix
+++ b/hosts/p-body/prometheus.nix
@@ -1,10 +1,10 @@
{config, ...}: let
- scrapeExporter = name: exporter: {
+ scrapeExporter = name: host: port: {
job_name = "${name}";
static_configs = [
{
targets = [
- "127.0.0.1:${toString config.services.prometheus.exporters.${exporter}.port}"
+ "${host}:${port}"
];
}
];
@@ -21,7 +21,14 @@ in {
};
};
scrapeConfigs = [
- (scrapeExporter "p-body" "node")
+ (scrapeExporter "p-body" "127.0.0.1" "${toString config.services.prometheus.exporters.node.port}")
+ (scrapeExporter "atlas" "atlas" "5001")
];
};
+
+ getchoo.server.services.promtail.clients = [
+ {
+ url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push";
+ }
+ ];
}
diff --git a/hosts/p-body/promtail.nix b/hosts/p-body/promtail.nix
deleted file mode 100644
index 1fa7f35..0000000
--- a/hosts/p-body/promtail.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{config, ...}: {
- services.promtail = {
- enable = true;
- configuration = {
- server = {
- http_listen_port = 3031;
- grpc_listen_port = 0;
- };
- positions = {
- filename = "/tmp/positions.yaml";
- };
- clients = [
- {
- url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push";
- }
- ];
- scrape_configs = [
- {
- job_name = "journal";
- journal = {
- max_age = "12h";
- labels = {
- job = "systemd-journal";
- host = "pihole";
- };
- };
- relabel_configs = [
- {
- source_labels = ["__journal__systemd_unit"];
- target_label = "unit";
- }
- ];
- }
- ];
- };
- };
-}
diff --git a/hosts/profiles.nix b/hosts/profiles.nix
index d565840..614933e 100644
--- a/hosts/profiles.nix
+++ b/hosts/profiles.nix
@@ -73,8 +73,13 @@ in {
../modules/nixos/features/tailscale.nix
{
- getchoo.features.tailscale.enable = true;
- getchoo.server.enable = true;
+ getchoo = {
+ features.tailscale.enable = true;
+ server = {
+ enable = true;
+ services.promtail.enable = true;
+ };
+ };
nix.registry.nixpkgs.flake = nixpkgs;
}
];
diff --git a/modules/nixos/server/services/default.nix b/modules/nixos/server/services/default.nix
index 68271b1..eb24d04 100644
--- a/modules/nixos/server/services/default.nix
+++ b/modules/nixos/server/services/default.nix
@@ -1,5 +1,7 @@
_: {
imports = [
./hercules.nix
+ ./loki.nix
+ ./promtail.nix
];
}
diff --git a/hosts/p-body/loki.nix b/modules/nixos/server/services/loki.nix
index 5b0541e..1a42637 100644
--- a/hosts/p-body/loki.nix
+++ b/modules/nixos/server/services/loki.nix
@@ -1,8 +1,24 @@
-_: {
- services.loki = {
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.getchoo.server.services.loki;
+ inherit (lib) mkEnableOption mkIf mkOption types;
+in {
+ options.getchoo.server.services.loki = {
+ enable = mkEnableOption "enable loki";
+ port = mkOption {
+ type = types.port;
+ default = 3030;
+ description = "port for loki";
+ };
+ };
+
+ config.services.loki = mkIf cfg.enable {
enable = true;
configuration = {
- server.http_listen_port = 3030;
+ server.http_listen_port = cfg.port;
auth_enabled = false;
ingester = {
diff --git a/modules/nixos/server/services/promtail.nix b/modules/nixos/server/services/promtail.nix
new file mode 100644
index 0000000..73a8de2
--- /dev/null
+++ b/modules/nixos/server/services/promtail.nix
@@ -0,0 +1,56 @@
+{
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.getchoo.server.services.promtail;
+ inherit (lib) mkEnableOption mkIf mkOption types;
+in {
+ options.getchoo.server.services.promtail = {
+ enable = mkEnableOption "enable promtail";
+
+ port = mkOption {
+ type = types.port;
+ default = 3031;
+ description = "port for promtail";
+ };
+
+ clients = mkOption {
+ type = types.listOf types.attrs;
+ default = [{}];
+ description = "clients for promtail";
+ };
+ };
+
+ config.services.promtail = mkIf cfg.enable {
+ enable = true;
+ configuration = {
+ server = {
+ http_listen_port = cfg.port;
+ grpc_listen_port = 0;
+ };
+ positions = {
+ filename = "/tmp/positions.yaml";
+ };
+ inherit (cfg) clients;
+ scrape_configs = [
+ {
+ job_name = "journal";
+ journal = {
+ max_age = "12h";
+ labels = {
+ job = "systemd-journal";
+ host = "${config.networking.hostName}";
+ };
+ };
+ relabel_configs = [
+ {
+ source_labels = ["__journal__systemd_unit"];
+ target_label = "unit";
+ }
+ ];
+ }
+ ];
+ };
+ };
+}