@ -5,6 +5,10 @@ with lib;
let
cfg = config . services . prometheus . alertmanager ;
mkConfigFile = pkgs . writeText " a l e r t m a n a g e r . y m l " ( builtins . toJSON cfg . configuration ) ;
alertmanagerYml =
if cfg . configText != null then
pkgs . writeText " a l e r t m a n a g e r . y m l " cfg . configText
else mkConfigFile ;
in {
options = {
services . prometheus . alertmanager = {
@ -34,6 +38,17 @@ in {
'' ;
} ;
configText = mkOption {
type = types . nullOr types . lines ;
default = null ;
description = ''
Alertmanager configuration as YAML text . If non-null , this option
defines the text that is written to alertmanager . yml . If null , the
contents of alertmanager . yml is generated from the structured config
options .
'' ;
} ;
logFormat = mkOption {
type = types . nullOr types . str ;
default = null ;
@ -96,7 +111,7 @@ in {
after = [ " n e t w o r k . t a r g e t " ] ;
script = ''
$ { pkgs . prometheus-alertmanager . bin } /bin/alertmanager \
- config . file $ { mkConfigFile } \
- config . file $ { alertmanagerYml } \
- web . listen-address $ { cfg . listenAddress }: $ { toString cfg . port } \
- log . level $ { cfg . logLevel } \
$ { optionalString ( cfg . webExternalUrl != null ) '' - w e b . e x t e r n a l - u r l ${ cfg . webExternalUrl } \ '' }