{"action":"created","issue":{"url":"https://api.github.com/repos/DataDog/dd-agent/issues/2583","repository_url":"https://api.github.com/repos/DataDog/dd-agent","labels_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2583/labels{/name}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2583/comments","events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2583/events","html_url":"https://github.com/DataDog/dd-agent/pull/2583","id":159276748,"number":2583,"title":"[core] Use datadog_id label for service discovery.","user":{"login":"geowa4","id":136390,"avatar_url":"https://avatars.githubusercontent.com/u/136390?v=3","gravatar_id":"","url":"https://api.github.com/users/geowa4","html_url":"https://github.com/geowa4","followers_url":"https://api.github.com/users/geowa4/followers","following_url":"https://api.github.com/users/geowa4/following{/other_user}","gists_url":"https://api.github.com/users/geowa4/gists{/gist_id}","starred_url":"https://api.github.com/users/geowa4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geowa4/subscriptions","organizations_url":"https://api.github.com/users/geowa4/orgs","repos_url":"https://api.github.com/users/geowa4/repos","events_url":"https://api.github.com/users/geowa4/events{/privacy}","received_events_url":"https://api.github.com/users/geowa4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/DataDog/dd-agent/labels/checks","name":"checks","color":"444444"},{"url":"https://api.github.com/repos/DataDog/dd-agent/labels/community","name":"community","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"hkaj","id":5287287,"avatar_url":"https://avatars.githubusercontent.com/u/5287287?v=3","gravatar_id":"","url":"https://api.github.com/users/hkaj","html_url":"https://github.com/hkaj","followers_url":"https://api.github.com/users/hkaj/followers","following_url":"https://api.github.com/users/hkaj/following{/other_user}","gists_url":"https://api.github.com/users/hkaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hkaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkaj/subscriptions","organizations_url":"https://api.github.com/users/hkaj/orgs","repos_url":"https://api.github.com/users/hkaj/repos","events_url":"https://api.github.com/users/hkaj/events{/privacy}","received_events_url":"https://api.github.com/users/hkaj/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/DataDog/dd-agent/milestones/62","html_url":"https://github.com/DataDog/dd-agent/milestones/Triage","labels_url":"https://api.github.com/repos/DataDog/dd-agent/milestones/62/labels","id":1485890,"number":62,"title":"Triage","description":null,"creator":{"login":"remh","id":1311477,"avatar_url":"https://avatars.githubusercontent.com/u/1311477?v=3","gravatar_id":"","url":"https://api.github.com/users/remh","html_url":"https://github.com/remh","followers_url":"https://api.github.com/users/remh/followers","following_url":"https://api.github.com/users/remh/following{/other_user}","gists_url":"https://api.github.com/users/remh/gists{/gist_id}","starred_url":"https://api.github.com/users/remh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remh/subscriptions","organizations_url":"https://api.github.com/users/remh/orgs","repos_url":"https://api.github.com/users/remh/repos","events_url":"https://api.github.com/users/remh/events{/privacy}","received_events_url":"https://api.github.com/users/remh/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":12,"state":"open","created_at":"2016-01-05T21:06:49Z","updated_at":"2016-06-09T14:12:53Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2016-06-08T21:26:57Z","updated_at":"2016-06-10T12:51:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/2583","html_url":"https://github.com/DataDog/dd-agent/pull/2583","diff_url":"https://github.com/DataDog/dd-agent/pull/2583.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/2583.patch"},"body":"This still falls back to parsing the image name when this label is not\r\npresent.\r\n\r\nI created this as a result of #2576 and my conversation with support."},"comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments/225173662","html_url":"https://github.com/DataDog/dd-agent/pull/2583#issuecomment-225173662","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/2583","id":225173662,"user":{"login":"geowa4","id":136390,"avatar_url":"https://avatars.githubusercontent.com/u/136390?v=3","gravatar_id":"","url":"https://api.github.com/users/geowa4","html_url":"https://github.com/geowa4","followers_url":"https://api.github.com/users/geowa4/followers","following_url":"https://api.github.com/users/geowa4/following{/other_user}","gists_url":"https://api.github.com/users/geowa4/gists{/gist_id}","starred_url":"https://api.github.com/users/geowa4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geowa4/subscriptions","organizations_url":"https://api.github.com/users/geowa4/orgs","repos_url":"https://api.github.com/users/geowa4/repos","events_url":"https://api.github.com/users/geowa4/events{/privacy}","received_events_url":"https://api.github.com/users/geowa4/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T12:51:52Z","updated_at":"2016-06-10T12:51:52Z","body":"The effect of my proposed change:\r\n```\r\n$ python\r\nPython 2.7.11 (default, Dec  5 2015, 20:44:19)\r\n[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> from utils.dockerutil import DockerUtil\r\n>>> docker_client = DockerUtil().client\r\n>>> docker_client.containers()\r\n[{u'Status': u'Up 45 hours', u'Created': 1465399125, u'Image': u'nginx', u'Labels': {u'datadog_id': u'custom-nginx'}, u'NetworkSettings': {u'Networks': {u'bridge': {u'NetworkID': u'', u'MacAddress': u'', u'GlobalIPv6PrefixLen': 0, u'Links': None, u'GlobalIPv6Address': u'', u'IPv6Gateway': u'', u'IPAMConfig': None, u'EndpointID': u'', u'IPPrefixLen': 16, u'IPAddress': u'172.17.0.2', u'Gateway': u'172.17.0.1', u'Aliases': None}}}, u'HostConfig': {u'NetworkMode': u'default'}, u'ImageID': u'sha256:6f8d099c3adc0f9c14bdc11d6c698a647c2f0457aa1ae76a592d6f7dc9bdb5b8', u'State': u'running', u'Command': u\"nginx -g 'daemon off;'\", u'Names': [u'/stoic_allen'], u'Mounts': [], u'Id': u'445272bc04e4ad5f0d0a480e7a56af36aeef57053601835ef3579d98cdf3e567', u'Ports': [{u'IP': u'0.0.0.0', u'Type': u'tcp', u'PublicPort': 32770, u'PrivatePort': 443}, {u'IP': u'0.0.0.0', u'Type': u'tcp', u'PublicPort': 32771, u'PrivatePort': 80}]}]\r\n>>> docker_client.containers()[0].get('Image').split(':')[0].split('/')[-1]\r\nu'nginx'\r\n>>> docker_client.containers()[0].get('Labels', {}).get('datadog_id')\r\nu'custom-nginx'\r\n```\r\n\r\nThe `container` dictionary also has a `Labels` key that is a dictionary of all labels applied to the container. My change simply looks for a key `datadog_id` in that dictionary. If it does not exist, it falls back to the equivalent of the original code which uses the `Image` key."}}
{"actor":{"display_login":"geowa4"}}