Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7d180b33
Commit
7d180b33
authored
Dec 22, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record pleg pod relist interval and latency
Relisting latency/interval affects how quick kubelet discovers changes. Record the metrics in Prometheus to surface such information.
parent
4606171a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
metrics.go
pkg/kubelet/metrics/metrics.go
+18
-0
generic.go
pkg/kubelet/pleg/generic.go
+14
-0
kubelet_metrics.go
pkg/metrics/kubelet_metrics.go
+6
-0
No files found.
pkg/kubelet/metrics/metrics.go
View file @
7d180b33
...
@@ -35,6 +35,8 @@ const (
...
@@ -35,6 +35,8 @@ const (
DockerOperationsKey
=
"docker_operations_latency_microseconds"
DockerOperationsKey
=
"docker_operations_latency_microseconds"
DockerErrorsKey
=
"docker_errors"
DockerErrorsKey
=
"docker_errors"
PodWorkerStartLatencyKey
=
"pod_worker_start_latency_microseconds"
PodWorkerStartLatencyKey
=
"pod_worker_start_latency_microseconds"
PLEGRelistLatencyKey
=
"pleg_relist_latency_microseconds"
PLEGRelistIntervalKey
=
"pleg_relist_interval_microseconds"
)
)
var
(
var
(
...
@@ -105,6 +107,20 @@ var (
...
@@ -105,6 +107,20 @@ var (
},
},
[]
string
{
"operation_type"
},
[]
string
{
"operation_type"
},
)
)
PLEGRelistLatency
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Subsystem
:
KubeletSubsystem
,
Name
:
PLEGRelistLatencyKey
,
Help
:
"Latency in microseconds for relisting pods in PLEG."
,
},
)
PLEGRelistInterval
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Subsystem
:
KubeletSubsystem
,
Name
:
PLEGRelistIntervalKey
,
Help
:
"Interval in microseconds between relisting in PLEG."
,
},
)
)
)
var
registerMetrics
sync
.
Once
var
registerMetrics
sync
.
Once
...
@@ -123,6 +139,8 @@ func Register(containerCache kubecontainer.RuntimeCache) {
...
@@ -123,6 +139,8 @@ func Register(containerCache kubecontainer.RuntimeCache) {
prometheus
.
MustRegister
(
ContainersPerPodCount
)
prometheus
.
MustRegister
(
ContainersPerPodCount
)
prometheus
.
MustRegister
(
DockerErrors
)
prometheus
.
MustRegister
(
DockerErrors
)
prometheus
.
MustRegister
(
newPodAndContainerCollector
(
containerCache
))
prometheus
.
MustRegister
(
newPodAndContainerCollector
(
containerCache
))
prometheus
.
MustRegister
(
PLEGRelistLatency
)
prometheus
.
MustRegister
(
PLEGRelistInterval
)
})
})
}
}
...
...
pkg/kubelet/pleg/generic.go
View file @
7d180b33
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
)
)
...
@@ -50,6 +51,8 @@ type GenericPLEG struct {
...
@@ -50,6 +51,8 @@ type GenericPLEG struct {
eventChannel
chan
*
PodLifecycleEvent
eventChannel
chan
*
PodLifecycleEvent
// The internal cache for container information.
// The internal cache for container information.
containers
map
[
string
]
containerInfo
containers
map
[
string
]
containerInfo
// Time of the last relisting.
lastRelistTime
time
.
Time
}
}
type
containerInfo
struct
{
type
containerInfo
struct
{
...
@@ -101,6 +104,17 @@ func generateEvent(podID types.UID, cid string, oldState, newState kubecontainer
...
@@ -101,6 +104,17 @@ func generateEvent(podID types.UID, cid string, oldState, newState kubecontainer
// with the internal pods/containers, and generats events accordingly.
// with the internal pods/containers, and generats events accordingly.
func
(
g
*
GenericPLEG
)
relist
()
{
func
(
g
*
GenericPLEG
)
relist
()
{
glog
.
V
(
5
)
.
Infof
(
"GenericPLEG: Relisting"
)
glog
.
V
(
5
)
.
Infof
(
"GenericPLEG: Relisting"
)
timestamp
:=
time
.
Now
()
if
!
g
.
lastRelistTime
.
IsZero
()
{
metrics
.
PLEGRelistInterval
.
Observe
(
metrics
.
SinceInMicroseconds
(
g
.
lastRelistTime
))
}
defer
func
()
{
// Update the relist time.
g
.
lastRelistTime
=
timestamp
metrics
.
PLEGRelistLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
timestamp
))
}()
// Get all the pods.
// Get all the pods.
pods
,
err
:=
g
.
runtime
.
GetPods
(
true
)
pods
,
err
:=
g
.
runtime
.
GetPods
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/metrics/kubelet_metrics.go
View file @
7d180b33
...
@@ -74,6 +74,12 @@ var KnownKubeletMetrics = map[string][]string{
...
@@ -74,6 +74,12 @@ var KnownKubeletMetrics = map[string][]string{
"kubelet_generate_pod_status_latency_microseconds"
:
{
"quantile"
},
"kubelet_generate_pod_status_latency_microseconds"
:
{
"quantile"
},
"kubelet_generate_pod_status_latency_microseconds_count"
:
{},
"kubelet_generate_pod_status_latency_microseconds_count"
:
{},
"kubelet_generate_pod_status_latency_microseconds_sum"
:
{},
"kubelet_generate_pod_status_latency_microseconds_sum"
:
{},
"kubelet_pleg_relist_latency_microseconds"
:
{
"quantile"
},
"kubelet_pleg_relist_latency_microseconds_sum"
:
{},
"kubelet_pleg_relist_latency_microseconds_count"
:
{},
"kubelet_pleg_relist_interval_microseconds"
:
{
"quantile"
},
"kubelet_pleg_relist_interval_microseconds_sum"
:
{},
"kubelet_pleg_relist_interval_microseconds_count"
:
{},
"kubelet_pod_start_latency_microseconds"
:
{
"quantile"
},
"kubelet_pod_start_latency_microseconds"
:
{
"quantile"
},
"kubelet_pod_start_latency_microseconds_count"
:
{},
"kubelet_pod_start_latency_microseconds_count"
:
{},
"kubelet_pod_start_latency_microseconds_sum"
:
{},
"kubelet_pod_start_latency_microseconds_sum"
:
{},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment