Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
2,090 additions
and
809 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.prometheus.blackboxExporter; | ||
in { | ||
options = { | ||
services.prometheus.blackboxExporter = { | ||
enable = mkEnableOption "prometheus blackbox exporter"; | ||
|
||
configFile = mkOption { | ||
type = types.path; | ||
description = '' | ||
Path to configuration file. | ||
''; | ||
}; | ||
|
||
port = mkOption { | ||
type = types.int; | ||
default = 9115; | ||
description = '' | ||
Port to listen on. | ||
''; | ||
}; | ||
|
||
extraFlags = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
description = '' | ||
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"; | ||
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
User = "nobody"; | ||
Restart = "always"; | ||
PrivateTmp = true; | ||
WorkingDirectory = /tmp; | ||
ExecStart = '' | ||
${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \ | ||
-web.listen-address :${toString cfg.port} \ | ||
-config.file ${cfg.configFile} \ | ||
${concatStringsSep " \\\n " cfg.extraFlags} | ||
''; | ||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; | ||
}; | ||
}; | ||
}; | ||
} |
74 changes: 74 additions & 0 deletions
74
nixos/modules/services/monitoring/prometheus/json-exporter.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.prometheus.jsonExporter; | ||
in { | ||
options = { | ||
services.prometheus.jsonExporter = { | ||
enable = mkEnableOption "prometheus JSON exporter"; | ||
|
||
url = mkOption { | ||
type = types.str; | ||
description = '' | ||
URL to scrape JSON from. | ||
''; | ||
}; | ||
|
||
configFile = mkOption { | ||
type = types.path; | ||
description = '' | ||
Path to configuration file. | ||
''; | ||
}; | ||
|
||
port = mkOption { | ||
type = types.int; | ||
default = 7979; | ||
description = '' | ||
Port to listen on. | ||
''; | ||
}; | ||
|
||
extraFlags = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
description = '' | ||
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"; | ||
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
User = "nobody"; | ||
Restart = "always"; | ||
PrivateTmp = true; | ||
WorkingDirectory = /tmp; | ||
ExecStart = '' | ||
${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \ | ||
--port ${toString cfg.port} \ | ||
${cfg.url} ${cfg.configFile} \ | ||
${concatStringsSep " \\\n " cfg.extraFlags} | ||
''; | ||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; | ||
}; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.