-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
koordlet: add metrics for kubelet and resource executor (#1913)
Signed-off-by: 佑祎 <zzw261520@alibaba-inc.com>
- Loading branch information
1 parent
f42fffb
commit c0374ef
Showing
14 changed files
with
202 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
const ( | ||
HTTPVerbKey = "verb" | ||
HTTPPathKey = "path" | ||
HTTPCodeKey = "code" | ||
) | ||
|
||
const ( | ||
HTTPVerbGet = "get" | ||
) | ||
|
||
var ( | ||
kubeletRequestDurationSeconds = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Subsystem: KoordletSubsystem, | ||
Name: "kubelet_request_duration_seconds", | ||
Help: "kubelet http request duration in seconds", | ||
// 10s ~ 4s, /config <= 4ms, /pods <= 16ms | ||
Buckets: prometheus.ExponentialBuckets(0.001, 4, 7), | ||
}, | ||
[]string{HTTPVerbKey, HTTPPathKey, HTTPCodeKey}, | ||
) | ||
|
||
KubeletStubCollector = []prometheus.Collector{ | ||
kubeletRequestDurationSeconds, | ||
} | ||
) | ||
|
||
// RecordKubeletRequestDuration records the duration of kubelet http request | ||
func RecordKubeletRequestDuration(verb, path, code string, seconds float64) { | ||
kubeletRequestDurationSeconds.WithLabelValues(verb, path, code).Observe(seconds) | ||
} | ||
|
||
func SinceInSeconds(start time.Time) float64 { | ||
return time.Since(start).Seconds() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2022 The Koordinator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
const ( | ||
// ResourceUpdaterType represents the type of resource udpater, including cgroup files, resctrl files, etc | ||
ResourceUpdaterType = "type" | ||
// ResourceUpdateStatusKey represents the status of resource update | ||
ResourceUpdateStatusKey = "status" | ||
) | ||
|
||
const ( | ||
ResourceUpdateStatusSuccess = "success" | ||
ResourceUpdateStatusFailed = "failed" | ||
) | ||
|
||
var ( | ||
resourceUpdateDurationMilliSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Subsystem: KoordletSubsystem, | ||
Name: "resource_update_duration_milliseconds", | ||
Help: "time duration of resource update such as cgroup files", | ||
// 10us ~ 10.24ms, cgroup <= 40us | ||
Buckets: prometheus.ExponentialBuckets(0.01, 4, 8), | ||
}, []string{ResourceUpdaterType, ResourceUpdateStatusKey}) | ||
|
||
ResourceExecutorCollector = []prometheus.Collector{ | ||
resourceUpdateDurationMilliSeconds, | ||
} | ||
) | ||
|
||
func RecordResourceUpdateDuration(updaterType, status string, seconds float64) { | ||
resourceUpdateDurationMilliSeconds.WithLabelValues(updaterType, status).Observe(seconds * 1000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.