Merge pull request #116897 from Richabanker/kubelete-resource-metrics-ga
Graduate kubelet resource metrics to GA
This commit is contained in:
@@ -31,14 +31,14 @@ var (
|
||||
"Cumulative cpu time consumed by the node in core-seconds",
|
||||
nil,
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
nodeMemoryUsageDesc = metrics.NewDesc("node_memory_working_set_bytes",
|
||||
"Current working set of the node in bytes",
|
||||
nil,
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
nodeSwapUsageDesc = metrics.NewDesc("node_swap_usage_bytes",
|
||||
@@ -52,14 +52,14 @@ var (
|
||||
"Cumulative cpu time consumed by the container in core-seconds",
|
||||
[]string{"container", "pod", "namespace"},
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
containerMemoryUsageDesc = metrics.NewDesc("container_memory_working_set_bytes",
|
||||
"Current working set of the container in bytes",
|
||||
[]string{"container", "pod", "namespace"},
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
containerSwapUsageDesc = metrics.NewDesc("container_swap_usage_bytes",
|
||||
@@ -73,14 +73,14 @@ var (
|
||||
"Cumulative cpu time consumed by the pod in core-seconds",
|
||||
[]string{"pod", "namespace"},
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
podMemoryUsageDesc = metrics.NewDesc("pod_memory_working_set_bytes",
|
||||
"Current working set of the pod in bytes",
|
||||
[]string{"pod", "namespace"},
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
podSwapUsageDesc = metrics.NewDesc("pod_swap_usage_bytes",
|
||||
@@ -95,13 +95,20 @@ var (
|
||||
nil,
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
"1.29.0")
|
||||
|
||||
resourceScrapeErrorResultDesc = metrics.NewDesc("resource_scrape_error",
|
||||
"1 if there was an error while getting container metrics, 0 otherwise",
|
||||
nil,
|
||||
nil,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
|
||||
containerStartTimeDesc = metrics.NewDesc("container_start_time_seconds",
|
||||
"Start time of the container since unix epoch in seconds",
|
||||
[]string{"container", "pod", "namespace"},
|
||||
nil,
|
||||
metrics.ALPHA,
|
||||
metrics.STABLE,
|
||||
"")
|
||||
)
|
||||
|
||||
@@ -134,6 +141,7 @@ func (rc *resourceMetricsCollector) DescribeWithStability(ch chan<- *metrics.Des
|
||||
ch <- podMemoryUsageDesc
|
||||
ch <- podSwapUsageDesc
|
||||
ch <- resourceScrapeResultDesc
|
||||
ch <- resourceScrapeErrorResultDesc
|
||||
}
|
||||
|
||||
// CollectWithStability implements metrics.StableCollector
|
||||
@@ -145,6 +153,7 @@ func (rc *resourceMetricsCollector) CollectWithStability(ch chan<- metrics.Metri
|
||||
var errorCount float64
|
||||
defer func() {
|
||||
ch <- metrics.NewLazyConstMetric(resourceScrapeResultDesc, metrics.GaugeValue, errorCount)
|
||||
ch <- metrics.NewLazyConstMetric(resourceScrapeErrorResultDesc, metrics.GaugeValue, errorCount)
|
||||
}()
|
||||
statsSummary, err := rc.provider.GetCPUAndMemoryStats(ctx)
|
||||
if err != nil {
|
||||
|
@@ -36,6 +36,7 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
testTime := metav1.NewTime(staticTimestamp)
|
||||
interestedMetrics := []string{
|
||||
"scrape_error",
|
||||
"resource_scrape_error",
|
||||
"node_cpu_usage_seconds_total",
|
||||
"node_memory_working_set_bytes",
|
||||
"node_swap_usage_bytes",
|
||||
@@ -64,6 +65,9 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 1
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 1
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -86,10 +90,10 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
},
|
||||
summaryErr: nil,
|
||||
expectedMetrics: `
|
||||
# HELP node_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the node in core-seconds
|
||||
# HELP node_cpu_usage_seconds_total [STABLE] Cumulative cpu time consumed by the node in core-seconds
|
||||
# TYPE node_cpu_usage_seconds_total counter
|
||||
node_cpu_usage_seconds_total 10 1624396278302
|
||||
# HELP node_memory_working_set_bytes [ALPHA] Current working set of the node in bytes
|
||||
# HELP node_memory_working_set_bytes [STABLE] Current working set of the node in bytes
|
||||
# TYPE node_memory_working_set_bytes gauge
|
||||
node_memory_working_set_bytes 1000 1624396278302
|
||||
# HELP node_swap_usage_bytes [ALPHA] Current swap usage of the node in bytes. Reported only on non-windows systems
|
||||
@@ -98,6 +102,9 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -119,6 +126,9 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -188,17 +198,20 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP container_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the container in core-seconds
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
# HELP container_cpu_usage_seconds_total [STABLE] Cumulative cpu time consumed by the container in core-seconds
|
||||
# TYPE container_cpu_usage_seconds_total counter
|
||||
container_cpu_usage_seconds_total{container="container_a",namespace="namespace_a",pod="pod_a"} 10 1624396278302
|
||||
container_cpu_usage_seconds_total{container="container_a",namespace="namespace_b",pod="pod_b"} 10 1624396278302
|
||||
container_cpu_usage_seconds_total{container="container_b",namespace="namespace_a",pod="pod_a"} 10 1624396278302
|
||||
# HELP container_memory_working_set_bytes [ALPHA] Current working set of the container in bytes
|
||||
# HELP container_memory_working_set_bytes [STABLE] Current working set of the container in bytes
|
||||
# TYPE container_memory_working_set_bytes gauge
|
||||
container_memory_working_set_bytes{container="container_a",namespace="namespace_a",pod="pod_a"} 1000 1624396278302
|
||||
container_memory_working_set_bytes{container="container_a",namespace="namespace_b",pod="pod_b"} 1000 1624396278302
|
||||
container_memory_working_set_bytes{container="container_b",namespace="namespace_a",pod="pod_a"} 1000 1624396278302
|
||||
# HELP container_start_time_seconds [ALPHA] Start time of the container since unix epoch in seconds
|
||||
# HELP container_start_time_seconds [STABLE] Start time of the container since unix epoch in seconds
|
||||
# TYPE container_start_time_seconds gauge
|
||||
container_start_time_seconds{container="container_a",namespace="namespace_a",pod="pod_a"} 1.6243962483020916e+09 1624396248302
|
||||
container_start_time_seconds{container="container_a",namespace="namespace_b",pod="pod_b"} 1.6243956783020916e+09 1624395678302
|
||||
@@ -239,10 +252,13 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP container_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the container in core-seconds
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
# HELP container_cpu_usage_seconds_total [STABLE] Cumulative cpu time consumed by the container in core-seconds
|
||||
# TYPE container_cpu_usage_seconds_total counter
|
||||
container_cpu_usage_seconds_total{container="container_a",namespace="namespace_a",pod="pod_a"} 10 1624396278302
|
||||
# HELP container_memory_working_set_bytes [ALPHA] Current working set of the container in bytes
|
||||
# HELP container_memory_working_set_bytes [STABLE] Current working set of the container in bytes
|
||||
# TYPE container_memory_working_set_bytes gauge
|
||||
container_memory_working_set_bytes{container="container_a",namespace="namespace_a",pod="pod_a"} 1000 1624396278302
|
||||
`,
|
||||
@@ -295,19 +311,22 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
},
|
||||
summaryErr: nil,
|
||||
expectedMetrics: `
|
||||
# HELP container_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the container in core-seconds
|
||||
# HELP container_cpu_usage_seconds_total [STABLE] Cumulative cpu time consumed by the container in core-seconds
|
||||
# TYPE container_cpu_usage_seconds_total counter
|
||||
container_cpu_usage_seconds_total{container="container_a",namespace="namespace_b",pod="pod_b"} 10 1624396278302
|
||||
# HELP container_memory_working_set_bytes [ALPHA] Current working set of the container in bytes
|
||||
# HELP container_memory_working_set_bytes [STABLE] Current working set of the container in bytes
|
||||
# TYPE container_memory_working_set_bytes gauge
|
||||
container_memory_working_set_bytes{container="container_a",namespace="namespace_b",pod="pod_b"} 1000 1624396278302
|
||||
# HELP container_start_time_seconds [ALPHA] Start time of the container since unix epoch in seconds
|
||||
# HELP container_start_time_seconds [STABLE] Start time of the container since unix epoch in seconds
|
||||
# TYPE container_start_time_seconds gauge
|
||||
container_start_time_seconds{container="container_a",namespace="namespace_a",pod="pod_a"} 1.6243962483020916e+09 1624396248302
|
||||
container_start_time_seconds{container="container_a",namespace="namespace_b",pod="pod_b"} 1.6243956783020916e+09 1624395678302
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -339,10 +358,13 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP pod_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the pod in core-seconds
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
# HELP pod_cpu_usage_seconds_total [STABLE] Cumulative cpu time consumed by the pod in core-seconds
|
||||
# TYPE pod_cpu_usage_seconds_total counter
|
||||
pod_cpu_usage_seconds_total{namespace="namespace_a",pod="pod_a"} 10 1624396278302
|
||||
# HELP pod_memory_working_set_bytes [ALPHA] Current working set of the pod in bytes
|
||||
# HELP pod_memory_working_set_bytes [STABLE] Current working set of the pod in bytes
|
||||
# TYPE pod_memory_working_set_bytes gauge
|
||||
pod_memory_working_set_bytes{namespace="namespace_a",pod="pod_a"} 1000 1624396278302
|
||||
# HELP pod_swap_usage_bytes [ALPHA] Current amount of the pod swap usage in bytes. Reported only on non-windows systems
|
||||
@@ -375,6 +397,9 @@ func TestCollectResourceMetrics(t *testing.T) {
|
||||
# HELP scrape_error [ALPHA] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE scrape_error gauge
|
||||
scrape_error 0
|
||||
# HELP resource_scrape_error [STABLE] 1 if there was an error while getting container metrics, 0 otherwise
|
||||
# TYPE resource_scrape_error gauge
|
||||
resource_scrape_error 0
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user