mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Update package web for new labels.Labels type
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
cdbe7f462b
commit
5bc4643122
|
@ -171,26 +171,24 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
Untyped: &dto.Untyped{},
|
||||
}
|
||||
|
||||
for _, l := range s.Metric {
|
||||
err := s.Metric.Validate(func(l labels.Label) error {
|
||||
if l.Value == "" {
|
||||
// No value means unset. Never consider those labels.
|
||||
// This is also important to protect against nameless metrics.
|
||||
continue
|
||||
return nil
|
||||
}
|
||||
if l.Name == labels.MetricName {
|
||||
nameSeen = true
|
||||
if l.Value == lastMetricName {
|
||||
// We already have the name in the current MetricFamily,
|
||||
// and we ignore nameless metrics.
|
||||
continue
|
||||
return nil
|
||||
}
|
||||
// Need to start a new MetricFamily. Ship off the old one (if any) before
|
||||
// creating the new one.
|
||||
if protMetricFam != nil {
|
||||
if err := enc.Encode(protMetricFam); err != nil {
|
||||
federationErrors.Inc()
|
||||
level.Error(h.logger).Log("msg", "federation failed", "err", err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
protMetricFam = &dto.MetricFamily{
|
||||
|
@ -198,7 +196,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
Name: proto.String(l.Value),
|
||||
}
|
||||
lastMetricName = l.Value
|
||||
continue
|
||||
return nil
|
||||
}
|
||||
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
|
||||
Name: proto.String(l.Name),
|
||||
|
@ -207,6 +205,12 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
if _, ok := externalLabels[l.Name]; ok {
|
||||
globalUsed[l.Name] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
federationErrors.Inc()
|
||||
level.Error(h.logger).Log("msg", "federation failed", "err", err)
|
||||
return
|
||||
}
|
||||
if !nameSeen {
|
||||
level.Warn(h.logger).Log("msg", "Ignoring nameless metric during federation", "metric", s.Metric)
|
||||
|
|
|
@ -653,13 +653,10 @@ func (h *Handler) consoles(w http.ResponseWriter, r *http.Request) {
|
|||
params[k] = v[0]
|
||||
}
|
||||
|
||||
externalLabels := map[string]string{}
|
||||
h.mtx.RLock()
|
||||
els := h.config.GlobalConfig.ExternalLabels
|
||||
h.mtx.RUnlock()
|
||||
for _, el := range els {
|
||||
externalLabels[el.Name] = el.Value
|
||||
}
|
||||
externalLabels := els.Map()
|
||||
|
||||
// Inject some convenience variables that are easier to remember for users
|
||||
// who are not used to Go's templating system.
|
||||
|
|
Loading…
Reference in a new issue