Migrate pkg/kubelet/metrics logs to structured logging.

This commit is contained in:
jialaijun 2021-01-31 17:36:18 +08:00
parent c241a237f9
commit 15612338e5
3 changed files with 5 additions and 5 deletions

View File

@ -63,7 +63,7 @@ func (c *logMetricsCollector) DescribeWithStability(ch chan<- *metrics.Desc) {
func (c *logMetricsCollector) CollectWithStability(ch chan<- metrics.Metric) {
podStats, err := c.podStats()
if err != nil {
klog.Errorf("failed to get pod stats: %v", err)
klog.ErrorS(err, "Failed to get pod stats")
return
}

View File

@ -115,7 +115,7 @@ func (rc *resourceMetricsCollector) CollectWithStability(ch chan<- metrics.Metri
statsSummary, err := rc.provider.GetCPUAndMemoryStats()
if err != nil {
errorCount = 1
klog.Warningf("Error getting summary for resourceMetric prometheus endpoint: %v", err)
klog.ErrorS(err, "Error getting summary for resourceMetric prometheus endpoint")
return
}

View File

@ -467,7 +467,7 @@ func SetAssignedConfig(source *corev1.NodeConfigSource) error {
}
// clean up the old timeseries (WithLabelValues creates a new one for each distinct label set)
if !AssignedConfig.Delete(assignedConfigLabels) {
klog.Warningf("Failed to delete metric for labels %v. This may result in ambiguity from multiple metrics concurrently indicating different assigned configs.", assignedConfigLabels)
klog.InfoS("Failed to delete metric for labels. This may result in ambiguity from multiple metrics concurrently indicating different assigned configs.", "labels", assignedConfigLabels)
}
// record the new timeseries
assignedConfigLabels = labels
@ -489,7 +489,7 @@ func SetActiveConfig(source *corev1.NodeConfigSource) error {
}
// clean up the old timeseries (WithLabelValues creates a new one for each distinct label set)
if !ActiveConfig.Delete(activeConfigLabels) {
klog.Warningf("Failed to delete metric for labels %v. This may result in ambiguity from multiple metrics concurrently indicating different active configs.", activeConfigLabels)
klog.InfoS("Failed to delete metric for labels. This may result in ambiguity from multiple metrics concurrently indicating different active configs.", "labels", activeConfigLabels)
}
// record the new timeseries
activeConfigLabels = labels
@ -511,7 +511,7 @@ func SetLastKnownGoodConfig(source *corev1.NodeConfigSource) error {
}
// clean up the old timeseries (WithLabelValues creates a new one for each distinct label set)
if !LastKnownGoodConfig.Delete(lastKnownGoodConfigLabels) {
klog.Warningf("Failed to delete metric for labels %v. This may result in ambiguity from multiple metrics concurrently indicating different last known good configs.", lastKnownGoodConfigLabels)
klog.InfoS("Failed to delete metric for labels. This may result in ambiguity from multiple metrics concurrently indicating different last known good configs.", "labels", lastKnownGoodConfigLabels)
}
// record the new timeseries
lastKnownGoodConfigLabels = labels