summaryrefslogtreecommitdiff
path: root/gnu/services/monitoring.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/monitoring.scm')
-rw-r--r--gnu/services/monitoring.scm82
1 files changed, 82 insertions, 0 deletions
diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index a37dfd80d8..50a4b7302c 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -51,6 +51,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
@@ -228,6 +239,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
;;;