Skip to content

Commit cb92a78

Browse files
committed
update to include log
1 parent d10c948 commit cb92a78

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/query/querier.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,41 +378,46 @@ func (q *querier) Select(ctx context.Context, _ bool, hints *storage.SelectHints
378378
func (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms ...*labels.Matcher) (storage.SeriesSet, storepb.SeriesStatsCounter, error) {
379379
if q.enablePreAggregationLabelRewrite {
380380
hasNameLabel, needLabelRewrite := false, false
381+
var nameLabelMatcher *labels.Matcher
381382
for _, m := range ms {
382383
if m.Name == labels.MetricName {
383384
hasNameLabel = true
384385
if m.Type == labels.MatchEqual {
385386
for _, suffix := range q.aggregationStandardSuffixes {
386387
if strings.HasSuffix(m.Value, suffix) {
387388
needLabelRewrite = true
389+
nameLabelMatcher = m
388390
break
389391
}
390392
}
391393
break
392394
} else {
393-
level.Info(q.logger).Log("msg", "Skipping aggregation label rewrite attempt", "reason", "non-equal name matcher", "name_matcher", m, "labels", ms)
395+
level.Info(q.logger).Log("msg", "Skipping aggregation label rewrite attempt", "reason", "non-equal name matcher", "name_matcher", m)
394396
}
395397
}
396398
}
397399
if !hasNameLabel {
398-
level.Info(q.logger).Log("msg", "Skipping aggregation label rewrite", "reason", "no metric name matcher found", "labels", ms)
400+
level.Info(q.logger).Log("msg", "Skipping aggregation label rewrite", "reason", "no metric name matcher found")
399401
}
400402
if needLabelRewrite {
401403
hasAggregationLabel := false
402404
for i, m := range ms {
403405
if m.Name == q.aggregationLabelName {
406+
level.Info(q.logger).Log("msg", "Rewriting aggregation label", "original_matcher", m, "name_matcher", nameLabelMatcher, "new_value", q.rewriteAggregationLabelTo)
404407
hasAggregationLabel = true
405408
ms[i].Type = labels.MatchEqual
406409
ms[i].Value = q.rewriteAggregationLabelTo
407410
break
408411
}
409412
}
410413
if !hasAggregationLabel {
411-
ms = append(ms, &labels.Matcher{
414+
newMatcher := &labels.Matcher{
412415
Name: q.aggregationLabelName,
413416
Type: labels.MatchEqual,
414417
Value: q.rewriteAggregationLabelTo,
415-
})
418+
}
419+
level.Info(q.logger).Log("msg", "Adding aggregation label", "new_matcher", newMatcher, "name_matcher", nameLabelMatcher)
420+
ms = append(ms, newMatcher)
416421
}
417422
}
418423
}

0 commit comments

Comments
 (0)