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

Fix pod metric filtering for containerd #2283

Merged
merged 1 commit into from
Oct 2, 2018

Conversation

mfpierre
Copy link
Contributor

What does this PR do?

Seems that container_name is empty for pod metrics with containerd runtime causing them to be filtered out.

Motivation

Have pod metrics (like network) correctly submitted for containerd

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

Additional Notes

See containerd/cri#922

@codecov-io
Copy link

codecov-io commented Sep 21, 2018

Codecov Report

Merging #2283 into master will increase coverage by 1.08%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2283      +/-   ##
==========================================
+ Coverage   85.83%   86.92%   +1.08%     
==========================================
  Files         189        8     -181     
  Lines       12646      841   -11805     
  Branches     1325      130    -1195     
==========================================
- Hits        10855      731   -10124     
+ Misses       1408       78    -1330     
+ Partials      383       32     -351

@@ -125,6 +125,10 @@ def _is_pod_metric(labels):
if 'container_name' in labels:
if labels['container_name'] == 'POD':
return True
# Some runtimes does not report container_name="POD"
if 'pod_name' in labels:

Choose a reason for hiding this comment

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

For the metric to be a pod-level one, don't you also need container_name=""? (because all container metrics also have a pod_name label)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, just fixed it

@mfpierre mfpierre force-pushed the mfpierre/fix-pod-metric-filtering branch from 021fab9 to 0626735 Compare September 21, 2018 12:12
@@ -125,6 +125,9 @@ def _is_pod_metric(labels):
if 'container_name' in labels:
if labels['container_name'] == 'POD':
return True
# containerd does not report container_name="POD"
elif labels['container_name'] == '' and 'pod_name' in labels and labels['pod_name']:
Copy link
Member

Choose a reason for hiding this comment

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

or elif labels['container_name'] == '' and labels.get('pod_name', False):?

@mfpierre mfpierre force-pushed the mfpierre/fix-pod-metric-filtering branch from 0626735 to 8bba137 Compare October 2, 2018 10:24
@mfpierre mfpierre force-pushed the mfpierre/fix-pod-metric-filtering branch from 8bba137 to 3ee32b9 Compare October 2, 2018 10:32
Copy link
Contributor

@xvello xvello left a comment

Choose a reason for hiding this comment

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

👍

@mfpierre mfpierre merged commit b033408 into master Oct 2, 2018
@mfpierre mfpierre deleted the mfpierre/fix-pod-metric-filtering branch October 2, 2018 12:21
nmuesch pushed a commit that referenced this pull request Nov 1, 2018
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.

6 participants