Skip to content

Add conntrack basic metrics to the network integration.#2981

Merged
gzussa merged 7 commits into
DataDog:masterfrom
aerostitch:conntrack
Feb 14, 2019
Merged

Add conntrack basic metrics to the network integration.#2981
gzussa merged 7 commits into
DataDog:masterfrom
aerostitch:conntrack

Conversation

@aerostitch

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the conntrack count and the conntrack table max capacity metrics in the standard network integration.

Motivation

This is something that we have been doing in custom and that was started a while back in DataDog/dd-agent#1904 by someone else but never finished.
We need those metrics in general to monitor our conntrack tables that sometimes get full and start generating issues.

Review checklist

  • PR has a meaningful title or PR has the no-changelog label attached
  • Feature or bugfix has tests
  • Git history is clean
  • If PR impacts documentation, docs team has been notified or an issue has been opened on the documentation repo
  • If PR adds a configuration option, it has been added to the configuration file.

Thanks for your time,
Joseph

@codecov-io

codecov-io commented Jan 22, 2019

Copy link
Copy Markdown

Codecov Report

Merging #2981 into master will decrease coverage by 16.51%.
The diff coverage is 55.55%.

@@             Coverage Diff             @@
##           master    #2981       +/-   ##
===========================================
- Coverage    84.9%   68.39%   -16.52%     
===========================================
  Files         665        4      -661     
  Lines       36455      386    -36069     
  Branches     4337       71     -4266     
===========================================
- Hits        30953      264    -30689     
+ Misses       4224      100     -4124     
+ Partials     1278       22     -1256

@aerostitch

Copy link
Copy Markdown
Contributor Author

Sorry I just noticed the job was failing.
Do you need me to squash the commits or you're fine using a "squash and merge" when merging the PR?
Thanks!

@gzussa gzussa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @aerostitch This looks really good. I just have one question below out of curiosity and minor comments.

conntrack_count += conntrack_buffer.count('\n')
self.gauge('system.net.conntrack.count', conntrack_count, tags=custom_tags)
except IOError:
self.log.debug("Unable to read %s. Skipping conntrack metrics pull.", proc_conntrack_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, should we change conntrack to nf_conntrack like formatted below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason I didn't put nf_conntrack is that one of the enhancements could be to also have separate count for ipv4 and ipv6 which would result in metrics looking like:

  • system.net.conntrack.count => totall conntrack count
  • system.net.conntrack.ipv4.count => total conntrack count for ipv4 connections only
  • system.net.conntrack.ipv6.count => total conntrack count for ipv6 connections only

But if you prefer I can use nf_conntrack, just let me know if an enhancement like that would make sense or if we should rather put the ipv4 conntrack in system.net.ipv4.conntrack.count in which case system.net.nf_conntrack.count would probably make more sense. I have no preference at this point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the details explanation 😄. I like your reasoning. Is adding the ipv4/ipv6 logic something you want to do with this PR? I love the idea to be honest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No I'd rather keep the 1st one as basic as possible for now. The split ipv4/ipv6 might be a bit trickier to do because depending on the systems they might not be in the same files.
So I'd rather do a separate PR for that.

# Starting at 0 as the last line has a line return
conntrack_count = 0
while 1:
conntrack_buffer = conntrack_file.read(65536)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why 65536?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It just reads the file by chunks of 64k to avoid loading too much data into memory at once. Random choice. Do you have a preference in terms of buffer size?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok. let's add one comment line so we know why long term :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread network/datadog_checks/network/network.py
@aerostitch

Copy link
Copy Markdown
Contributor Author

Hi @gzussa,
Thanks for your review! I replied to your comments. Let me know what you think.
Thanks,
Joseph

@gzussa
gzussa merged commit a07a4f9 into DataDog:master Feb 14, 2019
@aerostitch
aerostitch deleted the conntrack branch February 19, 2019 02:11
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.

3 participants