-
Notifications
You must be signed in to change notification settings - Fork 22
Howto add alias? #42
Comments
This is also a commity question, see https://community.grafana.com/t/no-alias-by-when-using-flux/15575 |
A further problem with not having aliases is that you cannot style different queries on the same measurement differently as they will appear as the same query in the visualisation editor. |
I am stuck due to this while integrating flux in Grafana dashboard. Looking for a way to make it work. |
Yes, same issue here! |
I was able to work around this by renaming the columns that the flux plugin does put in the legend for a series. Assuming that what you are changing the "title" of the series to will be unique across the series, this will not cause any issue. If this is not the case though, it will merge the data as the "title" acts as a key. The trick is to remove all the columns except the necessary ones, replacing the specilal _field column which is displayed by whatever unique string you want. In @andig case it would be r.title. This is done in the map. Note that naming each part isn't necessary, just easier to show what I'm doing.
|
+1 on this issue. Can't really have a customer-facing dashboard with current label format. |
https://github.com/grafana/influxdb-flux-datasource/blob/master/src/response_parser.ts#L30 Changing alias to measurement name only should be trivial, but I wonder what was the reason for such format ... "_measurement + _field + tag keys/values" Especially given |
@ mdb5108 Hi, Your solution is kinda getting me in the right direction. I am wanting to use flux and grafana to graph rainfall. I'm also wanting to do timeshift and overlay several days with the appropriate legend. It seems I must use flux or another DB to do timeshifting. Your solution has got me a little closer to the end goal but unfortunately, I am not fluent enough to get the DB to answer the questions I want to ask . Instead of FinalOutput = ["_field", "_time", "_value"] with _value = r.title I would like to have _value = eg Today, yesterday, this week. I would appreciate any help you could offer. |
It's been awhile since I've looked at this, and I haven't tested this code, but I suspect you could do something like this. Using the time manipulation documented here: https://docs.influxdata.com/flux/v0.50/guides/manipulate-timestamps/. Note that I offset in the range to get the data, and then reset it back in the map function so that the timeshift is overlayed on top of the normal range.
|
Hi, Thanks for your time looking at this for me, very much appreciated. Below is the query I am using in Grafana that give me the one day graph I am wanting. I am using the latest addon versions of both Grafana and Influxdb in the latest release of homeassistant. from(bucket: "homeassistant/autogen") Based on that I have modified your example to the following removing "+postfix". I am assuming that what is in quotes at the end of |> createTimelapse($range, offset:1d, "7d") ie "7d" is what should appear in the legend. I am only getting an error message "time info: undefined". import "experimental" Getting closer I think but still scratching my head. Once again your help is much appreciated. I have a long way to go to become as proficient at this as I would like too. |
Unfortunately I'm not sure. What I will say is that I was not confident that $range = "start: , stop: " which this solution depends on. You may look into that further. The error should give you a line and column that it is on though I think. That will help too. Another thing is that I don't know how reliable the experimental namespace actually is, and for all I know it requires some other things to work. Also, you have a lot of syntax errors in the code that you pointed. createNormal has an extra comma after fnTimeSkew, createTimelapse still takes in a offsetString and passes it to createNormal even though createNormal no longer has that parameter, the creation of the normal table still calls createNormal with an empty string although it no longer takes the parameter, in the weekOff call to createTimelapse you pass on offset of 1 day but you then pass the string 7d (for 7 days) which you should probably not pass at all and rename the table to dayOff. |
I was able to fix it a little simpler than using map() - using set() at the very end of the pipe works just as well:
In fact, I had some trouble with map() in a graph with multiple queries (might be my own fault, but I couldn't figure it out); set() worked instantly. |
+1 to this request. UPD. The solution described above does not work with the |
+1 here as well. |
@brettlg I am using Flux to show the current temperature and yesterday's temperature in the same graph. Thanks to @mdb5108 for the code. Maybe you can rework it to display your rain data.
|
I tried the mapping and column deletion approach, but I get "Metric request error":
This is my query (that works fine in InfluxDB Data Explorer):
The reason I want to have an alias is to avoid this resizing behavior on mobile, caused by the long title being generated by adding all tags: |
The workaround defined above works for me in Grafana v7.1.0 (8101355285), with the new integrated InfluxDB data source |
Wondering how I could alias a query to make it visually more appealing, i.e. rename
data value title=HcStarts type=workinghourstotal uuid=dcbb3a00-c45a-11e6-9917-dba8816dc812
toHcStarts
?The text was updated successfully, but these errors were encountered: