Skip to content

Commit

Permalink
promtail: factor monitoring ref out of module
Browse files Browse the repository at this point in the history
and into profile
  • Loading branch information
Shay Bergmann committed May 17, 2022
1 parent 2d66fab commit 86a80ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 13 additions & 5 deletions modules/promtail.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ let
inherit (cfg.server) grpc_listen_port;
};

clients = [{
url =
"http://${config.cluster.nodes.monitoring.privateIP}:3100/loki/api/v1/push";
}];
inherit (cfg) clients;

positions = { filename = "/var/lib/promtail/positions.yaml"; };

Expand Down Expand Up @@ -106,6 +103,17 @@ in {
services.promtail = {
enable = lib.mkEnableOption "Enable Promtail";

clients = lib.mkOption {
default = [];
type = with lib.types; listOf (submodule {
options = {
url = lib.mkOption {
type = lib.types.string;
};
};
});
};

server = lib.mkOption {
default = { };
type = with lib.types;
Expand All @@ -126,7 +134,7 @@ in {
};
};

config = lib.mkIf (cfg.enable && config.cluster.nodes ? monitoring) {
config = lib.mkIf cfg.enable {
systemd.services.promtail = {
description = "Promtail service for Loki";
after = [ "network-online.target" ];
Expand Down
9 changes: 8 additions & 1 deletion profiles/auxiliaries/promtail.nix
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
_: { services.promtail.enable = true; }
_: {
services.promtail.enable = true;

services.promtail.clients = [{
url =
"http://${config.cluster.nodes.monitoring.privateIP}:3100/loki/api/v1/push";
}];
}

0 comments on commit 86a80ee

Please sign in to comment.