InfluxDB: Fix corner case where index is too large in ALIAS field #41562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in InfluxDB, when you have a query like this:
SELECT value from "computer.cpu"
, when the result is drawn on the screen, the time-series will be named "computer.cpu".you can change this by using the ALIAS field in the query, there are many formats supported by the ALIAS field, but there is one where you use numbers, like
$0
or[[1]]
. in this case the following will happen:computer.cpu
)["computer","cpu"]
AL $1
, the timeseries-name will beAL cpu
there is a problem, if you specify an index that is higher than the length of the array, the series will be named
undefined
. for example, if your measurement is namedcomputer.cpu
and you use the aliasAL $7
, the series will be namedAL undefined
.this pull request changes this so that the series name will become
AL $7
in this case. this is consistent with how it happens in the influxdb-alerting-go-code, and also consistent with the approach that when we have a variable that does not exist, we just keep the original text.how to test:
you need to have measurement with names that contain periods. the simplest way is to manually insert such values into influxdb:
make devenv sources=influxdb
docker ps
, and find the ID of the influxdb container.docker exec -it <docker_container_id> influx write -b mybucket -o myorg -t mytoken 'name.with.dots v=40'
gdev-influxdb-influxql
, and choose the measurement "name.with.dots", choose the field "v", and try out ALIAS values.