I am trying to set an “ALIAS BY” using flux lang. However I do not see an option to do so. Is this option implemented yet? It is implemented if I use influxql, but the option is not available when I change the data source to flux.
Did you managed to solve that problem in some easy way?
I do have graphs of the same data soruce (solar energy) with time shifts where I compare Today, Yesterday and Same Day year ago. and the results look terible and confusing.
This is the only topic I’ve found on this issue and can’t tell if it’s been resolved.
Using influxDB Cloud/Flux query language trying to rename the results of queries to be human friendly on the legend. Is there a command/method for this available in grafana?
this gives back 4 values ( I1, I2, I3, IAvg) in grafana
but i would like to have it renamed ‘I Line 1’, ‘I Line 2’, ‘I Line 3’ and ‘I Average’
What do I need to do?
I think Grafana should work out the possibility to rename where we can also change the colors of the values (i think ‘alias’ in flux is difficult since we have multiple values from one ‘querry’ )
Each line is a _measurement. Is anyone familiar with a way to change the legend name to the _measurement it is representing. I tried the grafana name function method above, but no luck.
So while it is definitely a bummer that Flux does not have the ‘alias’ option like InfluxQL did in Grafana, I have found that using the Overrides is perfectly acceptable.
Thanks for the welcome and for getting back on this. Also tried to work with the overrides but as soon as I do some transformations on the data (like combining two or more queries into 1 final result) all queries are named _value or Value making them hard to distinguish using the override option. Tried all kinds of solutions such as setting the _field via a map or set command and using the suggested ${__field.name} as name override but without any luck. Really frustrating since this should be something so easy to do.
A few tricks that I’ve learned in converting influxql queries to flux queries for grafana with regards to alias by, in addition to what others have written here. It’s best to use the influxdb v2 web interface > Explore, to test queries and achieve the results you are looking for, because the query results that grafana displays are slightly modified (for example, _field is not displayed as _field when _time is present in the result set):
To my knowledge, you can only insert variable text (from grafana or influx row values) as column names by setting _field to the variable text (using set() or map(), I prefer map()) and using pivot. As far as I’m aware, pivot() is the only way to convert values (such as values of _field) into column names. Here’s an example of the a possibility:
Pivot in #1 above requires _time to be present in the data set. For aggregation functions such as sum() or mean(), _time is removed. In influxql, epoch 0 was returned as time along with the result. In flux, _time is dropped. When using _field, grafana expects a time result to be present, otherwise it won’t use _field correctly. You can add fake time back into the data set after the aggregation function in flux and pivot using the fake time to achieve the result you are looking for. The flux time() function is used to add epoch 0 back in the result: