okay so basically i want all the cells to be displayed one after another but it goes to the default of this
I have also tried rearranging the data in while writing the query but still it has no effect. (looks to me like that grafana is rearranging it numerically but only with the first digit, for example 14 come before 2, because the first digit of 14 {1} is smaller then 2)
I just need it to say [Cell 1, Cell 2, Cell 3…]
What is your datasource as is right not those values are not numeric hence what you are seeing
Influxdb, do you think that is playing a part?
Any data source would have this issue
C4 will always come before C19999
Maybe use a replace function or regex to create another column to remove non numeric value to sort on
I dont think that might be a good solution. because i dont think that will just change the placement of the gauges it will only change the name of the gauge, right?
I need the gauges to rearranged according to the upper image.
Please explain the sorting of this upper image
Basically if you look right now. The Cells are numbered (looking at only the cell Currents column).
1…10…11…12…13…14…15…16…17
18…2…3… 4… 5… 6… 7… 8… 9
To make sure that the data is easier to read, i need to make sure that it is in the following configuration.
1…2…3…4…5…6…7…8…9
10…11…12…13…14…15…16…17…18
(as also marked with the yellow numbering in the picture)
As i said before, to me like that grafana is trying to rearrangi it numerically but only with the first digit, for example 14 come before 2, because the first digit of 14 {1} is smaller then 2
In order to be more visually easier to read, i need it to be in this format.
Again grafana is not trying to rearrange it numerically because it is not numeric
It is alphanumeric string. So grafana is doing it accurately
Using flux function or regex stripff the strings to creat a column you can use to sort on as recommended earlier and the current column to display on gauge
For example in SQL Server notice the order by
Im going to be fully honest, i dont actually know what you just did and how you did it , but hey thank you for atleast pointing me in the right direction
Is there anyway i can ask you to write this in flux, i have been at it for the last two hours and i can’t seem to get it right
Please post what you have tried?
Work your way up by carving the flux query in influxdb db 8086 first to see how you can remove the Cell string
// Generate a sequence of numbers from 1 to 22
numbers = range(start: 1, stop: 22, step: 1)
// Map each number to the desired format
src = numbers
|> map(fn: (n) => ({
metric: “Cell " + string(v: n) + " Current”,
value: n
}))
src
|> sort(columns: [“metric”], desc: false)
|> map(fn: (r) => ({
metric: r.metric,
value: int(v: string(v: r.metric) |> strings.replace(old: "Cell ", new: “”) |> int())
}))
|> sort(columns: [“value”], desc: false)
This is the code that was generated from chatgpt, after i asked it to translate your code into flux language. I have also gone through the influxdb, the thing is that “Cell 1”, “Cell 2”, “Cell 3”,… are the names of the measurements and “Current” is a field in those measurements. I can’t really get rid of it without losing readability
chatGpt nice. Ok maybe a different approach then. maybe instead of manipulating the measurement route how about maybe a case statememt or switch statement where in you define a sort column or value based on measurement name or adding a sorting tag for each measurement. Resd the doc not chatgpt
I tried this but still no go.
import "strings"
from(bucket: "electric_boogaloo")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_field"] == "current")
|> map(fn: (r) => ({r with _replace: strings.replaceAll(v: r._measurement, t: "Cell", u: "")}))
|> map(fn: (r) => ({r with _trim: strings.trimSpace(v: r._replace)}))
|> map(fn: (r) => ({r with _sort: int(v: r._trim)}))
|> sort(columns: ["_sort"])
hey can you tell me what you are doing with the replaceAll function. Like can you give me a logic on how i can achieve what i need. At this point being new to flux, i dont really, which logic will work and which will not. Hence i just need a rough attack plan…then it just comes down how much time i have to give to this to understand this.
YOOOOOOO, I did it!!! It is one of the most getto solutions i could find to this but it works!!!
I basically just put a “_” for the Cells after 9 and that rearranged it in the correct way. Now all i have to do is use overrides and change the display names and boom we in business.
Is it a good solution…no, is it a tedious solution…no, does it work…YES!!
and hey @yosiasz, thank you for all your help. You are clearly one of the best and most competent grafana users and all i want to say is thank you.