Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to get docker IP address from Rancher labels for Rancher 1.3 #3265

Merged
merged 9 commits into from
Mar 29, 2017

Conversation

zippolyte
Copy link
Contributor

@zippolyte zippolyte commented Mar 16, 2017

edit by hkaj: linked with DataDog/integrations-core#282

@hkaj
Copy link
Member

hkaj commented Mar 17, 2017

Nice one @zippolyte
As mentioned in the card description (and add rancher labels as tags in SD and the docker check while we're parsing docker labels.) could you also collect interesting labels as tags? Like the rancher service name, etc.
It would also be interesting to add these tags in the docker check (integration-core).

This way users will be able to graph their metrics based on rancher resources.

@@ -171,6 +171,14 @@ def _get_host_address(self, state, c_id, tpl_var):
if pod_ip:
return pod_ip

# try to get the rancher IP address
log.debug("No IP address was found in container %s (%s) "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add if Platform.is_rancher() before this new code? Otherwise this rancher-specific log line will show up in non Rancher environments.

You'll need to create an is_rancher function in platform.py first. One way you could detect rancher is by looking for their agent container(s) (read more about that here).

@@ -290,6 +301,12 @@ def get_tags(self, state, c_id):
if swarm_svc:
tags.append('swarm_service:%s' % swarm_svc)

if Platform.is_rancher():
c_inspect = state.inspect_container(c_id)
service_name = c_inspect.get('Config', {}).get('Labels', {}).get('io.rancher.container.name')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make io.rancher.container.name a constant? It could live here or in dockerutil.

log.debug("No IP address was found in container %s (%s) "
"trying with the Rancher label" % (c_id[:12], c_img))

ip_addr = c_inspect.get('Config', {}).get('Labels', {}).get('io.rancher.container.ip')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make io.rancher.container.ip a constant?

Copy link
Member

@hkaj hkaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM

@hkaj
Copy link
Member

hkaj commented Mar 21, 2017

cool, i like it better too :)

Copy link
Member

@hkaj hkaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zippolyte zippolyte merged commit 480420e into master Mar 29, 2017
@zippolyte zippolyte deleted the hippolyte.henry/docker_ip_rancher branch March 29, 2017 14:41
@hkaj hkaj modified the milestones: 5.12.4, 5.13.0 Apr 12, 2017
@masci masci modified the milestones: 5.12.4, 5.13.0 Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants