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

pkg/kubelet/logs: Add container log size metric #70749

Merged
merged 1 commit into from Nov 13, 2018

Conversation

@brancz
Copy link
Member

brancz commented Nov 7, 2018

What type of PR is this?

/kind feature

What this PR does / why we need it:

Unless an additional DaemonSet that has the same permissions as the kubelet is deployed there is currently no way to monitor the size and thus the amount of logs written by a Kubernetes cluster's pods/containers.

Special notes for your reviewer:

This is not technically a feature, but more of a small enhancement for monitoring logs, in my opinion it should be fine to merge for 1.13 as long as it merges until code-freeze.

Does this PR introduce a user-facing change?:

Not an end-user facing change, but an additional metrics to be used for monitoring by cluster admins.

Add `kubelet_container_log_size_bytes` metric representing the log file size of a container.

/sig instrumentation

@kubernetes/sig-instrumentation-pr-reviews
@kubernetes/sig-node-pr-reviews

@derekwaynecarr

This comment has been minimized.

Copy link
Member

derekwaynecarr commented Nov 7, 2018

/assign @derekwaynecarr

i am wondering why we would not put some of this logic in cri stats provider so we can avoid listing containers all over code base, i need to take a deeper look to know pros/cons.

}
podMetadata := pod.GetMetadata()

ch <- prometheus.MustNewConstMetric(descLogSize, prometheus.GaugeValue, float64(info.Size()), podMetadata.GetNamespace(), podMetadata.GetName(), container.GetMetadata().GetName(), id)

This comment has been minimized.

@metalmatze

metalmatze Nov 7, 2018

small nit: would you mind putting this across multiple lines? Thanks.

@brancz

This comment has been minimized.

Copy link
Member

brancz commented Nov 7, 2018

I did indeed find something in the cri stats provider so I will rework this PR to reuse that logic.

@brancz brancz force-pushed the brancz:log-metrics branch 3 times, most recently from d798814 to 553a574 Nov 7, 2018

@derekwaynecarr
Copy link
Member

derekwaynecarr left a comment

a structural change, otherwise this is good for me.

@@ -711,6 +712,8 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
runtimeService,
imageService,
stats.NewLogMetricsService())

prometheus.MustRegister(klet.StatsProvider.Collector())

This comment has been minimized.

@derekwaynecarr

derekwaynecarr Nov 9, 2018

Member

typically, we have put registration of collectors under kubelet/metrics/metrics.go, see the Register function there.

Can you move this under initializeModules where it calls metrics.Register and pass in the additional collector?

@brancz brancz force-pushed the brancz:log-metrics branch from 553a574 to 194e172 Nov 9, 2018

@brancz brancz force-pushed the brancz:log-metrics branch from 194e172 to beb8562 Nov 9, 2018

@brancz brancz force-pushed the brancz:log-metrics branch from beb8562 to a00179d Nov 9, 2018

@brancz

This comment has been minimized.

Copy link
Member

brancz commented Nov 12, 2018

/retest

@brancz brancz force-pushed the brancz:log-metrics branch from a00179d to 4724fca Nov 12, 2018

@brancz

This comment has been minimized.

Copy link
Member

brancz commented Nov 13, 2018

/test pull-kubernetes-local-e2e-containerized

@nikopen

This comment has been minimized.

Copy link
Member

nikopen commented Nov 13, 2018

/milestone v1.13

/priority important-soon

@k8s-ci-robot k8s-ci-robot added this to the v1.13 milestone Nov 13, 2018

@derekwaynecarr

This comment has been minimized.

Copy link
Member

derekwaynecarr commented Nov 13, 2018

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm label Nov 13, 2018

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Nov 13, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brancz, derekwaynecarr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 67b7d97 into kubernetes:master Nov 13, 2018

18 checks passed

cla/linuxfoundation brancz authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gke Skipped
pull-kubernetes-e2e-kops-aws Job succeeded.
Details
pull-kubernetes-e2e-kubeadm-gce Skipped
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped
pull-kubernetes-local-e2e-containerized Job succeeded.
Details
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
tide In merge pool.
Details

@brancz brancz deleted the brancz:log-metrics branch Nov 13, 2018

@Random-Liu Random-Liu referenced this pull request Nov 17, 2018

Merged

Fix kubelet panic. #71166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment