Merge branch 'master' into grafana_dashboard
This commit is contained in:
		
				commit
				
					
						ba933f1470
					
				
			
		
					 18 changed files with 257 additions and 1 deletions
				
			
		
							
								
								
									
										66
									
								
								cdist/conf/type/__prometheus_alertmanager/man.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								cdist/conf/type/__prometheus_alertmanager/man.rst
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,66 @@
 | 
				
			||||||
 | 
					cdist-type__prometheus_alertmanager(7)
 | 
				
			||||||
 | 
					======================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAME
 | 
				
			||||||
 | 
					----
 | 
				
			||||||
 | 
					cdist-type__prometheus_alertmanager - install Alertmanager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DESCRIPTION
 | 
				
			||||||
 | 
					-----------
 | 
				
			||||||
 | 
					Install and configure Prometheus Alertmanager (https://prometheus.io/docs/alerting/alertmanager/).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					REQUIRED PARAMETERS
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
					config
 | 
				
			||||||
 | 
					   Alertmanager configuration file. It will be saved as /etc/alertmanager/alertmanager.yml on the target.
 | 
				
			||||||
 | 
					listen-address
 | 
				
			||||||
 | 
					   Passed as web.listen-address.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONAL PARAMETERS
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
					storage-path
 | 
				
			||||||
 | 
					   Where to put data. Default: /data/alertmanager. (Directory will be created if needed.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOLEAN PARAMETERS
 | 
				
			||||||
 | 
					------------------
 | 
				
			||||||
 | 
					with-daemontools
 | 
				
			||||||
 | 
					   Create a daemontools service directory under /service/prometheus. Default: yes.
 | 
				
			||||||
 | 
					   Note: If you do not use this, Alertmanager will not be launched, and will not reload config on change.
 | 
				
			||||||
 | 
					   If you use this, daemontools (or something compatible) must be installed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EXAMPLES
 | 
				
			||||||
 | 
					--------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ALERTPORT=9093
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __daemontools
 | 
				
			||||||
 | 
					    __golang_from_vendor --version 1.8.1  # required for prometheus and many exporters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    require="__daemontools __golang_from_vendor" __prometheus_alertmanager \
 | 
				
			||||||
 | 
					      --config "$__manifest/files/alertmanager.yml" \
 | 
				
			||||||
 | 
					      --storage-path /data/alertmanager \
 | 
				
			||||||
 | 
					      --listen-address "[::]:$ALERTPORT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SEE ALSO
 | 
				
			||||||
 | 
					--------
 | 
				
			||||||
 | 
					:strong:`cdist-type__prometheus_server`\ (7), :strong:`cdist-type__daemontools`\ (7),
 | 
				
			||||||
 | 
					Prometheus alerting documentation: https://prometheus.io/docs/alerting/overview/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AUTHORS
 | 
				
			||||||
 | 
					-------
 | 
				
			||||||
 | 
					Kamila Součková <kamila--@--ksp.sk>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPYING
 | 
				
			||||||
 | 
					-------
 | 
				
			||||||
 | 
					Copyright \(C) 2017 Kamila Součková. You can redistribute it
 | 
				
			||||||
 | 
					and/or modify it under the terms of the GNU General Public License as
 | 
				
			||||||
 | 
					published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
 | 
					License, or (at your option) any later version.
 | 
				
			||||||
							
								
								
									
										39
									
								
								cdist/conf/type/__prometheus_alertmanager/manifest
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								cdist/conf/type/__prometheus_alertmanager/manifest
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,39 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GOBIN=/opt/gocode/bin  # where to find go binaries
 | 
				
			||||||
 | 
					CONF_DIR=/etc/prometheus
 | 
				
			||||||
 | 
					LOGLEVEL=info
 | 
				
			||||||
 | 
					CONF=$CONF_DIR/alertmanager.yml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Prometheus server #######################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config="$(cat "$__object/parameter/config")"
 | 
				
			||||||
 | 
					storage_path="$(cat "$__object/parameter/storage-path")"
 | 
				
			||||||
 | 
					listen_address="$(cat "$__object/parameter/listen-address")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ONCHANGE=""
 | 
				
			||||||
 | 
					if [ -f "$__object/parameter/with-daemontools" ]; then
 | 
				
			||||||
 | 
						__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS"
 | 
				
			||||||
 | 
						ONCHANGE="svc -h /service/prometheus"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FLAGS="config.file '$CONF'
 | 
				
			||||||
 | 
					storage.path '$storage_path'
 | 
				
			||||||
 | 
					web.listen-address '$listen_address'
 | 
				
			||||||
 | 
					log.level $LOGLEVEL"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__go_get github.com/prometheus/alertmanager/cmd/...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__user prometheus --system
 | 
				
			||||||
 | 
					__directory "$storage_path" --owner prometheus
 | 
				
			||||||
 | 
					__directory "$CONF_DIR" --owner prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__daemontools_service alertmanager --run "setuidgid prometheus $GOBIN/alertmanager $REAL_FLAGS"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require="$require __directory/$storage_path" \
 | 
				
			||||||
 | 
					__config_file $CONF \
 | 
				
			||||||
 | 
					    --source $config \
 | 
				
			||||||
 | 
					    --group prometheus --mode 640 \
 | 
				
			||||||
 | 
					    --onchange "$ONCHANGE"
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					/data/alertmanager
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					storage-path
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					config
 | 
				
			||||||
 | 
					listen-address
 | 
				
			||||||
							
								
								
									
										0
									
								
								cdist/conf/type/__prometheus_alertmanager/singleton
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								cdist/conf/type/__prometheus_alertmanager/singleton
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										78
									
								
								cdist/conf/type/__prometheus_server/man.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								cdist/conf/type/__prometheus_server/man.rst
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,78 @@
 | 
				
			||||||
 | 
					cdist-type__prometheus_server(7)
 | 
				
			||||||
 | 
					================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAME
 | 
				
			||||||
 | 
					----
 | 
				
			||||||
 | 
					cdist-type__prometheus_server - install Prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DESCRIPTION
 | 
				
			||||||
 | 
					-----------
 | 
				
			||||||
 | 
					Install and configure Prometheus (https://prometheus.io/).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					REQUIRED PARAMETERS
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
					config
 | 
				
			||||||
 | 
					   Prometheus configuration file. It will be saved as /etc/prometheus/prometheus.yml on the target.
 | 
				
			||||||
 | 
					listen-address
 | 
				
			||||||
 | 
					   Passed as web.listen-address.
 | 
				
			||||||
 | 
					alertmanager-url
 | 
				
			||||||
 | 
					   Passed as alertmanager.url
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONAL PARAMETERS
 | 
				
			||||||
 | 
					-------------------
 | 
				
			||||||
 | 
					retention-days
 | 
				
			||||||
 | 
					   How long to keep data. Default: 30
 | 
				
			||||||
 | 
					rule-files
 | 
				
			||||||
 | 
					   Path to rule files. They will be installed under /etc/prometheus/<filename>. You need to include `rule_files: [/etc/prometheus/<your-pattern>]` in the config file if you use this.
 | 
				
			||||||
 | 
					storage-path
 | 
				
			||||||
 | 
					   Where to put data. Default: /data/prometheus. (Directory will be created if needed.)
 | 
				
			||||||
 | 
					target-heap-size
 | 
				
			||||||
 | 
					   Passed as storage.local.target-heap-size. Default: 1/2 of RAM.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BOOLEAN PARAMETERS
 | 
				
			||||||
 | 
					------------------
 | 
				
			||||||
 | 
					with-daemontools
 | 
				
			||||||
 | 
					   Create a daemontools service directory under /service/prometheus. Default: yes.
 | 
				
			||||||
 | 
					   Note: If you do not use this, Prometheus will not be launched, and will not reload config on change.
 | 
				
			||||||
 | 
					   If you use this, daemontools (or something compatible) must be installed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EXAMPLES
 | 
				
			||||||
 | 
					--------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PROMPORT=9090
 | 
				
			||||||
 | 
					    ALERTPORT=9093
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    __daemontools
 | 
				
			||||||
 | 
					    __golang_from_vendor --version 1.8.1  # required for prometheus and many exporters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    require="__daemontools __golang_from_vendor" __prometheus_server \
 | 
				
			||||||
 | 
					        --config "$__manifest/files/prometheus.yml" \
 | 
				
			||||||
 | 
					        --retention-days 14 \
 | 
				
			||||||
 | 
					        --storage-path /data/prometheus \
 | 
				
			||||||
 | 
					        --listen-address "[::]:$PROMPORT" \
 | 
				
			||||||
 | 
					        --rule-files "$__manifest/files/*.rules" \
 | 
				
			||||||
 | 
					        --alertmanager-url "http://monitoring1.node.consul:$ALERTPORT,http://monitoring2.node.consul:$ALERTPORT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SEE ALSO
 | 
				
			||||||
 | 
					--------
 | 
				
			||||||
 | 
					:strong:`cdist-type__prometheus_alertmanager`\ (7), :strong:`cdist-type__daemontools`\ (7),
 | 
				
			||||||
 | 
					Prometheus documentation: https://prometheus.io/docs/introduction/overview/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AUTHORS
 | 
				
			||||||
 | 
					-------
 | 
				
			||||||
 | 
					Kamila Součková <kamila--@--ksp.sk>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPYING
 | 
				
			||||||
 | 
					-------
 | 
				
			||||||
 | 
					Copyright \(C) 2017 Kamila Součková. You can redistribute it
 | 
				
			||||||
 | 
					and/or modify it under the terms of the GNU General Public License as
 | 
				
			||||||
 | 
					published by the Free Software Foundation, either version 3 of the
 | 
				
			||||||
 | 
					License, or (at your option) any later version.
 | 
				
			||||||
							
								
								
									
										57
									
								
								cdist/conf/type/__prometheus_server/manifest
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								cdist/conf/type/__prometheus_server/manifest
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,57 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GOBIN=/opt/gocode/bin  # where to find go binaries
 | 
				
			||||||
 | 
					CONF_DIR=/etc/prometheus
 | 
				
			||||||
 | 
					CONF=$CONF_DIR/prometheus.yml
 | 
				
			||||||
 | 
					LOGLEVEL=info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config="$(cat "$__object/parameter/config")"
 | 
				
			||||||
 | 
					retention_days="$(cat "$__object/parameter/retention-days")"
 | 
				
			||||||
 | 
					storage_path="$(cat "$__object/parameter/storage-path")"
 | 
				
			||||||
 | 
					listen_address="$(cat "$__object/parameter/listen-address")"
 | 
				
			||||||
 | 
					alertmanager_url="$(cat "$__object/parameter/alertmanager-url")"
 | 
				
			||||||
 | 
					target_heap_size="$(cat "$__object/parameter/target-heap-size")"
 | 
				
			||||||
 | 
					rule_files="$(cat "$__object/parameter/rule-files")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# explorer in kB => convert; by default we go with 1/2 RAM
 | 
				
			||||||
 | 
					[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat $__global/explorer/memory)*1024/2))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ONCHANGE=""
 | 
				
			||||||
 | 
					if [ -f "$__object/parameter/with-daemontools" ]; then
 | 
				
			||||||
 | 
						__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS"
 | 
				
			||||||
 | 
						ONCHANGE="&& svc -h /service/prometheus"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FLAGS="config.file '$CONF'
 | 
				
			||||||
 | 
					storage.local.path '$storage_path'
 | 
				
			||||||
 | 
					storage.local.target-heap-size $(($target_heap_size))  # in bytes; should be 2/3 of available memory because it may be hungry
 | 
				
			||||||
 | 
					storage.local.retention $(($retention_days*24))h  # golang doesn't have days :D
 | 
				
			||||||
 | 
					web.listen-address '$listen_address'
 | 
				
			||||||
 | 
					alertmanager.url '$alertmanager_url'
 | 
				
			||||||
 | 
					log.level $LOGLEVEL"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__go_get github.com/prometheus/prometheus/cmd/...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__user prometheus --system
 | 
				
			||||||
 | 
					__directory "$storage_path" --owner prometheus
 | 
				
			||||||
 | 
					__directory "$CONF_DIR" --owner prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require="$require __directory/$storage_path" \
 | 
				
			||||||
 | 
					__config_file $CONF \
 | 
				
			||||||
 | 
						--source $config \
 | 
				
			||||||
 | 
						--group prometheus --mode 640 \
 | 
				
			||||||
 | 
						--onchange "$GOBIN/promtool check-config $CONF $ONCHANGE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for file in $rule_files; do
 | 
				
			||||||
 | 
						dest=$CONF_DIR/$(basename $file)
 | 
				
			||||||
 | 
						require="$require __directory/$CONF_DIR" \
 | 
				
			||||||
 | 
						__config_file "$dest" \
 | 
				
			||||||
 | 
							--source "$file" \
 | 
				
			||||||
 | 
							--owner prometheus \
 | 
				
			||||||
 | 
							--onchange "$GOBIN/promtool check-rules '$dest' $ONCHANGE"
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								cdist/conf/type/__prometheus_server/parameter/boolean
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__prometheus_server/parameter/boolean
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					with-daemontools
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					30
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					/data/prometheus
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					auto
 | 
				
			||||||
							
								
								
									
										4
									
								
								cdist/conf/type/__prometheus_server/parameter/optional
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								cdist/conf/type/__prometheus_server/parameter/optional
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					target-heap-size
 | 
				
			||||||
 | 
					retention-days
 | 
				
			||||||
 | 
					rule-files
 | 
				
			||||||
 | 
					storage-path
 | 
				
			||||||
							
								
								
									
										3
									
								
								cdist/conf/type/__prometheus_server/parameter/required
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								cdist/conf/type/__prometheus_server/parameter/required
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					alertmanager-url
 | 
				
			||||||
 | 
					config
 | 
				
			||||||
 | 
					listen-address
 | 
				
			||||||
							
								
								
									
										0
									
								
								cdist/conf/type/__prometheus_server/singleton
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								cdist/conf/type/__prometheus_server/singleton
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -9,6 +9,7 @@ next:
 | 
				
			||||||
	* Core: Shorten ssh control path (Darko Poljak)
 | 
						* Core: Shorten ssh control path (Darko Poljak)
 | 
				
			||||||
	* Type __consul: Add new version and add http check (Kamila Součková)
 | 
						* Type __consul: Add new version and add http check (Kamila Součková)
 | 
				
			||||||
	* New types: __daemontools and __daemontools_service (Kamila Součková)
 | 
						* New types: __daemontools and __daemontools_service (Kamila Součková)
 | 
				
			||||||
 | 
						* New types: __prometheus_server and __prometheus_alertmanager (Kamila Součková)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
4.4.2: 2017-03-08
 | 
					4.4.2: 2017-03-08
 | 
				
			||||||
	* Core: Fix suppression of manifests' outputs (Darko Poljak)
 | 
						* Core: Fix suppression of manifests' outputs (Darko Poljak)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue