Hi,
I recently started my adventure with Grafana and I need to create a panel that will show the storage status of the plugged-in drives to the server. So far, I collect data on computer usage/parameters via the Telegraf plugin and store it in the InfluxDB v2 database (Flux queries). I came across various dashboards on the Internet and a specific panel caught my particular attention.
I have read a lot about data transformation in Grafana, but I still have a problem with processing the data by which the table draws incorrectly.
First of all, I have a problem that the rows are placed as columns.
In your Influx Data Explorer screenshot, I do not see fields for Used, Free and Total. Do you have these values for each device?
EDIT: Nevermind, I was looking in the wrong place. I think you can avoid the Grafana tranformation by massaging the data in Influx first. Have you tried using a pivot function?
Hey, thanks for reply. I have not tried to use this pivot function, although I have come across it on the Internet. Unfortunately, I don’t have much knowledge in the Flux language (I’ve always used SQL). So could you help me modify my query syntax using the pivot function?
I don’t believe this but I tried to do it myself before you wrote the post and it worked!
But I also have a question about the use of |> last(column: "") and |> yield(name: "last") (not sure if I used them correctly). I did some tests and when I use |> last(column: "") only one last value is shown (I think it’s a good solution, but I don’t know its disadvantages and if this field should be empty).
Below I will post some tests with |> last(column: "") and |> yield(name: "last") - if I may ask, please advise me what to improve.
Hi @misiekdp and congrats on getting the solution.
If you just want the last row returned in your query, then I think this would work:
|> last()
The yield statement is just to deliver the data, and in Grafana, it’s often not even needed (although it does not hurt anything). In Influx Data Explorer, you need to put it in, usually as the last line of your query, and it can be any word in quotes, such as:
|> yield(name: "kalamazoo")
Finally, I would suggest you change the order of the statements to be as shown and make sure your query still works with this order:
I believe that last error about no column "_value" exists is due to the way Grafana parses the result from InfluxDB. If a _value column is found, it is assumed to be a time-series. The quick workaround is to add the following rename() function. Try adding this after the pivot and see if that eliminates the error. |> rename(columns: {_value: "something"})
Hi @misiekdp I usually use Influx Data Explorer as the place for debugging my Flux code. I’m sorry but I cannot tell from my end what else might require changing.