InfluxDB: fix numeric aliases in queries (#41531)

* influxdb: alerting: handle out-of-range numeric aliases

* influxdb: updated documentation
This commit is contained in:
Gábor Farkas
2021-11-11 09:18:06 +01:00
committed by GitHub
parent dbe78e47b1
commit eb47a58029
3 changed files with 12 additions and 1 deletions

View File

@@ -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])
}

View File

@@ -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"]