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