diff options
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 940f60c0e8..7c6bd061d0 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -99,6 +99,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 @@ -752,6 +763,77 @@ resolution.") ;;; +;;; 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 ;;; |