Skip to content

[docker_daemon] Adding Marathon App Id tag capture for Docker Daemon #2870

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

seeder
Copy link

@seeder seeder commented Sep 29, 2016

What does this PR do?

On Mesos/Marathon managed docker daemons, allows tagging container data with app_id tag used by your Marathon integration, allowing to correlated the data in Dashboards

Motivation

As DevOps integrator, using datadog we would like to have Marathon and docker data correlation.

Sharing the integration with you, as we believe it maybe of use to others.

Testing Guidelines

An overview on testing
is available in our contribution guidelines.

Additional Notes

Feature gets enabled when instance config in docker_daemon.yaml has the include_marathon_app_id set to true
It may not be perfectly within Datadog coding guidelines and feel free to change as required.
Provided as is.

These changes allow including marathon app_id in the reported tags for containers
@seeder seeder changed the title Adding Marathon App Id tag capture for Docker Daemon [docker_daemon] Adding Marathon App Id tag capture for Docker Daemon Sep 29, 2016
@hkaj hkaj self-assigned this Dec 7, 2016
@hkaj hkaj added this to the 5.11.0 milestone Dec 7, 2016
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.

Thanks a lot for contributing @seeder !

The logic and the code are both great, I left a few minor comments to make the code fit more nicely with the check, but nothing major to change.

I have one more request though (sorry about that 😅 ): could you add this parameter to docker_daemon.yaml.example with a short comment to explain what it does? A short extract from your PR description would do the trick.

Thanks again!

@@ -174,6 +174,7 @@ def init(self):
self._disable_net_metrics = False

# Set tagging options
self.include_app_id = instance.get("include_marathon_app_id", False)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking but can you rename this attribute to include_marathon_app_id? App is quite generic, it could be an issue when we add more tags in the future.

@@ -357,6 +358,19 @@ def _get_tags(self, entity=None, tag_type=None):
if entity is not None:
pod_name = None

if self.include_app_id and (tag_type is CONTAINER or tag_type is PERFORMANCE):
self.log.debug("We need to capture Marathon Id")
Copy link
Member

Choose a reason for hiding this comment

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

let's remove this one, debug logs are already spammy enough 😄

if cont_id is not None:
cont_inspected = self.docker_client.inspect_container(cont_id)
for env_var in cont_inspected['Config']['Env']:
self.log.debug("We have env_var : %s" % env_var)
Copy link
Member

Choose a reason for hiding this comment

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

same here

self.log.debug("We have env_var : %s" % env_var)
if 'MARATHON_APP_ID=' in env_var:
app_id = env_var.replace('MARATHON_APP_ID=','')
self.log.debug("We have found the id as %s" % app_id)
Copy link
Member

Choose a reason for hiding this comment

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

This one is cool.
If the tag is missing in Datadog and the logs don't show this line we can display env variables and see what's wrong.

if 'MARATHON_APP_ID=' in env_var:
app_id = env_var.replace('MARATHON_APP_ID=','')
self.log.debug("We have found the id as %s" % app_id)
tags.append("app_id:%s" % app_id)
Copy link
Member

Choose a reason for hiding this comment

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

Same as for the attribute, app_id is quite generic, it will be difficult to make a sense of it in the check as we support many orchestrators besides Marathon. Could you rename it to marathon_app_id please?

@masci masci modified the milestones: 5.11.0, 5.12.0 Jan 24, 2017
@olivielpeau olivielpeau modified the milestones: 5.13.0, 5.12.0 Mar 8, 2017
@masci masci modified the milestones: 5.13.0, 5.14.x Apr 12, 2017
@xvello xvello modified the milestones: 5.15, 5.14 May 26, 2017
@hush-hush hush-hush modified the milestones: 5.16, 5.15 Jul 10, 2017
@truthbk truthbk modified the milestones: 5.16, 5.17 Jul 25, 2017
@olivielpeau olivielpeau added this to the 5.18.0 milestone Aug 18, 2017
@olivielpeau olivielpeau removed this from the 5.17 milestone Aug 18, 2017
@truthbk truthbk modified the milestones: 5.18.0, 5.19.0 Oct 10, 2017
@olivielpeau olivielpeau modified the milestones: 5.19.0, 5.20.0 Oct 31, 2017
@hush-hush hush-hush modified the milestones: 5.20.0, 5.21.0 Nov 13, 2017
@xvello xvello modified the milestones: 5.21.0, Future Dec 27, 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.

7 participants