mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: fix numeric aliases in queries (#41531)
* influxdb: alerting: handle out-of-range numeric aliases * influxdb: updated documentation
This commit is contained in:
@@ -113,7 +113,7 @@ func formatFrameName(row Row, column string, query *Query) string {
|
||||
}
|
||||
|
||||
pos, err := strconv.Atoi(aliasFormat)
|
||||
if err == nil && len(nameSegment) >= pos {
|
||||
if err == nil && len(nameSegment) > pos {
|
||||
return []byte(nameSegment[pos])
|
||||
}
|
||||
|
||||
|
||||
@@ -293,6 +293,16 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
query = &Query{Alias: "alias $0 $1 $2 $3 $4"}
|
||||
result = parser.Parse(prepare(response), query)
|
||||
frame = result.Responses["A"]
|
||||
name = "alias cpu upc $2 $3 $4"
|
||||
testFrame.Name = name
|
||||
testFrame.Fields[1].Config.DisplayNameFromDS = name
|
||||
if diff := cmp.Diff(testFrame, frame.Frames[0], data.FrameTestCompareOptions()...); diff != "" {
|
||||
t.Errorf("Result mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
query = &Query{Alias: "alias $1"}
|
||||
result = parser.Parse(prepare(response), query)
|
||||
frame = result.Responses["A"]
|
||||
|
||||
Reference in New Issue
Block a user