mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-02 06:47:34 +00:00
Update cadvisor and containerd
This commit is contained in:
13
vendor/github.com/google/cadvisor/collector/prometheus_collector.go
generated
vendored
13
vendor/github.com/google/cadvisor/collector/prometheus_collector.go
generated
vendored
@@ -184,6 +184,17 @@ func (s byName) Less(i, j int) bool {
|
||||
return s.prometheusLabels[i].GetName() < s.prometheusLabels[j].GetName()
|
||||
}
|
||||
|
||||
func prometheusLabelSetToCadvisorLabels(promLabels model.Metric) map[string]string {
|
||||
labels := make(map[string]string)
|
||||
for k, v := range promLabels {
|
||||
if string(k) == "__name__" {
|
||||
continue
|
||||
}
|
||||
labels[string(k)] = string(v)
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
func prometheusLabelSetToCadvisorLabel(promLabels model.Metric) string {
|
||||
labels := labelSetToLabelPairs(promLabels)
|
||||
sort.Sort(byName{labels})
|
||||
@@ -247,11 +258,13 @@ func (collector *PrometheusCollector) Collect(metrics map[string][]v1.MetricVal)
|
||||
// TODO Handle multiple labels nicer. Prometheus metrics can have multiple
|
||||
// labels, cadvisor only accepts a single string for the metric label.
|
||||
label := prometheusLabelSetToCadvisorLabel(sample.Metric)
|
||||
labels := prometheusLabelSetToCadvisorLabels(sample.Metric)
|
||||
|
||||
metric := v1.MetricVal{
|
||||
FloatValue: float64(sample.Value),
|
||||
Timestamp: sample.Timestamp.Time(),
|
||||
Label: label,
|
||||
Labels: labels,
|
||||
}
|
||||
newMetrics[metName] = append(newMetrics[metName], metric)
|
||||
if len(newMetrics) > collector.metricCountLimit {
|
||||
|
||||
Reference in New Issue
Block a user