mirror of https://github.com/k3s-io/k3s
Print only interesting Kubelet metrics in JSON printer
parent
548b3b2fc1
commit
ed7e9bfb20
|
@ -49,6 +49,22 @@ const (
|
|||
|
||||
type MetricsForE2E metrics.MetricsCollection
|
||||
|
||||
func (m *MetricsForE2E) filterMetrics() {
|
||||
interestingApiServerMetrics := make(metrics.ApiServerMetrics)
|
||||
for _, metric := range InterestingApiServerMetrics {
|
||||
interestingApiServerMetrics[metric] = (*m).ApiServerMetrics[metric]
|
||||
}
|
||||
interestingKubeletMetrics := make(map[string]metrics.KubeletMetrics)
|
||||
for kubelet, grabbed := range (*m).KubeletMetrics {
|
||||
interestingKubeletMetrics[kubelet] = make(metrics.KubeletMetrics)
|
||||
for _, metric := range InterestingKubeletMetrics {
|
||||
interestingKubeletMetrics[kubelet][metric] = grabbed[metric]
|
||||
}
|
||||
}
|
||||
(*m).ApiServerMetrics = interestingApiServerMetrics
|
||||
(*m).KubeletMetrics = interestingKubeletMetrics
|
||||
}
|
||||
|
||||
func (m *MetricsForE2E) PrintHumanReadable() string {
|
||||
buf := bytes.Buffer{}
|
||||
for _, interestingMetric := range InterestingApiServerMetrics {
|
||||
|
@ -70,6 +86,7 @@ func (m *MetricsForE2E) PrintHumanReadable() string {
|
|||
}
|
||||
|
||||
func (m *MetricsForE2E) PrintJSON() string {
|
||||
m.filterMetrics()
|
||||
return prettyPrintJSON(*m)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue