mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-20 02:55:39 +00:00
nixos/prometheus.sachet: add module
This commit is contained in:
parent
6953eca70d
commit
f7e49fae0d
@ -183,6 +183,14 @@
|
||||
<link xlink:href="options.html#opt-services.hadoop.hbase.enable">services.hadoop.hbase</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://github.com/messagebird/sachet/">Sachet</link>,
|
||||
an SMS alerting tool for the Prometheus Alertmanager.
|
||||
Available as
|
||||
<link linkend="opt-services.prometheus.sachet.enable">services.prometheus.sachet</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://github.com/leetronics/infnoise">infnoise</link>,
|
||||
|
@ -68,6 +68,8 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||
|
||||
- [HBase cluster](https://hbase.apache.org/), a distributed, scalable, big data store. Available as [services.hadoop.hbase](options.html#opt-services.hadoop.hbase.enable).
|
||||
|
||||
- [Sachet](https://github.com/messagebird/sachet/), an SMS alerting tool for the Prometheus Alertmanager. Available as [services.prometheus.sachet](#opt-services.prometheus.sachet.enable).
|
||||
|
||||
- [infnoise](https://github.com/leetronics/infnoise), a hardware True Random Number Generator dongle.
|
||||
Available as [services.infnoise](options.html#opt-services.infnoise.enable).
|
||||
|
||||
|
@ -692,6 +692,7 @@
|
||||
./services/monitoring/prometheus/alertmanager.nix
|
||||
./services/monitoring/prometheus/exporters.nix
|
||||
./services/monitoring/prometheus/pushgateway.nix
|
||||
./services/monitoring/prometheus/sachet.nix
|
||||
./services/monitoring/prometheus/xmpp-alerts.nix
|
||||
./services/monitoring/riemann.nix
|
||||
./services/monitoring/riemann-dash.nix
|
||||
|
88
nixos/modules/services/monitoring/prometheus/sachet.nix
Normal file
88
nixos/modules/services/monitoring/prometheus/sachet.nix
Normal file
@ -0,0 +1,88 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.prometheus.sachet;
|
||||
configFile = pkgs.writeText "sachet.yml" (builtins.toJSON cfg.configuration);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.prometheus.sachet = {
|
||||
enable = mkEnableOption "Sachet, an SMS alerting tool for the Prometheus Alertmanager";
|
||||
|
||||
configuration = mkOption {
|
||||
type = types.nullOr types.attrs;
|
||||
default = null;
|
||||
example = literalExample ''
|
||||
{
|
||||
providers = {
|
||||
twilio = {
|
||||
# environment variables gets expanded at runtime
|
||||
account_sid = "$TWILIO_ACCOUNT";
|
||||
auth_token = "$TWILIO_TOKEN";
|
||||
};
|
||||
};
|
||||
templates = [ ./some-template.tmpl ];
|
||||
receivers = [{
|
||||
name = "pager";
|
||||
provider = "twilio";
|
||||
to = [ "+33123456789" ];
|
||||
text = "{{ template \"message\" . }}";
|
||||
}];
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Sachet's configuration as a nix attribute set.
|
||||
'';
|
||||
};
|
||||
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
description = ''
|
||||
The address Sachet will listen to.
|
||||
'';
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 9876;
|
||||
description = ''
|
||||
The port Sachet will listen to.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = singleton {
|
||||
assertion = cfg.configuration != null;
|
||||
message = "Cannot enable Sachet without a configuration.";
|
||||
};
|
||||
|
||||
systemd.services.sachet = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" "network-online.target" ];
|
||||
script = ''
|
||||
${pkgs.envsubst}/bin/envsubst -i "${configFile}" > /tmp/sachet.yaml
|
||||
exec ${pkgs.prometheus-sachet}/bin/sachet -config /tmp/sachet.yaml -listen-address ${cfg.address}:${builtins.toString cfg.port}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectControlGroups = true;
|
||||
|
||||
DynamicUser = true;
|
||||
PrivateTmp = true;
|
||||
WorkingDirectory = "/tmp/";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user