mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Rename global "labels" config option to "external_labels".
This commit is contained in:
parent
bf4e4a8ff0
commit
dac26cef71
|
@ -206,6 +206,10 @@ func reloadConfig(filename string, rls ...Reloadable) (success bool) {
|
|||
conf, err := config.LoadFile(filename)
|
||||
if err != nil {
|
||||
log.Errorf("Couldn't load configuration (-config.file=%s): %v", filename, err)
|
||||
// TODO(julius): Remove this notice when releasing 0.17.0 or 0.18.0.
|
||||
if err.Error() == "unknown fields in global config: labels" {
|
||||
log.Errorf("NOTE: The 'labels' setting in the global configuration section has been renamed to 'external_labels' and now has changed semantics (see release notes at https://github.com/prometheus/prometheus/blob/master/CHANGELOG.md). Please update your configuration file accordingly.")
|
||||
}
|
||||
return false
|
||||
}
|
||||
success = true
|
||||
|
|
|
@ -274,7 +274,7 @@ type GlobalConfig struct {
|
|||
// How frequently to evaluate rules by default.
|
||||
EvaluationInterval Duration `yaml:"evaluation_interval,omitempty"`
|
||||
// The labels to add to any timeseries that this Prometheus instance scrapes.
|
||||
Labels model.LabelSet `yaml:"labels,omitempty"`
|
||||
ExternalLabels model.LabelSet `yaml:"external_labels,omitempty"`
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
@ -292,7 +292,7 @@ func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
|
||||
// isZero returns true iff the global config is the zero value.
|
||||
func (c *GlobalConfig) isZero() bool {
|
||||
return c.Labels == nil &&
|
||||
return c.ExternalLabels == nil &&
|
||||
c.ScrapeInterval == 0 &&
|
||||
c.ScrapeTimeout == 0 &&
|
||||
c.EvaluationInterval == 0
|
||||
|
|
|
@ -32,7 +32,7 @@ var expectedConf = &Config{
|
|||
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
||||
EvaluationInterval: Duration(30 * time.Second),
|
||||
|
||||
Labels: model.LabelSet{
|
||||
ExternalLabels: model.LabelSet{
|
||||
"monitor": "codelab",
|
||||
"foo": "bar",
|
||||
},
|
||||
|
|
2
config/testdata/conf.good.yml
vendored
2
config/testdata/conf.good.yml
vendored
|
@ -4,7 +4,7 @@ global:
|
|||
evaluation_interval: 30s
|
||||
# scrape_timeout is set to the global default (10s).
|
||||
|
||||
labels:
|
||||
external_labels:
|
||||
monitor: codelab
|
||||
foo: bar
|
||||
|
||||
|
|
2
config/testdata/labelname.bad.yml
vendored
2
config/testdata/labelname.bad.yml
vendored
|
@ -1,3 +1,3 @@
|
|||
global:
|
||||
labels:
|
||||
external_labels:
|
||||
not$allowed: value
|
||||
|
|
2
config/testdata/labelname2.bad.yml
vendored
2
config/testdata/labelname2.bad.yml
vendored
|
@ -1,3 +1,3 @@
|
|||
global:
|
||||
labels:
|
||||
external_labels:
|
||||
'not:allowed': value
|
||||
|
|
2
config/testdata/unknown_attr.bad.yml
vendored
2
config/testdata/unknown_attr.bad.yml
vendored
|
@ -4,7 +4,7 @@ global:
|
|||
evaluation_interval: 30s
|
||||
# scrape_timeout is set to the global default (10s).
|
||||
|
||||
labels:
|
||||
external_labels:
|
||||
monitor: codelab
|
||||
foo: bar
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ type NotificationHandler struct {
|
|||
notificationsQueueLength prometheus.Gauge
|
||||
notificationsQueueCapacity prometheus.Metric
|
||||
|
||||
globalLabels model.LabelSet
|
||||
externalLabels model.LabelSet
|
||||
mtx sync.RWMutex
|
||||
stopped chan struct{}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ func (n *NotificationHandler) ApplyConfig(conf *config.Config) bool {
|
|||
n.mtx.Lock()
|
||||
defer n.mtx.Unlock()
|
||||
|
||||
n.globalLabels = conf.GlobalConfig.Labels
|
||||
n.externalLabels = conf.GlobalConfig.ExternalLabels
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func (n *NotificationHandler) sendNotifications(reqs NotificationReqs) error {
|
|||
|
||||
alerts := make([]map[string]interface{}, 0, len(reqs))
|
||||
for _, req := range reqs {
|
||||
for ln, lv := range n.globalLabels {
|
||||
for ln, lv := range n.externalLabels {
|
||||
if _, ok := req.Labels[ln]; !ok {
|
||||
req.Labels[ln] = lv
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
// Storage collects multiple remote storage queues.
|
||||
type Storage struct {
|
||||
queues []*StorageQueueManager
|
||||
globalLabels model.LabelSet
|
||||
externalLabels model.LabelSet
|
||||
mtx sync.RWMutex
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ func (s *Storage) ApplyConfig(conf *config.Config) bool {
|
|||
s.mtx.Lock()
|
||||
defer s.mtx.Unlock()
|
||||
|
||||
s.globalLabels = conf.GlobalConfig.Labels
|
||||
s.externalLabels = conf.GlobalConfig.ExternalLabels
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func (s *Storage) Append(smpl *model.Sample) {
|
|||
snew = *smpl
|
||||
snew.Metric = smpl.Metric.Clone()
|
||||
|
||||
for ln, lv := range s.globalLabels {
|
||||
for ln, lv := range s.externalLabels {
|
||||
if _, ok := smpl.Metric[ln]; !ok {
|
||||
snew.Metric[ln] = lv
|
||||
}
|
||||
|
|
|
@ -80,13 +80,13 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
Name: proto.String(string(ln)),
|
||||
Value: proto.String(string(lv)),
|
||||
})
|
||||
if _, ok := h.globalLabels[ln]; ok {
|
||||
if _, ok := h.externalLabels[ln]; ok {
|
||||
globalUsed[ln] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// Attach global labels if they do not exist yet.
|
||||
for ln, lv := range h.globalLabels {
|
||||
for ln, lv := range h.externalLabels {
|
||||
if _, ok := globalUsed[ln]; !ok {
|
||||
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
|
||||
Name: proto.String(string(ln)),
|
||||
|
|
|
@ -67,7 +67,7 @@ type Handler struct {
|
|||
options *Options
|
||||
statusInfo *PrometheusStatus
|
||||
|
||||
globalLabels model.LabelSet
|
||||
externalLabels model.LabelSet
|
||||
mtx sync.RWMutex
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ func (h *Handler) ApplyConfig(conf *config.Config) bool {
|
|||
h.mtx.Lock()
|
||||
defer h.mtx.Unlock()
|
||||
|
||||
h.globalLabels = conf.GlobalConfig.Labels
|
||||
h.externalLabels = conf.GlobalConfig.ExternalLabels
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue