Performance issues with New-UDGrid

I’m having problems trying to figure out how to handle large amounts of data when working with New-UDGrid. I’m testing it out with the security log on my computer as it has close to 30k entries in the log. I’m struggling to understand how the scheduled endpoints really work. I was under the impression that the cached variables are store locally but when I refresh the page for my dashboard it takes about 90 seconds or so before it loads the grid again. Also, the filtering on the grid is very slow with that much data. Is that just a downside of a grid? Lastly, not a performance issue but the date time formatting doesn’t seem to work for me. Regardless of the formatting I choose the date always stays at the default format of 2018-12-28T00:06:59.5813278-08:00. The TimeCreated property is of the datetime type.

Below is the current dashboard I’m using to test:

$schedule = New-UDEndpointSchedule -Every 5 -Minute

$endpoint = New-UDEndpoint -Schedule $schedule -Endpoint {
    $cache:securityLog = Get-WinEvent -FilterHashtable @{logname = 'Security'} |
        Select-Object -Property 'TimeCreated', 'Id', 'TaskDisplayName', 'LevelDisplayName'
}

$dashboard = New-UDDashboard -Title 'Test' -Content {
    New-UDElement -Tag div -Attributes @{
        className = 'container'
    } -Content {
        $gridParams = @{
            Title = 'Security Log'
            Headers = @('Time Created', 'Id', 'Task', 'Level')
            Properties = @('TimeCreated', 'Id', 'TaskDisplayName', 'LevelDisplayName')
            DefaultSortColumn = 'TimeCreated'
            DefaultSortDescending = $true
            AutoRefresh = $true
            RefreshInterval = 300
            DateTimeFormat = 'LLLL'
            Endpoint = {$cache:securityLog | Out-UDGridData}
        }
        New-UDGrid @gridParams
    }
}

Get-UDDashboard | Stop-UDDashboard

Start-UDDashboard -Dashboard $dashboard -Port 8001 -AutoReload -Endpoint $endpoint

You’ll want to use server side processing: https://github.com/ironmansoftware/universal-dashboard/blob/master/examples/grid/high-performance-sql-grid.ps1

The problem that you’re having right now is that all 30K records are being serialized and returned from the server and then sent to the grid. If you filter and page on the server, it should be much faster.

Below is the code I have now but I’m not sure I’ve got it right. There was some guess work I had to do as I’m not really sure how to properly implement the server side processing variables. I didn’t follow your example exactly as I don’t have a SQL server set up currently.

Using the server side processing the page now loads the grid in a couple seconds but there are still performance problems with the filter and paging. It’s either a bit too slow or the behavior is a bit erratic as it tries to filter or go to the next page. Also, when server side processing is enabled the auto refresh stops working.

Lastly, not a performance problem but the date time formatting doesn’t work as expected for me. The date isn’t being formatted at all.

Any help is definitely appreciated! :grinning:

$schedule = New-UDEndpointSchedule -Every 5 -Minute

$endpoint = New-UDEndpoint -Schedule $schedule -Endpoint {
    $cache:securityLog = Get-WinEvent -FilterHashtable @{logname = 'security'} |
        Select-Object -Property 'TimeCreated', 'Id', 'TaskDisplayName', 'LevelDisplayName'
}

$dashboard = New-UDDashboard -Title 'Security Log' -Content {
    New-UDElement -Tag div -Attributes @{
        className = 'container'
    } -Content {
        $gridParams = @{
            ServerSideProcessing = $true
            Headers = @('Time Created', 'Id', 'Task', 'Level')
            Properties = @('TimeCreated', 'Id', 'TaskDisplayName', 'LevelDisplayName')
            DefaultSortColumn = 'TimeCreated'
            AutoRefresh = $true
            DateTimeFormat = 'LLLL'
            Endpoint = {
                $cache:securityLog | Where-Object {
                    $_.Id -like "*$filterText*" -or
                    $_.TaskDisplayName -like "*$filterText*" -or
                    $_.LevelDisplayName -like "*$filterText*"
                } | Sort-Object -Property $sortColumn -Descending:$sortAscending |
                        Select-Object -First $take -Skip $skip |
                        Out-UDGridData -TotalItems $cache:securityLog.Count
            }
        }
        New-UDGrid @gridParams
    }
}

Get-UDDashboard | Stop-UDDashboard

Start-UDDashboard -Dashboard $dashboard -Port 8002 -AutoReload -Endpoint $endpoint -Design
1 Like

hi Adam, what is the point/Effect of the “Total Items” parameter?