parent
d3abaa51e1
commit
add880c5e8
@ -0,0 +1,47 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
with lib; |
||||
|
||||
let |
||||
cfg = config.services.prometheus.xmpp-alerts; |
||||
|
||||
configFile = pkgs.writeText "prometheus-xmpp-alerts.yml" (builtins.toJSON cfg.configuration); |
||||
|
||||
in |
||||
|
||||
{ |
||||
options.services.prometheus.xmpp-alerts = { |
||||
|
||||
enable = mkEnableOption "XMPP Web hook service for Alertmanager"; |
||||
|
||||
configuration = mkOption { |
||||
type = types.attrs; |
||||
description = "Configuration as attribute set which will be converted to YAML"; |
||||
}; |
||||
|
||||
}; |
||||
|
||||
config = mkIf cfg.enable { |
||||
systemd.services.prometheus-xmpp-alerts = { |
||||
wantedBy = [ "multi-user.target" ]; |
||||
after = [ "network-online.target" ]; |
||||
wants = [ "network-online.target" ]; |
||||
serviceConfig = { |
||||
ExecStart = "${pkgs.prometheus-xmpp-alerts}/bin/prometheus-xmpp-alerts --config ${configFile}"; |
||||
Restart = "on-failure"; |
||||
DynamicUser = true; |
||||
PrivateTmp = true; |
||||
PrivateDevices = true; |
||||
ProtectHome = true; |
||||
ProtectSystem = "strict"; |
||||
ProtectKernelTunables = true; |
||||
ProtectKernelModules = true; |
||||
ProtectControlGroups = true; |
||||
NoNewPrivileges = true; |
||||
SystemCallArchitectures = "native"; |
||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ]; |
||||
SystemCallFilter = [ "@system-service" ]; |
||||
}; |
||||
}; |
||||
}; |
||||
} |
@ -0,0 +1,22 @@ |
||||
{ lib, fetchFromGitHub, pythonPackages }: |
||||
|
||||
pythonPackages.buildPythonApplication rec { |
||||
pname = "prometheus-xmpp-alerts"; |
||||
version = "0.4.2"; |
||||
|
||||
src = fetchFromGitHub { |
||||
owner = "jelmer"; |
||||
repo = pname; |
||||
rev = version; |
||||
sha256 = "17aq6v4ahnga82r350kx1y8i7zgikpzmwzaacj7a339kh8hxkh63"; |
||||
}; |
||||
|
||||
propagatedBuildInputs = with pythonPackages; [ slixmpp prometheus_client pyyaml ]; |
||||
|
||||
meta = { |
||||
description = "XMPP Web hook for Prometheus"; |
||||
homepage = "https://github.com/jelmer/prometheus-xmpp-alerts"; |
||||
maintainers = with lib.maintainers; [ fpletz ]; |
||||
license = with lib.licenses; [ asl20 ]; |
||||
}; |
||||
} |
Loading…
Reference in new issue