Merge pull request #100274 from hax404/prometheus-xmpp-alerts

This commit is contained in:
Martin Weinelt 2021-05-19 01:36:28 +02:00 committed by GitHub
commit 4c798857e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 18 deletions

View file

@ -4,21 +4,29 @@ with lib;
let let
cfg = config.services.prometheus.xmpp-alerts; cfg = config.services.prometheus.xmpp-alerts;
settingsFormat = pkgs.formats.yaml {};
configFile = pkgs.writeText "prometheus-xmpp-alerts.yml" (builtins.toJSON cfg.configuration); configFile = settingsFormat.generate "prometheus-xmpp-alerts.yml" cfg.settings;
in in
{ {
options.services.prometheus.xmpp-alerts = { imports = [
(mkRenamedOptionModule
[ "services" "prometheus" "xmpp-alerts" "configuration" ]
[ "services" "prometheus" "xmpp-alerts" "settings" ])
];
options.services.prometheus.xmpp-alerts = {
enable = mkEnableOption "XMPP Web hook service for Alertmanager"; enable = mkEnableOption "XMPP Web hook service for Alertmanager";
configuration = mkOption { settings = mkOption {
type = types.attrs; type = settingsFormat.type;
description = "Configuration as attribute set which will be converted to YAML"; default = {};
};
description = ''
Configuration for prometheus xmpp-alerts, see
<link xlink:href="https://github.com/jelmer/prometheus-xmpp-alerts/blob/master/xmpp-alerts.yml.example"/>
for supported values.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -1,17 +1,36 @@
{ lib, fetchFromGitHub, pythonPackages }: { lib
, fetchFromGitHub
, python3Packages
, prometheus-alertmanager
}:
pythonPackages.buildPythonApplication rec { python3Packages.buildPythonApplication rec {
pname = "prometheus-xmpp-alerts"; pname = "prometheus-xmpp-alerts";
version = "0.4.2"; version = "0.5.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "jelmer"; owner = "jelmer";
repo = pname; repo = pname;
rev = version; rev = "v${version}";
sha256 = "17aq6v4ahnga82r350kx1y8i7zgikpzmwzaacj7a339kh8hxkh63"; sha256 = "0qmmmlcanbrhyyxi32gy3gibgvj7jdjwpa8cf5ci9czvbyxg4rld";
}; };
propagatedBuildInputs = with pythonPackages; [ slixmpp prometheus_client pyyaml ]; propagatedBuildInputs = [
prometheus-alertmanager
] ++ (with python3Packages; [
aiohttp
slixmpp
prometheus_client
pyyaml
]);
checkInputs = with python3Packages; [
pytz
];
checkPhase = ''
${python3Packages.python.interpreter} -m unittest discover
'';
meta = { meta = {
description = "XMPP Web hook for Prometheus"; description = "XMPP Web hook for Prometheus";

View file

@ -19453,9 +19453,7 @@ in
prometheus-wireguard-exporter = callPackage ../servers/monitoring/prometheus/wireguard-exporter.nix { prometheus-wireguard-exporter = callPackage ../servers/monitoring/prometheus/wireguard-exporter.nix {
inherit (darwin.apple_sdk.frameworks) Security; inherit (darwin.apple_sdk.frameworks) Security;
}; };
prometheus-xmpp-alerts = callPackage ../servers/monitoring/prometheus/xmpp-alerts.nix { prometheus-xmpp-alerts = callPackage ../servers/monitoring/prometheus/xmpp-alerts.nix { };
pythonPackages = python3Packages;
};
prometheus-cpp = callPackage ../development/libraries/prometheus-cpp { }; prometheus-cpp = callPackage ../development/libraries/prometheus-cpp { };