Bar Chart results doesn't produce correct results when more than 2 columns are present

Grafana version: 10.4.3 (6e6fbf6a34)

I’m trying to create a chart to show a representation of current disk space and the available space left for each one of the servers returned in my query (sample below).

I could get the chart to work only when I have HostName and FreeGB columns, adding the SizeGB in the query results, make everything go crazy, and nothing seems to work or make sense.

I’m not sure if the Bar Chart would be the best option, I would like very much to use the “Stat Chart”, it seems a good idea but to represent my data but it proved too much for me, and the Bar Chart was the closest thing I could get to show something representative for each one of the servers, here it is the data for consideration:

Using the “NORMAL” stacking I get these weird results in the bars which doesn’t necessary represent the numbers behind them, considering all servers have the same disk size of 126GB the bars diverge for each record, and the green representing the free space doesn’t seem to make sense of the actual numbers:

And on the example below, the stacking is set to “100%”, and it shows results to 105% (in the previous chart the numbers went to 240GB - how?) - I really don’t understand how this Bar Chart is supposed to work.

I did try to limit the max and min but no effect from using the limits and calculations, I think I’m missing something very important and seems very basic but I’m completely new to this:

Thanks in advance for any help!

please post your sample data not as an image but as usable inline csv like following

host,FreeGb,SizeGB
PAUE,84,126

listing all data.

so when stacking it is doing what it is supposed to. the numbers will naturally look bigger, it is stacking it

with stacking off, it does what it is supposed to

My apologies, the image was just a description to illustrate my question, I hope the sample below can be in anyway helpful, thanks for looking into my question!

let Sample = datatable (HostName: string, FreeGB: real, SizeGB: real) [
    "PAUE-SPSG-001",real(83.98),real(126.45),
    "PAUE-SPSG-002",real(74.78),real(126.45),
    "PAUE-SPSG-003",real(83.76),real(126.45),
    "PAUE-SPSG-004",real(84.86),real(126.45),
    "PAUE-SPSG-005",real(83.78),real(126.45),
    "PAUE-SPSG-006",real(79.25),real(126.45),
    "PAUE-SPSG-007",real(99.83),real(126.45),
    "PAUE-SPSG-008",real(100.14),real(126.45),
    "PAUE-SPSG-009",real(100),real(126.45),
    "PAUE-SPSG-010",real(100.66),real(126.45),
    "PAUE-SPSG-011",real(99.81),real(126.45)
];
Sample
HostName FreeGB SizeGB
PAUE-SPSG-001 83.98 126.45
PAUE-SPSG-002 74.78 126.45
PAUE-SPSG-003 83.76 126.45
PAUE-SPSG-004 84.86 126.45
PAUE-SPSG-005 83.78 126.45
PAUE-SPSG-006 79.25 126.45
PAUE-SPSG-007 99.83 126.45
PAUE-SPSG-008 100.14 126.45
PAUE-SPSG-009 100 126.45
PAUE-SPSG-010 100.66 126.45
PAUE-SPSG-011 99.81 126.45
"HostName","FreeGB","SizeGB"
PAUE-SPSG-001,83.98,126.45
PAUE-SPSG-002,74.78,126.45
PAUE-SPSG-003,83.76,126.45
PAUE-SPSG-004,84.86,126.45
PAUE-SPSG-005,83.78,126.45
PAUE-SPSG-006,79.25,126.45
PAUE-SPSG-007,99.83,126.45
PAUE-SPSG-008,100.14,126.45
PAUE-SPSG-009,100,126.45
PAUE-SPSG-010,100.66,126.45
PAUE-SPSG-011,99.81,126.45

what result would you like to see?

Hey Joachim,

In my mind the Bar Chart should show something representative of the amount of disk space left followed by the amount used, so looking at the bar I would expect to see something like the “HOSTNAME” followed by a bar representing the space left and the amount used in the end:

SERVER1 0000000000000## 80%
SERVER2 00000000000000# 90%

Or the inverse is also ok, we could show how much used and the percentage remaining:

SERVER1 0000000000000## 20%
SERVER2 00000000000000# 10%

Honestly, I’m not sure the Bar Chart is the best option, please correct my assumption if I’m mistaken

1 Like

ok…why you dont calculate the “not free” size.
So you always end up at 100%

oh sorry … Raymond does what I ment :wink:

1 Like

Hi Raymond,

I understand your idea in using TRANSFORMATION to get the calculated values, and this was one of my first ideas when I started on Bar Chart, but it didn’t work (I will explain ahead with the screenshots).

I did skip the TRANSFORMATIONs and I got the values directly from my KQL in my query as you can see below:

SharePoint_CL
| mv-expand OSDriveC
| evaluate bag_unpack(OSDriveC)
| where EnvironmentName in ($var_EnvironmentName) and EnvironmentType in ($var_EnvironmentType) and isnotempty(SizeGB) and TimeGenerated >= ago(5m)
| extend Used = SizeGB - FreeGB
| extend Percentage = (FreeGB / SizeGB) * 100
| project HostName, Used, Percentage
| sort by HostName asc

The problem is not the query or the transformations, the real problem at least for me is in the bar chart, I don’t get the same results like you do in your example, looking at my results in the pictures below you can see something is missing or wrong on my side, here it two examples:

  • Using STACKED 100% - Why is the chart showing 105% instead of 100%?

  • Using NORMAL- I get these weird ranges (note: all the disk sizes are 126GB)

I’m not sure but I’m starting to think the Bar Gauge could be the best option

try setting the max value to 100?

I also prefer the bar gauge over the bar chart

even the table view is nice as well:

I did try to set to 100 on Soft Max, I give up, this thing doesn’t work

i posted a screenshot of exactly how to make it work, what is not working for you?

It seems your charts are comparing apples and oranges:
Used (SizeGB - FreeGB) is in Gigabytes
Percentage ((FreeGB / SizeGB) * 100) is a number between 0 and 100.

You should put Used and FreeGB in your chart. Those are both in Gigabytes.