Search code examples
azureazure-functionskql

Disk Usage Forecast with KQL and Azure


I've been struggling past few days to create a graph for a dashboard I'm working on Azure.

The idea is to get the data collected on Perf, then use it to predict the disk usage with series_decompose_forecast.

Here is what I have right now:

    let DiskSpace = Perf
    | where Computer == "COMPUTERNAME" 
        and ObjectName == "LogicalDisk" 
        and InstanceName == "F:" 
        and CounterName == "% Free Space"
    | where TimeGenerated > ago(90d)
    | extend Timestamp = TimeGenerated, DiskIdentifier = InstanceName, FreeSpace = CounterValue
    | project Timestamp, DiskIdentifier, FreeSpace;
DiskSpace
    | make-series FreeSpace=max(FreeSpace) default=long(null) on Timestamp from ago(60d) to now()+24h*7*4 step 12h
    | extend FreeSpace=series_fill_backward(FreeSpace), forecast=series_decompose_forecast(FreeSpace, 7*4*2)
    | render timechart

The second part, the "make-series" is from an old question on stack, and I've been trying to adapt it to use for my own purposes. This query creates a graph for me, but the data returned from the forecast is null, and I'm not sure why. Any idea what I'm missing here?

Cheers, and thanks in advance.


Solution

  • It works with default=long(0).

    range timestamp from ago(55d) to now() step 4h
    | extend FreeSpace = 50 + (now()-timestamp)/1d
    | make-series FreeSpace=max(FreeSpace) default=long(0) on timestamp from ago(60d) to now(24h*7*4) step 12h
    | extend FreeSpace=series_fill_backward(FreeSpace), forecast=series_decompose_forecast(FreeSpace, 7*4*2)
    | render timechart