lib/promscrape: follow-up for a7e29c38bc

- Document the bugfix at docs/CHANGELOG.md
- Make the fix more durable against future changes when droppedTargetsMap.Register may be called from other places.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3580
This commit is contained in:
Aliaksandr Valialkin 2023-01-05 02:49:26 -08:00
parent 52226c392f
commit 634e24e685
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
3 changed files with 8 additions and 7 deletions

View file

@ -27,6 +27,7 @@ The following tip changes can be tested by building VictoriaMetrics components f
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): properly update tooltip when quickly hovering multiple lines on the graph. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3530). * BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): properly update tooltip when quickly hovering multiple lines on the graph. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3530).
* BUGFIX: properly parse floating-point numbers without integer or fractional parts such as `.123` and `20.` during [data import](https://docs.victoriametrics.com/#how-to-import-time-series-data). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544). * BUGFIX: properly parse floating-point numbers without integer or fractional parts such as `.123` and `20.` during [data import](https://docs.victoriametrics.com/#how-to-import-time-series-data). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3544).
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly parse durations with uppercase suffixes such as `10S`, `5MS`, `1W`, etc. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3589). * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly parse durations with uppercase suffixes such as `10S`, `5MS`, `1W`, etc. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3589).
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix a panic during target discovery when `vmagent` runs with `-promscrape.dropOriginalLabels` command-line flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3580). The bug has been introduced in [v1.85.0](https://docs.victoriametrics.com/CHANGELOG.html#v1850).
## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3) ## [v1.85.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.85.3)

View file

@ -1186,9 +1186,7 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
} }
if labels.Len() == 0 { if labels.Len() == 0 {
// Drop target without labels. // Drop target without labels.
if !*dropOriginalLabels { droppedTargetsMap.Register(originalLabels, swc.relabelConfigs)
droppedTargetsMap.Register(originalLabels, swc.relabelConfigs)
}
return nil, nil return nil, nil
} }
// See https://www.robustperception.io/life-of-a-label // See https://www.robustperception.io/life-of-a-label
@ -1203,9 +1201,7 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
address := labels.Get("__address__") address := labels.Get("__address__")
if len(address) == 0 { if len(address) == 0 {
// Drop target without scrape address. // Drop target without scrape address.
if !*dropOriginalLabels { droppedTargetsMap.Register(originalLabels, swc.relabelConfigs)
droppedTargetsMap.Register(originalLabels, swc.relabelConfigs)
}
return nil, nil return nil, nil
} }
// Usability extension to Prometheus behavior: extract optional scheme and metricsPath from __address__. // Usability extension to Prometheus behavior: extract optional scheme and metricsPath from __address__.

View file

@ -276,6 +276,10 @@ func (dt *droppedTargets) getTargetsList() []droppedTarget {
} }
func (dt *droppedTargets) Register(originalLabels *promutils.Labels, relabelConfigs *promrelabel.ParsedConfigs) { func (dt *droppedTargets) Register(originalLabels *promutils.Labels, relabelConfigs *promrelabel.ParsedConfigs) {
if *dropOriginalLabels {
// The originalLabels must be dropped, so do not register it.
return
}
// It is better to have hash collisions instead of spending additional CPU on originalLabels.String() call. // It is better to have hash collisions instead of spending additional CPU on originalLabels.String() call.
key := labelsHash(originalLabels) key := labelsHash(originalLabels)
currentTime := fasttime.UnixTimestamp() currentTime := fasttime.UnixTimestamp()
@ -301,7 +305,7 @@ func (dt *droppedTargets) Register(originalLabels *promutils.Labels, relabelConf
func labelsHash(labels *promutils.Labels) uint64 { func labelsHash(labels *promutils.Labels) uint64 {
d := xxhashPool.Get().(*xxhash.Digest) d := xxhashPool.Get().(*xxhash.Digest)
for _, label := range labels.Labels { for _, label := range labels.GetLabels() {
_, _ = d.WriteString(label.Name) _, _ = d.WriteString(label.Name)
_, _ = d.WriteString(label.Value) _, _ = d.WriteString(label.Value)
} }