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
cfg = config.services.prometheus.xmpp-alerts;
configFile = pkgs.writeText "prometheus-xmpp-alerts.yml" (builtins.toJSON cfg.configuration);
settingsFormat = pkgs.formats.yaml {};
configFile = settingsFormat.generate "prometheus-xmpp-alerts.yml" cfg.settings;
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";
configuration = mkOption {
type = types.attrs;
description = "Configuration as attribute set which will be converted to YAML";
};
settings = mkOption {
type = settingsFormat.type;
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 {

View file

@ -1,17 +1,36 @@
{ lib, fetchFromGitHub, pythonPackages }:
{ lib
, fetchFromGitHub
, python3Packages
, prometheus-alertmanager
}:
pythonPackages.buildPythonApplication rec {
python3Packages.buildPythonApplication rec {
pname = "prometheus-xmpp-alerts";
version = "0.4.2";
version = "0.5.1";
src = fetchFromGitHub {
owner = "jelmer";
repo = pname;
rev = version;
sha256 = "17aq6v4ahnga82r350kx1y8i7zgikpzmwzaacj7a339kh8hxkh63";
rev = "v${version}";
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 = {
description = "XMPP Web hook for Prometheus";

View file

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