Merge pull request #19063 from gmarek/use-metrics
Auto commit by PR queue bot
This commit is contained in:
@@ -42,8 +42,6 @@ var KnownApiServerMetrics = map[string][]string{
|
||||
"etcd_request_latencies_summary": {"operation", "type", "quantile"},
|
||||
"etcd_request_latencies_summary_count": {"operation", "type"},
|
||||
"etcd_request_latencies_summary_sum": {"operation", "type"},
|
||||
"get_token_count": {},
|
||||
"get_token_fail_count": {},
|
||||
"rest_client_request_latency_microseconds": {"url", "verb", "quantile"},
|
||||
"rest_client_request_latency_microseconds_count": {"url", "verb"},
|
||||
"rest_client_request_latency_microseconds_sum": {"url", "verb"},
|
||||
|
||||
@@ -29,38 +29,55 @@ import (
|
||||
)
|
||||
|
||||
var CommonMetrics = map[string][]string{
|
||||
"process_start_time_seconds": {},
|
||||
"process_resident_memory_bytes": {},
|
||||
"process_virtual_memory_bytes": {},
|
||||
"process_cpu_seconds_total": {},
|
||||
"process_max_fds": {},
|
||||
"process_open_fds": {},
|
||||
|
||||
"http_request_size_bytes": {"handler", "quantile"},
|
||||
"http_request_size_bytes_count": {"handler"},
|
||||
"http_request_size_bytes_sum": {"handler"},
|
||||
"get_token_count": {},
|
||||
"get_token_fail_count": {},
|
||||
"go_gc_duration_seconds": {"quantile"},
|
||||
"go_gc_duration_seconds_count": {},
|
||||
"go_gc_duration_seconds_sum": {},
|
||||
"go_goroutines": {},
|
||||
"http_request_duration_microseconds": {"handler", "quantile"},
|
||||
"http_request_duration_microseconds_count": {"handler"},
|
||||
"http_request_duration_microseconds_sum": {"handler"},
|
||||
"http_request_size_bytes": {"handler", "quantile"},
|
||||
"http_request_size_bytes_count": {"handler"},
|
||||
"http_request_size_bytes_sum": {"handler"},
|
||||
"http_requests_total": {"handler", "method", "code"},
|
||||
|
||||
"http_response_size_bytes": {"handler", "quantile"},
|
||||
"http_response_size_bytes_count": {"handler"},
|
||||
"http_response_size_bytes_sum": {"handler"},
|
||||
|
||||
"ssh_tunnel_open_fail_count": {},
|
||||
"ssh_tunnel_open_count": {},
|
||||
|
||||
"go_gc_duration_seconds": {"quantile"},
|
||||
"go_gc_duration_seconds_count": {},
|
||||
"go_gc_duration_seconds_sum": {},
|
||||
"go_goroutines": {},
|
||||
|
||||
"kubernetes_build_info": {"major", "minor", "gitCommit", "gitTreeState", "gitVersion"},
|
||||
"http_response_size_bytes": {"handler", "quantile"},
|
||||
"http_response_size_bytes_count": {"handler"},
|
||||
"http_response_size_bytes_sum": {"handler"},
|
||||
"kubernetes_build_info": {"major", "minor", "gitCommit", "gitTreeState", "gitVersion"},
|
||||
"process_cpu_seconds_total": {},
|
||||
"process_max_fds": {},
|
||||
"process_open_fds": {},
|
||||
"process_resident_memory_bytes": {},
|
||||
"process_start_time_seconds": {},
|
||||
"process_virtual_memory_bytes": {},
|
||||
"ssh_tunnel_open_count": {},
|
||||
"ssh_tunnel_open_fail_count": {},
|
||||
}
|
||||
|
||||
type Metrics map[string]model.Samples
|
||||
|
||||
func PrintSample(sample *model.Sample) string {
|
||||
buf := make([]string, 0)
|
||||
// Id is a VERY special label. For 'normal' container it's usless, but it's necessary
|
||||
// for 'system' containers (e.g. /docker-daemon, /kubelet, etc.). We know if that's the
|
||||
// case by checking if there's a label "kubernetes_container_name" present. It's hacky
|
||||
// but it works...
|
||||
_, normalContainer := sample.Metric["kubernetes_container_name"]
|
||||
for k, v := range sample.Metric {
|
||||
if strings.HasPrefix(string(k), "__") || KubeletMetricsLabelsToSkip.Has(string(k)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if string(k) == "id" && normalContainer {
|
||||
continue
|
||||
}
|
||||
buf = append(buf, fmt.Sprintf("%v=%v", string(k), v))
|
||||
}
|
||||
return fmt.Sprintf("[%v] = %v", strings.Join(buf, ","), sample.Value)
|
||||
}
|
||||
|
||||
func NewMetrics() Metrics {
|
||||
result := make(Metrics)
|
||||
for metric := range CommonMetrics {
|
||||
|
||||
@@ -61,8 +61,6 @@ var KnownKubeletMetrics = map[string][]string{
|
||||
"container_spec_memory_swap_limit_bytes": {"id", "image", "kubernetes_container_name", "kubernetes_namespace", "kubernetes_pod_name", "name"},
|
||||
"container_start_time_seconds": {"id", "image", "kubernetes_container_name", "kubernetes_namespace", "kubernetes_pod_name", "name"},
|
||||
"container_tasks_state": {"id", "image", "kubernetes_container_name", "kubernetes_namespace", "kubernetes_pod_name", "name", "state"},
|
||||
"get_token_count": {},
|
||||
"get_token_fail_count": {},
|
||||
"kubelet_container_manager_latency_microseconds": {"operation_type", "quantile"},
|
||||
"kubelet_container_manager_latency_microseconds_count": {"operation_type"},
|
||||
"kubelet_container_manager_latency_microseconds_sum": {"operation_type"},
|
||||
@@ -98,6 +96,12 @@ var KnownKubeletMetrics = map[string][]string{
|
||||
"rest_client_request_status_codes": {"code", "host", "method"},
|
||||
}
|
||||
|
||||
var KubeletMetricsLabelsToSkip = sets.NewString(
|
||||
"kubernetes_namespace",
|
||||
"image",
|
||||
"name",
|
||||
)
|
||||
|
||||
type KubeletMetrics Metrics
|
||||
|
||||
func NewKubeletMetrics() KubeletMetrics {
|
||||
|
||||
Reference in New Issue
Block a user