mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmselect/promql: make sure that label_replace() doesn't create an empty dst_label if the src_label doesn't match regex
This commit is contained in:
parent
cc482b89a3
commit
a77bb09e69
1 changed files with 1 additions and 1 deletions
|
@ -1873,12 +1873,12 @@ func labelReplace(tss []*timeseries, srcLabel string, r *regexp.Regexp, dstLabel
|
||||||
replacementBytes := []byte(replacement)
|
replacementBytes := []byte(replacement)
|
||||||
for _, ts := range tss {
|
for _, ts := range tss {
|
||||||
mn := &ts.MetricName
|
mn := &ts.MetricName
|
||||||
dstValue := getDstValue(mn, dstLabel)
|
|
||||||
srcValue := mn.GetTagValue(srcLabel)
|
srcValue := mn.GetTagValue(srcLabel)
|
||||||
if !r.Match(srcValue) {
|
if !r.Match(srcValue) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
b := r.ReplaceAll(srcValue, replacementBytes)
|
b := r.ReplaceAll(srcValue, replacementBytes)
|
||||||
|
dstValue := getDstValue(mn, dstLabel)
|
||||||
*dstValue = append((*dstValue)[:0], b...)
|
*dstValue = append((*dstValue)[:0], b...)
|
||||||
if len(b) == 0 {
|
if len(b) == 0 {
|
||||||
mn.RemoveTag(dstLabel)
|
mn.RemoveTag(dstLabel)
|
||||||
|
|
Loading…
Reference in a new issue