Skip to content

Commit

Permalink
[docker_daemon] adding whitelist for docker health service checks.
Browse files Browse the repository at this point in the history
[docker_daemon] whitelist health service checks yaml update.

[docker_daemon] whitelist is a set for O(1) average complexity.
  • Loading branch information
truthbk committed Nov 10, 2016
1 parent 99bedbe commit 95b886c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions checks.d/docker_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def check(self, instance):

# Report docker healthcheck SC's where available
if health_service_checks:
self._send_container_healthcheck_sc(containers_by_id)
health_scs_whitelist = set(instance.get('health_service_check_whitelist', []))
self._send_container_healthcheck_sc(containers_by_id, health_scs_whitelist)

def _count_and_weigh_images(self):
try:
Expand Down Expand Up @@ -521,8 +522,12 @@ def _report_container_size(self, containers_by_id):
self, 'docker.container.size_rootfs', container['SizeRootFs'],
tags=tags)

def _send_container_healthcheck_sc(self, containers_by_id):
def _send_container_healthcheck_sc(self, containers_by_id, whitelist):
"""Send health service checks for containers. Whitelist should preferably be a set."""
for container in containers_by_id.itervalues():
if container.get('Image') not in whitelist:
continue

health = container.get('health', {})
tags = self._get_tags(container, CONTAINER)
status = AgentCheck.UNKNOWN
Expand Down
4 changes: 4 additions & 0 deletions conf.d/docker_daemon.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ instances:
# Container Healthchecks are available starting with docker 1.12, enabling with older
# versions will result in an UNKNOWN state for the service check.
#
# You should whitelist the container images you wish to submit health service checks for.
# Example: ["tomcat", "nginx", "etcd"]
#
# health_service_checks: false
# health_service_check_whitelist: []

# Collect images stats
# Number of available active images and intermediate images as gauges.
Expand Down

0 comments on commit 95b886c

Please sign in to comment.