Skip to content

Commit

Permalink
prometheus exporter modules: unify firewall handling
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Jan 9, 2017
1 parent 618b249 commit 575afe3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
10 changes: 10 additions & 0 deletions nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix
Expand Up @@ -31,10 +31,20 @@ in {
Extra commandline options when launching the blackbox exporter.
'';
};

openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Open port in firewall for incoming connections.
'';
};
};
};

config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;

systemd.services.prometheus-blackbox-exporter = {
description = "Prometheus exporter for blackbox probes";
unitConfig.Documentation = "https://github.com/prometheus/blackbox_exporter";
Expand Down
10 changes: 10 additions & 0 deletions nixos/modules/services/monitoring/prometheus/json-exporter.nix
Expand Up @@ -38,10 +38,20 @@ in {
Extra commandline options when launching the JSON exporter.
'';
};

openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Open port in firewall for incoming connections.
'';
};
};
};

config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;

systemd.services.prometheus-json-exporter = {
description = "Prometheus exporter for JSON over HTTP";
unitConfig.Documentation = "https://github.com/kawamuray/prometheus-json-exporter";
Expand Down
10 changes: 9 additions & 1 deletion nixos/modules/services/monitoring/prometheus/nginx-exporter.nix
Expand Up @@ -41,11 +41,19 @@ in {
Extra commandline options when launching the nginx exporter.
'';
};

openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Open port in firewall for incoming connections.
'';
};
};
};

config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [ cfg.port ];
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;

systemd.services.prometheus-nginx-exporter = {
after = [ "network.target" "nginx.service" ];
Expand Down
10 changes: 10 additions & 0 deletions nixos/modules/services/monitoring/prometheus/node-exporter.nix
Expand Up @@ -44,10 +44,20 @@ in {
Extra commandline options when launching the node exporter.
'';
};

openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Open port in firewall for incoming connections.
'';
};
};
};

config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;

systemd.services.prometheus-node-exporter = {
description = "Prometheus exporter for machine metrics";
unitConfig.Documentation = "https://github.com/prometheus/node_exporter";
Expand Down
10 changes: 10 additions & 0 deletions nixos/modules/services/monitoring/prometheus/varnish-exporter.nix
Expand Up @@ -25,10 +25,20 @@ in {
Extra commandline options when launching the Varnish exporter.
'';
};

openFirewall = mkOption {
type = types.bool;
default = false;
description = ''
Open port in firewall for incoming connections.
'';
};
};
};

config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = optional cfg.openFirewall cfg.port;

systemd.services.prometheus-varnish-exporter = {
description = "Prometheus exporter for Varnish metrics";
unitConfig.Documentation = "https://github.com/jonnenauha/prometheus_varnish_exporter";
Expand Down

0 comments on commit 575afe3

Please sign in to comment.