Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3768590
D2600.id6558.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D2600.id6558.diff
View Options
diff --git a/_modules/paas_docker.py b/_modules/paas_docker.py
--- a/_modules/paas_docker.py
+++ b/_modules/paas_docker.py
@@ -48,3 +48,37 @@
subnets.append("172.17.0.0/16")
return subnets
+
+
+# -------------------------------------------------------------
+# Monitoring
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def _get_health_check_url(check_type, container, url):
+ if check_type[-6:] == "_proxy":
+ return f"https://{container['host']}{url}"
+
+ return f"http://localhost:{container['app_port']}{url}"
+
+
+def get_health_checks():
+ """
+ A function to get a dictionary with health checks
+ for known containers to use with our monitoring.
+
+ CLI Example:
+
+ salt * paas_docker.get_health_checks
+ """
+ containers = __pillar__["docker_containers"][__grains__["id"]]
+ monitoring = __pillar__["docker_containers_monitoring"]
+
+ return {
+ check_type: {
+ instance: _get_health_check_url(check_type, container, url)
+ for service, url in monitoring[check_type].items()
+ for instance, container in containers[service].items()
+ }
+ for check_type in monitoring.keys()
+ }
diff --git a/pillar/paas/docker.sls b/pillar/paas/docker.sls
--- a/pillar/paas/docker.sls
+++ b/pillar/paas/docker.sls
@@ -474,6 +474,41 @@
sentry_cron:
realm: nasqueron
+# -------------------------------------------------------------
+# Monitoring
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+docker_containers_monitoring:
+
+ # Go to URL, check it's an HTTP 200 response
+ check_http_200:
+ acme_dns: /health
+ cachet: /api/v1/ping
+ hound: /healthz
+
+ # Test a regular URL for services without health check
+ api-datasources: /datasources
+ etherpad: /stats
+ hauk: /
+ jenkins: /login
+ registry: /
+
+ # Go to URL, check it's an HTTP 200 response code + "ALIVE" as content
+ check_http_200_alive:
+ auth-grove: /status
+ docker-registry-api: /status
+ notifications: /status
+ tommy: /status
+
+ # Same than check_http_200, but we need to query the proxy
+ check_http_200_proxy:
+ openfire: /login.jsp
+ pixelfed: /api/nodeinfo/2.0.json
+
+ # Same than check_http_200_alive, but we need to query the proxy
+ check_http_200_alive_proxy:
+ phabricator: /status
+
# -------------------------------------------------------------
# Ports listened by known applications
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/roles/paas-docker/init.sls b/roles/paas-docker/init.sls
--- a/roles/paas-docker/init.sls
+++ b/roles/paas-docker/init.sls
@@ -20,6 +20,7 @@
- .wwwroot-502
- .wwwroot-content
- .nginx
+ - .monitoring
- .letsencrypt
- .wrappers
{% if salt['node.has']('flags:install_docker_devel_tools') %}
diff --git a/roles/paas-docker/monitoring/files/checks.yml.jinja b/roles/paas-docker/monitoring/files/checks.yml.jinja
new file mode 100644
--- /dev/null
+++ b/roles/paas-docker/monitoring/files/checks.yml.jinja
@@ -0,0 +1,15 @@
+# -------------------------------------------------------------
+# Configuration for Docker PaaS monitoring
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Source file: roles/paas-docker/monitoring/files/checks.yml.jinja
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+checks: {{ checks }}
diff --git a/roles/paas-docker/monitoring/init.sls b/roles/paas-docker/monitoring/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/paas-docker/monitoring/init.sls
@@ -0,0 +1,28 @@
+# -------------------------------------------------------------
+# Salt — Provision Docker engine
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs with context %}
+
+# -------------------------------------------------------------
+# Platform checks
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+platform-checks:
+ pip.installed
+
+# -------------------------------------------------------------
+# Health check configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{{ dirs.etc }}/monitoring/checks.yml:
+ file.managed:
+ - source: salt://roles/paas-docker/monitoring/files/checks.yml.jinja
+ - makedirs: True
+ - mode: 0644
+ - template: jinja
+ - context:
+ checks: {{ salt['paas_docker.get_health_checks']() }}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 08:57 (11 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259890
Default Alt Text
D2600.id6558.diff (4 KB)
Attached To
Mode
D2600: Configure HTTP health checks monitoring for Docker engines
Attached
Detach File
Event Timeline
Log In to Comment