diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-20 22:17:41 +0100 |
---|---|---|
committer | Guix Patches Tester <> | 2020-04-20 22:20:06 +0100 |
commit | 31c23138824f5ccf677b97524acc39d02943be21 (patch) | |
tree | 9fc090a577b4e576a3bf8ba33ca388005530ac05 /gnu/services/monitoring.scm | |
parent | a87785d3f8c475d6a0f9d2910639587938450ddb (diff) | |
download | guix-patches-31c23138824f5ccf677b97524acc39d02943be21.tar guix-patches-31c23138824f5ccf677b97524acc39d02943be21.tar.gz |
services: Add a Prometheus service.
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 511f4fb2fe..a37dfd80d8 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -40,6 +40,17 @@ darkstat-service-type prometheus-node-exporter-service-type + prometheus-service-type + <prometheus-configuration> + prometheus-configuration + prometheus-configuration-package + prometheus-configuration-user + prometheus-configuration-group + prometheus-configuration-config-file + prometheus-configuration-web-listen-address + prometheus-configuration-storage-tsdb-path + prometheus-configuration-extra-options + zabbix-server-configuration zabbix-server-service-type zabbix-agent-configuration @@ -110,6 +121,77 @@ HTTP.") (service-extension shepherd-root-service-type (compose list darkstat-shepherd-service)))))) + +;;; +;;; Prometheus +;;; + +(define-record-type* <prometheus-configuration> + prometheus-configuration + make-prometheus-configuration + prometheus-configuration? + (package prometheus-configuration-package + (default prometheus)) + (user prometheus-configuration-user + (default "prometheus")) + (group prometheusconfiguration-group + (default "prometheus")) + (config-file prometheus-config-file + (default (plain-file "prometheus.yml" ""))) + (web-listen-address prometheus-web-listen-address + (default "0.0.0.0:9090")) + (storage-tsdb-path prometheus-storage-tsdb-path + (default "/var/lib/prometheus/data/")) + (extra-options prometheus-configuration-extra-options + (default '()))) + +(define prometheus-shepherd-service + (match-lambda + (($ <prometheus-configuration> package user group + config-file web-listen-address + storage-tsdb-path extra-options) + (shepherd-service + (documentation "Prometheus monitoring system and time series database.") + (provision '(prometheus)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/bin/prometheus") + "--config.file" #$config-file + "--web.listen-address" #$web-listen-address + "--storage.tsdb.path" #$storage-tsdb-path + #$@extra-options) + #:user #$user + #:group #$group + #:log-file "/var/log/prometheus.log")) + (stop #~(make-kill-destructor)))))) + +(define (prometheus-account config) + (match-record config <prometheus-configuration> + (user group) + (list (user-group + (name group) + (system? #t)) + (user-account + (name user) + (group group) + (system? #t) + (comment "Prometheus user") + (home-directory "/var/lib/prometheus") + (shell (file-append shadow "/sbin/nologin")))))) + +(define prometheus-service-type + (service-type + (name 'prometheus) + (description + "Run @command{prometheus} to scrape targets for mertrics and provide the +web interface.") + (extensions + (list (service-extension shepherd-root-service-type + (compose list prometheus-shepherd-service)) + (service-extension account-service-type + prometheus-account))) + (default-value (prometheus-configuration)))) + (define-record-type* <prometheus-node-exporter-configuration> prometheus-node-exporter-configuration make-prometheus-node-exporter-configuration |