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
ae450686
Unverified
Commit
ae450686
authored
Feb 06, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72323 from danielqsj/dockershim
Change docker metrics to conform metrics guidelines
parents
939f8ffa
7aef2efe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
14 deletions
+97
-14
instrumented_client.go
pkg/kubelet/dockershim/libdocker/instrumented_client.go
+5
-1
metrics.go
pkg/kubelet/dockershim/metrics/metrics.go
+65
-7
metrics.go
pkg/kubelet/dockershim/network/metrics/metrics.go
+24
-4
plugins.go
pkg/kubelet/dockershim/network/plugins.go
+2
-1
metrics_util.go
test/e2e/framework/metrics_util.go
+1
-1
No files found.
pkg/kubelet/dockershim/libdocker/instrumented_client.go
View file @
ae450686
...
@@ -42,7 +42,9 @@ func NewInstrumentedInterface(dockerClient Interface) Interface {
...
@@ -42,7 +42,9 @@ func NewInstrumentedInterface(dockerClient Interface) Interface {
// recordOperation records the duration of the operation.
// recordOperation records the duration of the operation.
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
metrics
.
DockerOperations
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DockerOperations
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
DeprecatedDockerOperations
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedDockerOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}
}
// recordError records error for metric if an error occurred.
// recordError records error for metric if an error occurred.
...
@@ -50,9 +52,11 @@ func recordError(operation string, err error) {
...
@@ -50,9 +52,11 @@ func recordError(operation string, err error) {
if
err
!=
nil
{
if
err
!=
nil
{
if
_
,
ok
:=
err
.
(
operationTimeout
);
ok
{
if
_
,
ok
:=
err
.
(
operationTimeout
);
ok
{
metrics
.
DockerOperationsTimeout
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DockerOperationsTimeout
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DeprecatedDockerOperationsTimeout
.
WithLabelValues
(
operation
)
.
Inc
()
}
}
// Docker operation timeout error is also a docker error, so we don't add else here.
// Docker operation timeout error is also a docker error, so we don't add else here.
metrics
.
DockerOperationsErrors
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DockerOperationsErrors
.
WithLabelValues
(
operation
)
.
Inc
()
metrics
.
DeprecatedDockerOperationsErrors
.
WithLabelValues
(
operation
)
.
Inc
()
}
}
}
}
...
...
pkg/kubelet/dockershim/metrics/metrics.go
View file @
ae450686
...
@@ -25,13 +25,22 @@ import (
...
@@ -25,13 +25,22 @@ import (
const
(
const
(
// DockerOperationsKey is the key for docker operation metrics.
// DockerOperationsKey is the key for docker operation metrics.
DockerOperationsKey
=
"docker_operations"
DockerOperationsKey
=
"docker_operations
_total
"
// DockerOperationsLatencyKey is the key for the operation latency metrics.
// DockerOperationsLatencyKey is the key for the operation latency metrics.
DockerOperationsLatencyKey
=
"docker_operations_latency_
micro
seconds"
DockerOperationsLatencyKey
=
"docker_operations_latency_seconds"
// DockerOperationsErrorsKey is the key for the operation error metrics.
// DockerOperationsErrorsKey is the key for the operation error metrics.
DockerOperationsErrorsKey
=
"docker_operations_errors"
DockerOperationsErrorsKey
=
"docker_operations_errors
_total
"
// DockerOperationsTimeoutKey is the key for the operation timeout metrics.
// DockerOperationsTimeoutKey is the key for the operation timeout metrics.
DockerOperationsTimeoutKey
=
"docker_operations_timeout"
DockerOperationsTimeoutKey
=
"docker_operations_timeout_total"
// DeprecatedDockerOperationsKey is the deprecated key for docker operation metrics.
DeprecatedDockerOperationsKey
=
"docker_operations"
// DeprecatedDockerOperationsLatencyKey is the deprecated key for the operation latency metrics.
DeprecatedDockerOperationsLatencyKey
=
"docker_operations_latency_microseconds"
// DeprecatedDockerOperationsErrorsKey is the deprecated key for the operation error metrics.
DeprecatedDockerOperationsErrorsKey
=
"docker_operations_errors"
// DeprecatedDockerOperationsTimeoutKey is the deprecated key for the operation timeout metrics.
DeprecatedDockerOperationsTimeoutKey
=
"docker_operations_timeout"
// Keep the "kubelet" subsystem for backward compatibility.
// Keep the "kubelet" subsystem for backward compatibility.
kubeletSubsystem
=
"kubelet"
kubeletSubsystem
=
"kubelet"
...
@@ -40,11 +49,12 @@ const (
...
@@ -40,11 +49,12 @@ const (
var
(
var
(
// DockerOperationsLatency collects operation latency numbers by operation
// DockerOperationsLatency collects operation latency numbers by operation
// type.
// type.
DockerOperationsLatency
=
prometheus
.
New
Summary
Vec
(
DockerOperationsLatency
=
prometheus
.
New
Histogram
Vec
(
prometheus
.
Summary
Opts
{
prometheus
.
Histogram
Opts
{
Subsystem
:
kubeletSubsystem
,
Subsystem
:
kubeletSubsystem
,
Name
:
DockerOperationsLatencyKey
,
Name
:
DockerOperationsLatencyKey
,
Help
:
"Latency in microseconds of Docker operations. Broken down by operation type."
,
Help
:
"Latency in seconds of Docker operations. Broken down by operation type."
,
Buckets
:
prometheus
.
DefBuckets
,
},
},
[]
string
{
"operation_type"
},
[]
string
{
"operation_type"
},
)
)
...
@@ -76,6 +86,45 @@ var (
...
@@ -76,6 +86,45 @@ var (
},
},
[]
string
{
"operation_type"
},
[]
string
{
"operation_type"
},
)
)
// DeprecatedDockerOperationsLatency collects operation latency numbers by operation
// type.
DeprecatedDockerOperationsLatency
=
prometheus
.
NewSummaryVec
(
prometheus
.
SummaryOpts
{
Subsystem
:
kubeletSubsystem
,
Name
:
DeprecatedDockerOperationsLatencyKey
,
Help
:
"(Deprecated) Latency in microseconds of Docker operations. Broken down by operation type."
,
},
[]
string
{
"operation_type"
},
)
// DeprecatedDockerOperations collects operation counts by operation type.
DeprecatedDockerOperations
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
kubeletSubsystem
,
Name
:
DeprecatedDockerOperationsKey
,
Help
:
"(Deprecated) Cumulative number of Docker operations by operation type."
,
},
[]
string
{
"operation_type"
},
)
// DeprecatedDockerOperationsErrors collects operation errors by operation
// type.
DeprecatedDockerOperationsErrors
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
kubeletSubsystem
,
Name
:
DeprecatedDockerOperationsErrorsKey
,
Help
:
"(Deprecated) Cumulative number of Docker operation errors by operation type."
,
},
[]
string
{
"operation_type"
},
)
// DeprecatedDockerOperationsTimeout collects operation timeouts by operation type.
DeprecatedDockerOperationsTimeout
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
kubeletSubsystem
,
Name
:
DeprecatedDockerOperationsTimeoutKey
,
Help
:
"(Deprecated) Cumulative number of Docker operation timeout by operation type."
,
},
[]
string
{
"operation_type"
},
)
)
)
var
registerMetrics
sync
.
Once
var
registerMetrics
sync
.
Once
...
@@ -87,6 +136,10 @@ func Register() {
...
@@ -87,6 +136,10 @@ func Register() {
prometheus
.
MustRegister
(
DockerOperations
)
prometheus
.
MustRegister
(
DockerOperations
)
prometheus
.
MustRegister
(
DockerOperationsErrors
)
prometheus
.
MustRegister
(
DockerOperationsErrors
)
prometheus
.
MustRegister
(
DockerOperationsTimeout
)
prometheus
.
MustRegister
(
DockerOperationsTimeout
)
prometheus
.
MustRegister
(
DeprecatedDockerOperationsLatency
)
prometheus
.
MustRegister
(
DeprecatedDockerOperations
)
prometheus
.
MustRegister
(
DeprecatedDockerOperationsErrors
)
prometheus
.
MustRegister
(
DeprecatedDockerOperationsTimeout
)
})
})
}
}
...
@@ -94,3 +147,8 @@ func Register() {
...
@@ -94,3 +147,8 @@ func Register() {
func
SinceInMicroseconds
(
start
time
.
Time
)
float64
{
func
SinceInMicroseconds
(
start
time
.
Time
)
float64
{
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
}
}
// SinceInSeconds gets the time since the specified start in seconds.
func
SinceInSeconds
(
start
time
.
Time
)
float64
{
return
time
.
Since
(
start
)
.
Seconds
()
}
pkg/kubelet/dockershim/network/metrics/metrics.go
View file @
ae450686
...
@@ -27,7 +27,9 @@ const (
...
@@ -27,7 +27,9 @@ const (
// NetworkPluginOperationsKey is the key for operation count metrics.
// NetworkPluginOperationsKey is the key for operation count metrics.
NetworkPluginOperationsKey
=
"network_plugin_operations"
NetworkPluginOperationsKey
=
"network_plugin_operations"
// NetworkPluginOperationsLatencyKey is the key for the operation latency metrics.
// NetworkPluginOperationsLatencyKey is the key for the operation latency metrics.
NetworkPluginOperationsLatencyKey
=
"network_plugin_operations_latency_microseconds"
NetworkPluginOperationsLatencyKey
=
"network_plugin_operations_latency_seconds"
// DeprecatedNetworkPluginOperationsLatencyKey is the deprecated key for the operation latency metrics.
DeprecatedNetworkPluginOperationsLatencyKey
=
"network_plugin_operations_latency_microseconds"
// Keep the "kubelet" subsystem for backward compatibility.
// Keep the "kubelet" subsystem for backward compatibility.
kubeletSubsystem
=
"kubelet"
kubeletSubsystem
=
"kubelet"
...
@@ -36,11 +38,23 @@ const (
...
@@ -36,11 +38,23 @@ const (
var
(
var
(
// NetworkPluginOperationsLatency collects operation latency numbers by operation
// NetworkPluginOperationsLatency collects operation latency numbers by operation
// type.
// type.
NetworkPluginOperationsLatency
=
prometheus
.
New
Summary
Vec
(
NetworkPluginOperationsLatency
=
prometheus
.
New
Histogram
Vec
(
prometheus
.
Summary
Opts
{
prometheus
.
Histogram
Opts
{
Subsystem
:
kubeletSubsystem
,
Subsystem
:
kubeletSubsystem
,
Name
:
NetworkPluginOperationsLatencyKey
,
Name
:
NetworkPluginOperationsLatencyKey
,
Help
:
"Latency in microseconds of network plugin operations. Broken down by operation type."
,
Help
:
"Latency in seconds of network plugin operations. Broken down by operation type."
,
Buckets
:
prometheus
.
DefBuckets
,
},
[]
string
{
"operation_type"
},
)
// DeprecatedNetworkPluginOperationsLatency collects operation latency numbers by operation
// type.
DeprecatedNetworkPluginOperationsLatency
=
prometheus
.
NewSummaryVec
(
prometheus
.
SummaryOpts
{
Subsystem
:
kubeletSubsystem
,
Name
:
DeprecatedNetworkPluginOperationsLatencyKey
,
Help
:
"(Deprecated) Latency in microseconds of network plugin operations. Broken down by operation type."
,
},
},
[]
string
{
"operation_type"
},
[]
string
{
"operation_type"
},
)
)
...
@@ -52,6 +66,7 @@ var registerMetrics sync.Once
...
@@ -52,6 +66,7 @@ var registerMetrics sync.Once
func
Register
()
{
func
Register
()
{
registerMetrics
.
Do
(
func
()
{
registerMetrics
.
Do
(
func
()
{
prometheus
.
MustRegister
(
NetworkPluginOperationsLatency
)
prometheus
.
MustRegister
(
NetworkPluginOperationsLatency
)
prometheus
.
MustRegister
(
DeprecatedNetworkPluginOperationsLatency
)
})
})
}
}
...
@@ -59,3 +74,8 @@ func Register() {
...
@@ -59,3 +74,8 @@ func Register() {
func
SinceInMicroseconds
(
start
time
.
Time
)
float64
{
func
SinceInMicroseconds
(
start
time
.
Time
)
float64
{
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
return
float64
(
time
.
Since
(
start
)
.
Nanoseconds
()
/
time
.
Microsecond
.
Nanoseconds
())
}
}
// SinceInSeconds gets the time since the specified start in seconds.
func
SinceInSeconds
(
start
time
.
Time
)
float64
{
return
time
.
Since
(
start
)
.
Seconds
()
}
pkg/kubelet/dockershim/network/plugins.go
View file @
ae450686
...
@@ -351,7 +351,8 @@ func (pm *PluginManager) podUnlock(fullPodName string) {
...
@@ -351,7 +351,8 @@ func (pm *PluginManager) podUnlock(fullPodName string) {
// recordOperation records operation and duration
// recordOperation records operation and duration
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
metrics
.
NetworkPluginOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
metrics
.
NetworkPluginOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInSeconds
(
start
))
metrics
.
DeprecatedNetworkPluginOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}
}
func
(
pm
*
PluginManager
)
GetPodNetworkStatus
(
podNamespace
,
podName
string
,
id
kubecontainer
.
ContainerID
)
(
*
PodNetworkStatus
,
error
)
{
func
(
pm
*
PluginManager
)
GetPodNetworkStatus
(
podNamespace
,
podName
string
,
id
kubecontainer
.
ContainerID
)
(
*
PodNetworkStatus
,
error
)
{
...
...
test/e2e/framework/metrics_util.go
View file @
ae450686
...
@@ -171,7 +171,7 @@ var InterestingControllerManagerMetrics = []string{
...
@@ -171,7 +171,7 @@ var InterestingControllerManagerMetrics = []string{
var
InterestingKubeletMetrics
=
[]
string
{
var
InterestingKubeletMetrics
=
[]
string
{
"kubelet_container_manager_latency_microseconds"
,
"kubelet_container_manager_latency_microseconds"
,
"kubelet_docker_errors"
,
"kubelet_docker_errors"
,
"kubelet_docker_operations_latency_
micro
seconds"
,
"kubelet_docker_operations_latency_seconds"
,
"kubelet_generate_pod_status_latency_microseconds"
,
"kubelet_generate_pod_status_latency_microseconds"
,
"kubelet_pod_start_latency_microseconds"
,
"kubelet_pod_start_latency_microseconds"
,
"kubelet_pod_worker_latency_microseconds"
,
"kubelet_pod_worker_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