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
9fd99a48
Commit
9fd99a48
authored
Jan 02, 2019
by
danielqsj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change kubelet metrics to conform guideline
parent
2de487c9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
30 additions
and
16 deletions
+30
-16
cgroup_manager_linux.go
pkg/kubelet/cm/cgroup_manager_linux.go
+6
-3
manager.go
pkg/kubelet/cm/devicemanager/manager.go
+3
-1
eviction_manager.go
pkg/kubelet/eviction/eviction_manager.go
+2
-1
kubelet.go
pkg/kubelet/kubelet.go
+6
-3
instrumented_services.go
pkg/kubelet/kuberuntime/instrumented_services.go
+4
-1
instrumented_services_test.go
pkg/kubelet/kuberuntime/instrumented_services_test.go
+2
-2
metrics.go
pkg/kubelet/metrics/metrics.go
+0
-0
generic.go
pkg/kubelet/pleg/generic.go
+4
-2
metrics_util.go
test/e2e/framework/metrics_util.go
+3
-3
No files found.
pkg/kubelet/cm/cgroup_manager_linux.go
View file @
9fd99a48
...
...
@@ -284,7 +284,8 @@ func (m *cgroupManagerImpl) Exists(name CgroupName) bool {
func
(
m
*
cgroupManagerImpl
)
Destroy
(
cgroupConfig
*
CgroupConfig
)
error
{
start
:=
time
.
Now
()
defer
func
()
{
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"destroy"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"destroy"
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedCgroupManagerLatency
.
WithLabelValues
(
"destroy"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
cgroupPaths
:=
m
.
buildCgroupPaths
(
cgroupConfig
.
Name
)
...
...
@@ -411,7 +412,8 @@ func (m *cgroupManagerImpl) toResources(resourceConfig *ResourceConfig) *libcont
func
(
m
*
cgroupManagerImpl
)
Update
(
cgroupConfig
*
CgroupConfig
)
error
{
start
:=
time
.
Now
()
defer
func
()
{
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"update"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"update"
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedCgroupManagerLatency
.
WithLabelValues
(
"update"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
// Extract the cgroup resource parameters
...
...
@@ -446,7 +448,8 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
func
(
m
*
cgroupManagerImpl
)
Create
(
cgroupConfig
*
CgroupConfig
)
error
{
start
:=
time
.
Now
()
defer
func
()
{
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"create"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
CgroupManagerLatency
.
WithLabelValues
(
"create"
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedCgroupManagerLatency
.
WithLabelValues
(
"create"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
resources
:=
m
.
toResources
(
cgroupConfig
.
ResourceParameters
)
...
...
pkg/kubelet/cm/devicemanager/manager.go
View file @
9fd99a48
...
...
@@ -354,6 +354,7 @@ func (m *ManagerImpl) Allocate(node *schedulernodeinfo.NodeInfo, attrs *lifecycl
func
(
m
*
ManagerImpl
)
Register
(
ctx
context
.
Context
,
r
*
pluginapi
.
RegisterRequest
)
(
*
pluginapi
.
Empty
,
error
)
{
klog
.
Infof
(
"Got registration request from device plugin with resource name %q"
,
r
.
ResourceName
)
metrics
.
DevicePluginRegistrationCount
.
WithLabelValues
(
r
.
ResourceName
)
.
Inc
()
metrics
.
DeprecatedDevicePluginRegistrationCount
.
WithLabelValues
(
r
.
ResourceName
)
.
Inc
()
var
versionCompatible
bool
for
_
,
v
:=
range
pluginapi
.
SupportedVersions
{
if
r
.
Version
==
v
{
...
...
@@ -696,7 +697,8 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
// in a passed in AllocateRequest pointer, and issues a single Allocate call per pod.
klog
.
V
(
3
)
.
Infof
(
"Making allocation request for devices %v for device plugin %s"
,
devs
,
resource
)
resp
,
err
:=
eI
.
e
.
allocate
(
devs
)
metrics
.
DevicePluginAllocationLatency
.
WithLabelValues
(
resource
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
startRPCTime
))
metrics
.
DevicePluginAllocationLatency
.
WithLabelValues
(
resource
)
.
Observe
(
metrics
.
SinceInSeconds
(
startRPCTime
))
metrics
.
DeprecatedDevicePluginAllocationLatency
.
WithLabelValues
(
resource
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
startRPCTime
))
if
err
!=
nil
{
// In case of allocation failure, we want to restore m.allocatedDevices
// to the actual allocated state from m.podDevices.
...
...
pkg/kubelet/eviction/eviction_manager.go
View file @
9fd99a48
...
...
@@ -361,7 +361,8 @@ func (m *managerImpl) synchronize(diskInfoProvider DiskInfoProvider, podFunc Act
for
_
,
t
:=
range
thresholds
{
timeObserved
:=
observations
[
t
.
Signal
]
.
time
if
!
timeObserved
.
IsZero
()
{
metrics
.
EvictionStatsAge
.
WithLabelValues
(
string
(
t
.
Signal
))
.
Observe
(
metrics
.
SinceInMicroseconds
(
timeObserved
.
Time
))
metrics
.
EvictionStatsAge
.
WithLabelValues
(
string
(
t
.
Signal
))
.
Observe
(
metrics
.
SinceInSeconds
(
timeObserved
.
Time
))
metrics
.
DeprecatedEvictionStatsAge
.
WithLabelValues
(
string
(
t
.
Signal
))
.
Observe
(
metrics
.
SinceInMicroseconds
(
timeObserved
.
Time
))
}
}
...
...
pkg/kubelet/kubelet.go
View file @
9fd99a48
...
...
@@ -1500,7 +1500,8 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
if
!
firstSeenTime
.
IsZero
()
{
// This is the first time we are syncing the pod. Record the latency
// since kubelet first saw the pod if firstSeenTime is set.
metrics
.
PodWorkerStartLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
firstSeenTime
))
metrics
.
PodWorkerStartLatency
.
Observe
(
metrics
.
SinceInSeconds
(
firstSeenTime
))
metrics
.
DeprecatedPodWorkerStartLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
firstSeenTime
))
}
else
{
klog
.
V
(
3
)
.
Infof
(
"First seen time not recorded for pod %q"
,
pod
.
UID
)
}
...
...
@@ -1517,7 +1518,8 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
existingStatus
,
ok
:=
kl
.
statusManager
.
GetPodStatus
(
pod
.
UID
)
if
!
ok
||
existingStatus
.
Phase
==
v1
.
PodPending
&&
apiPodStatus
.
Phase
==
v1
.
PodRunning
&&
!
firstSeenTime
.
IsZero
()
{
metrics
.
PodStartLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
firstSeenTime
))
metrics
.
PodStartLatency
.
Observe
(
metrics
.
SinceInSeconds
(
firstSeenTime
))
metrics
.
DeprecatedPodStartLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
firstSeenTime
))
}
runnable
:=
kl
.
canRunPod
(
pod
)
...
...
@@ -1996,7 +1998,8 @@ func (kl *Kubelet) dispatchWork(pod *v1.Pod, syncType kubetypes.SyncPodType, mir
UpdateType
:
syncType
,
OnCompleteFunc
:
func
(
err
error
)
{
if
err
!=
nil
{
metrics
.
PodWorkerLatency
.
WithLabelValues
(
syncType
.
String
())
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
PodWorkerLatency
.
WithLabelValues
(
syncType
.
String
())
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedPodWorkerLatency
.
WithLabelValues
(
syncType
.
String
())
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}
},
})
...
...
pkg/kubelet/kuberuntime/instrumented_services.go
View file @
9fd99a48
...
...
@@ -49,13 +49,16 @@ func newInstrumentedImageManagerService(service internalapi.ImageManagerService)
// recordOperation records the duration of the operation.
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
metrics
.
RuntimeOperations
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
RuntimeOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
DeprecatedRuntimeOperations
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
RuntimeOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedRuntimeOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}
// recordError records error for metric if an error occurred.
func
recordError
(
operation
string
,
err
error
)
{
if
err
!=
nil
{
metrics
.
RuntimeOperationsErrors
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DeprecatedRuntimeOperationsErrors
.
WithLabelValues
(
operation
)
.
Inc
()
}
}
...
...
pkg/kubelet/kuberuntime/instrumented_services_test.go
View file @
9fd99a48
...
...
@@ -50,8 +50,8 @@ func TestRecordOperation(t *testing.T) {
}()
recordOperation
(
"create_container"
,
time
.
Now
())
runtimeOperationsCounterExpected
:=
"kubelet_runtime_operations{operation_type=
\"
create_container
\"
} 1"
runtimeOperationsLatencyExpected
:=
"kubelet_runtime_operations_latency_
micro
seconds_count{operation_type=
\"
create_container
\"
} 1"
runtimeOperationsCounterExpected
:=
"kubelet_runtime_operations
_total
{operation_type=
\"
create_container
\"
} 1"
runtimeOperationsLatencyExpected
:=
"kubelet_runtime_operations_latency_seconds_count{operation_type=
\"
create_container
\"
} 1"
assert
.
HTTPBodyContains
(
t
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
mux
.
ServeHTTP
(
w
,
r
)
...
...
pkg/kubelet/metrics/metrics.go
View file @
9fd99a48
This diff is collapsed.
Click to expand it.
pkg/kubelet/pleg/generic.go
View file @
9fd99a48
...
...
@@ -189,12 +189,14 @@ func (g *GenericPLEG) relist() {
klog
.
V
(
5
)
.
Infof
(
"GenericPLEG: Relisting"
)
if
lastRelistTime
:=
g
.
getRelistTime
();
!
lastRelistTime
.
IsZero
()
{
metrics
.
PLEGRelistInterval
.
Observe
(
metrics
.
SinceInMicroseconds
(
lastRelistTime
))
metrics
.
PLEGRelistInterval
.
Observe
(
metrics
.
SinceInSeconds
(
lastRelistTime
))
metrics
.
DeprecatedPLEGRelistInterval
.
Observe
(
metrics
.
SinceInMicroseconds
(
lastRelistTime
))
}
timestamp
:=
g
.
clock
.
Now
()
defer
func
()
{
metrics
.
PLEGRelistLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
timestamp
))
metrics
.
PLEGRelistLatency
.
Observe
(
metrics
.
SinceInSeconds
(
timestamp
))
metrics
.
DeprecatedPLEGRelistLatency
.
Observe
(
metrics
.
SinceInMicroseconds
(
timestamp
))
}()
// Get all the pods.
...
...
test/e2e/framework/metrics_util.go
View file @
9fd99a48
...
...
@@ -168,9 +168,9 @@ var InterestingKubeletMetrics = []string{
"kubelet_docker_errors"
,
"kubelet_docker_operations_latency_seconds"
,
"kubelet_generate_pod_status_latency_microseconds"
,
"kubelet_pod_start_latency_
micro
seconds"
,
"kubelet_pod_worker_latency_
micro
seconds"
,
"kubelet_pod_worker_start_latency_
micro
seconds"
,
"kubelet_pod_start_latency_seconds"
,
"kubelet_pod_worker_latency_seconds"
,
"kubelet_pod_worker_start_latency_seconds"
,
"kubelet_sync_pods_latency_microseconds"
,
}
...
...
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