Skip to content

Commit 6489ae5

Browse files
committed
[docker_daemon] adding whitelist for docker health service checks.
[docker_daemon] whitelist health service checks yaml update. [docker_daemon] whitelist is a set for O(1) average complexity.
1 parent a3019e2 commit 6489ae5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

checks.d/docker_daemon.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ def check(self, instance):
242242

243243
# Report docker healthcheck SC's where available
244244
if health_service_checks:
245-
self._send_container_healthcheck_sc(containers_by_id)
245+
health_scs_whitelist = set(instance.get('health_service_check_whitelist', []))
246+
self._send_container_healthcheck_sc(containers_by_id, health_scs_whitelist)
246247

247248
def _count_and_weigh_images(self):
248249
try:
@@ -477,8 +478,12 @@ def _report_container_size(self, containers_by_id):
477478
self, 'docker.container.size_rootfs', container['SizeRootFs'],
478479
tags=tags)
479480

480-
def _send_container_healthcheck_sc(self, containers_by_id):
481+
def _send_container_healthcheck_sc(self, containers_by_id, whitelist):
482+
"""Send health service checks for containers. Whitelist should preferably be a set."""
481483
for container in containers_by_id.itervalues():
484+
if container.get('Image') not in whitelist:
485+
continue
486+
482487
health = container.get('health', {})
483488
tags = self._get_tags(container, CONTAINER)
484489
status = AgentCheck.UNKNOWN

conf.d/docker_daemon.yaml.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ instances:
5757
# Container Healthchecks are available starting with docker 1.12, enabling with older
5858
# versions will result in an UNKNOWN state for the service check.
5959
#
60+
# You should whitelist the container images you wish to submit health service checks for.
61+
# Example: ["tomcat", "nginx", "etcd"]
62+
#
6063
# health_service_checks: false
64+
# health_service_check_whitelist: []
6165

6266
# Collect images stats
6367
# Number of available active images and intermediate images as gauges.

0 commit comments

Comments
 (0)