Use target as name for aliased queries

This commit is contained in:
Andreas Christou
2026-01-13 17:53:02 +00:00
parent 586410d8b5
commit e99d7da667
2 changed files with 119 additions and 1 deletions
+6 -1
View File
@@ -200,8 +200,11 @@ func (s *Service) toDataFrames(response *http.Response, refId string, fromAlert
return nil, err
}
aliasRegex := regexp.MustCompile(`(alias\(|aliasByMetric|aliasByNode|aliasByTags|aliasQuery|aliasSub)`)
frames = data.Frames{}
for _, series := range responseData {
aliasMatch := aliasRegex.MatchString(series.Target)
timeVector := make([]time.Time, 0, len(series.DataPoints))
values := make([]*float64, 0, len(series.DataPoints))
@@ -217,7 +220,9 @@ func (s *Service) toDataFrames(response *http.Response, refId string, fromAlert
tags := make(map[string]string)
for name, value := range series.Tags {
if name == "name" {
if fromAlert {
// Queries with aliases should use the target as the name
// to ensure multi-dimensional queries are distinguishable from each other
if fromAlert || aliasMatch {
value = series.Target
}
}