diff --git a/dockerplugin.py b/dockerplugin.py index 2a9dc04..379d77b 100755 --- a/dockerplugin.py +++ b/dockerplugin.py @@ -45,6 +45,12 @@ def _c(c): return '{id}/{name}'.format(id=c['Id'][:7], name=c['Name']) +def _d(d): + """Formats a dictionary of key/value pairs as a comma-delimited list of + key=value tokens.""" + return ','.join(['='.join(p) for p in d.items()]) + + class Stats: @classmethod def emit(cls, container, type, value, t=None, type_instance=None): @@ -52,6 +58,10 @@ def emit(cls, container, type, value, t=None, type_instance=None): val.plugin = 'docker' val.plugin_instance = container['Name'] + if container['Labels']: + val.plugin_instance += '[{labels}]' + .format(labels=_d(container['Labels'])) + if type: val.type = type if type_instance: