diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-18 17:24:55 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-07-02 13:56:11 +0100 |
commit | f1993a1213bcef604c0b334b88b1db310ba115dc (patch) | |
tree | d760e331c7f76cdcc29809016c93cc470acc6ede /gnu/services/monitoring.scm | |
parent | d4e6bbe45da9e6a75cb49d82fc7f1937d76b75ae (diff) | |
download | guix-prometheus.tar guix-prometheus.tar.gz |
services: Add a service for Alertmanager.prometheus
Diffstat (limited to 'gnu/services/monitoring.scm')
-rw-r--r-- | gnu/services/monitoring.scm | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index b42cd1d224..2bc6e89024 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -55,6 +55,17 @@ prometheus-configuration-storage-tsdb-path prometheus-configuration-extra-options + alertmanager-service-type + <alertmanager-configuration> + alertmanager-configuration + alertmanager-configuration-package + alertmanager-configuration-user + alertmanager-configuration-group + alertmanager-configuration-config-file + alertmanager-configuration-web-listen-address + alertmanager-configuration-storage-path + alertmanager-configuration-extra-options + zabbix-server-configuration zabbix-server-service-type zabbix-agent-configuration @@ -279,6 +290,77 @@ Prometheus.") ;;; +;;; Alertmanager +;;; + +(define-record-type* <alertmanager-configuration> + alertmanager-configuration + make-alertmanager-configuration + alertmanager-configuration? + (package alertmanager-configuration-package + (default alertmanager)) + (user alertmanager-configuration-user + (default "alertmanager")) + (group alertmanagerconfiguration-group + (default "alertmanager")) + (config-file alertmanager-config-file + (default (plain-file "alertmanager.yml" ""))) + (web-listen-address alertmanager-web-listen-address + (default ":9093")) + (storage-tsdb-path alertmanager-storage-tsdb-path + (default "/var/lib/alertmanager/data/")) + (extra-options alertmanager-configuration-extra-options + (default '()))) + +(define alertmanager-shepherd-service + (match-lambda + (($ <alertmanager-configuration> package user group + config-file web-listen-address + storage-tsdb-path extra-options) + (shepherd-service + (documentation "Alertmanager monitoring system and time series database.") + (provision '(alertmanager)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/alertmanager") + "--config.file" #$config-file + "--web.listen-address" #$web-listen-address + "--storage.path" #$storage-tsdb-path + #$@extra-options) + #:user #$user + #:group #$group + #:log-file "/var/log/alertmanager.log")) + (stop #~(make-kill-destructor)))))) + +(define (alertmanager-account config) + (match-record config <alertmanager-configuration> + (user group) + (list (user-group + (name group) + (system? #t)) + (user-account + (name user) + (group group) + (system? #t) + (comment "Alertmanager user") + (home-directory "/var/lib/alertmanager") + (shell (file-append shadow "/sbin/nologin")))))) + +(define alertmanager-service-type + (service-type + (name 'alertmanager) + (description + "Run @command{alertmanager} to scrape targets for mertrics and provide the +web interface.") + (extensions + (list (service-extension shepherd-root-service-type + (compose list alertmanager-shepherd-service)) + (service-extension account-service-type + alertmanager-account))) + (default-value (alertmanager-configuration)))) + + +;;; ;;; Zabbix server ;;; |