Hi,
-
What Grafana version and what operating system are you using? 11.5.2 in Docker
-
What are you trying to achieve?
The ultimate goal is to have a time series with one line per user, showing the evolution of the occupied size for a specific share (filtered byshare like '%blah%'
), along with the delta between the latest result and the previous one. -
How are you trying to achieve it?
I have the graph displaying all of that, but I don’t know how to include the delta somewhere. I don’t want to plot the delta in order to keep the graph clean.
For now, the SQL query is like :
SELECT
date(time) AS time,
user,
SUM(size) AS total_size,
SUM(size) - LAG(SUM(size)) OVER (PARTITION BY user ORDER BY date(time) ASC) AS delta
FROM user_storage.storage
WHERE size > 150 AND share LIKE '/home%'
GROUP BY user, date(time)
ORDER BY time ASC
I also tried to cast the delta into a char(10)
, but it creates a new line for each user/delta couple.
I tried to hide the delta into the graph and edit the “Display name” to add this information inside the legend, but I did not find the right variable to display an other SQL field here.
The SQL table is like :
Field | Type |
---|---|
id | int(11) |
time | timestamp |
share | varchar(200) |
user | varchar(50) |
size | float |
Previous SQL query returns :
Time | delta user1 | delta user2 | total_size user1 | total_size user2 |
---|---|---|---|---|
2025-03-10 01:00:00 | 0 | 245 | 520 | 494 |
2025-03-17 01:00:00 | 18.8 | 438 | 539 | 932 |
2025-03-24 01:00:00 | 546 | 163 | 1085 | 1095 |
As you can see, for the user2 the last delta is equal to the last total_size - pervious total_size (1095 - 932).
Thanks for any suggestions.