-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support kube_state_metrics v2.0.0 #27552
Changes from 4 commits
84fc11d
bd17339
5521546
14a9c79
daba6cd
eda32e1
827ae31
27fec71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,20 @@ var ( | |
// Mapping of state metrics | ||
mapping = &p.MetricsMapping{ | ||
Metrics: map[string]p.MetricMap{ | ||
"kube_pod_info": p.InfoMetric(), | ||
"kube_pod_container_info": p.InfoMetric(), | ||
"kube_pod_info": p.InfoMetric(), | ||
"kube_pod_container_info": p.InfoMetric(), | ||
"kube_pod_container_resource_requests": p.Metric("", p.OpFilterMap( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great that you were able to re-use our existing OpFilter to handle this! |
||
"resource", map[string]string{ | ||
"cpu": "cpu.request.cores", | ||
"memory": "memory.request.bytes", | ||
}, | ||
)), | ||
"kube_pod_container_resource_limits": p.Metric("", p.OpFilterMap( | ||
"resource", map[string]string{ | ||
"cpu": "cpu.limit.cores", | ||
"memory": "memory.limit.bytes", | ||
}, | ||
)), | ||
"kube_pod_container_resource_limits_cpu_cores": p.Metric("cpu.limit.cores"), | ||
"kube_pod_container_resource_requests_cpu_cores": p.Metric("cpu.request.cores"), | ||
"kube_pod_container_resource_limits_memory_bytes": p.Metric("memory.limit.bytes"), | ||
|
@@ -130,18 +142,29 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) error { | |
} | ||
|
||
m.enricher.Enrich(events) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: consider not removing lines if there is no specific reason |
||
//m.Logger().Infof("Events are %+v", events) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leftover? |
||
// Calculate deprecated nanocores values | ||
for _, event := range events { | ||
if request, ok := event["cpu.request.cores"]; ok { | ||
if requestCores, ok := request.(float64); ok { | ||
event["cpu.request.nanocores"] = requestCores * nanocores | ||
} | ||
} | ||
|
||
if limit, ok := event["cpu.limit.cores"]; ok { | ||
if limitCores, ok := limit.(float64); ok { | ||
event["cpu.limit.nanocores"] = limitCores * nanocores | ||
if cpuFields, ok := event["cpu"]; ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not to convert the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
if cpuFieldsMapStr, ok := cpuFields.(common.MapStr); ok { | ||
if request, ok := cpuFieldsMapStr["request"]; ok { | ||
if requestFieldsMapStr, ok := request.(common.MapStr); ok { | ||
if cores, ok := requestFieldsMapStr["cores"]; ok { | ||
if requestCores, ok := cores.(float64); ok { | ||
event.Put("cpu.request.nanocores", requestCores*nanocores) | ||
} | ||
} | ||
} | ||
} | ||
if limit, ok := cpuFieldsMapStr["limit"]; ok { | ||
if limitFieldsMapStr, ok := limit.(common.MapStr); ok { | ||
if cores, ok := limitFieldsMapStr["cores"]; ok { | ||
if limitCores, ok := cores.(float64); ok { | ||
event.Put("cpu.limit.nanocores", limitCores*nanocores) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same here, do not remove lines if it's not intentional |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think that we need to cover
ksm.v2.0.0
in our tests, right?