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:
parent
dbe78e47b1
commit
eb47a58029
@ -120,6 +120,7 @@ You can switch to raw query mode by clicking hamburger icon and then `Switch edi
|
||||
|
||||
- $m = replaced with measurement name
|
||||
- $measurement = replaced with measurement name
|
||||
- $1 - $9 = replaced with part of measurement name (if you separate your measurement name with dots)
|
||||
- $col = replaced with column name
|
||||
- $tag_exampletag = replaced with the value of the `exampletag` tag. The syntax is `$tag*yourTagName`(must start with`$tag*`). To use your tag as an alias in the ALIAS BY field then the tag must be used to group by in the query.
|
||||
- You can also use [[tag_hostname]] pattern replacement syntax. For example, in the ALIAS BY field using this text `Host: [[tag_hostname]]` would substitute in the `hostname` tag value for each legend value and an example legend value would be: `Host: server1`.
|
||||
|
@ -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"]
|
||||
|
Loading…
Reference in New Issue
Block a user