MCPcopy Create free account
hub / github.com/cortexproject/cortex / getMetricsWithLabelNames

Function getMetricsWithLabelNames

pkg/util/metrics_helper.go:348–366  ·  view source on GitHub ↗
(mf *dto.MetricFamily, labelNames []string)

Source from the content-addressed store, hash-verified

346}
347
348func getMetricsWithLabelNames(mf *dto.MetricFamily, labelNames []string) map[string]metricsWithLabels {
349 result := map[string]metricsWithLabels{}
350
351 for _, m := range mf.GetMetric() {
352 lbls, include := getLabelValues(m, labelNames)
353 if !include {
354 continue
355 }
356
357 key := getLabelsString(lbls)
358 r := result[key]
359 if r.labelValues == nil {
360 r.labelValues = lbls
361 }
362 r.metrics = append(r.metrics, m)
363 result[key] = r
364 }
365 return result
366}
367
368func getLabelValues(m *dto.Metric, labelNames []string) ([]string, bool) {
369 result := make([]string, 0, len(labelNames))

Calls 3

getLabelValuesFunction · 0.85
getLabelsStringFunction · 0.85
GetMetricMethod · 0.45

Tested by 2