mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
do not crash on invalid metric values (#17764)
``` minio[1032735]: panic: label value "\xc0.\xc0." is not valid UTF-8 minio[1032735]: goroutine 1781101 [running]: minio[1032735]: github.com/prometheus/client_golang/prometheus.MustNewConstMetric(...) ``` log such errors for investigation
This commit is contained in:
parent
81be718674
commit
2fa561f22e
@ -2953,7 +2953,7 @@ func (c *minioBucketCollector) Collect(out chan<- prometheus.Metric) {
|
||||
continue
|
||||
}
|
||||
for k, v := range metric.Histogram {
|
||||
out <- prometheus.MustNewConstMetric(
|
||||
pmetric, err := prometheus.NewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(string(metric.Description.Namespace),
|
||||
string(metric.Description.Subsystem),
|
||||
@ -2965,6 +2965,11 @@ func (c *minioBucketCollector) Collect(out chan<- prometheus.Metric) {
|
||||
prometheus.GaugeValue,
|
||||
float64(v),
|
||||
append(values, k)...)
|
||||
if err != nil {
|
||||
logger.LogOnceIf(GlobalContext, fmt.Errorf("unable to validate prometheus metric (%w) %v+%v", err, values, metric.Histogram), "bucket-metrics-histogram")
|
||||
} else {
|
||||
out <- pmetric
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -2972,7 +2977,7 @@ func (c *minioBucketCollector) Collect(out chan<- prometheus.Metric) {
|
||||
if metric.Description.Type == counterMetric {
|
||||
metricType = prometheus.CounterValue
|
||||
}
|
||||
toPost := prometheus.MustNewConstMetric(
|
||||
pmetric, err := prometheus.NewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(string(metric.Description.Namespace),
|
||||
string(metric.Description.Subsystem),
|
||||
@ -2984,7 +2989,11 @@ func (c *minioBucketCollector) Collect(out chan<- prometheus.Metric) {
|
||||
metricType,
|
||||
metric.Value,
|
||||
values...)
|
||||
out <- toPost
|
||||
if err != nil {
|
||||
logger.LogOnceIf(GlobalContext, fmt.Errorf("unable to validate prometheus metric (%w) %v", err, values), "bucket-metrics")
|
||||
} else {
|
||||
out <- pmetric
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3024,7 +3033,7 @@ func (c *minioClusterCollector) Collect(out chan<- prometheus.Metric) {
|
||||
continue
|
||||
}
|
||||
for k, v := range metric.Histogram {
|
||||
out <- prometheus.MustNewConstMetric(
|
||||
pmetric, err := prometheus.NewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(string(metric.Description.Namespace),
|
||||
string(metric.Description.Subsystem),
|
||||
@ -3036,6 +3045,11 @@ func (c *minioClusterCollector) Collect(out chan<- prometheus.Metric) {
|
||||
prometheus.GaugeValue,
|
||||
float64(v),
|
||||
append(values, k)...)
|
||||
if err != nil {
|
||||
logger.LogOnceIf(GlobalContext, fmt.Errorf("unable to validate prometheus metric (%w) %v:%v", err, values, metric.Histogram), "cluster-metrics-histogram")
|
||||
} else {
|
||||
out <- pmetric
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -3043,7 +3057,7 @@ func (c *minioClusterCollector) Collect(out chan<- prometheus.Metric) {
|
||||
if metric.Description.Type == counterMetric {
|
||||
metricType = prometheus.CounterValue
|
||||
}
|
||||
toPost := prometheus.MustNewConstMetric(
|
||||
pmetric, err := prometheus.NewConstMetric(
|
||||
prometheus.NewDesc(
|
||||
prometheus.BuildFQName(string(metric.Description.Namespace),
|
||||
string(metric.Description.Subsystem),
|
||||
@ -3055,7 +3069,11 @@ func (c *minioClusterCollector) Collect(out chan<- prometheus.Metric) {
|
||||
metricType,
|
||||
metric.Value,
|
||||
values...)
|
||||
out <- toPost
|
||||
if err != nil {
|
||||
logger.LogOnceIf(GlobalContext, fmt.Errorf("unable to validate prometheus metric (%w) %v", err, values), "cluster-metrics")
|
||||
} else {
|
||||
out <- pmetric
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user