Dashboard help with display numbers and $null values

Good Morning All,

I’m attempting to create a POC dashboard to help display some Security statistics and i’m running into some issues.
Overview:
I’m looking to create a Security Dashboard to displays monthly and annual line graph data.

Configuration:
I have a script that will query SAAS API and download the metrics every 5 minutes.

$annualResponse.data | gm

TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition


Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
computer NoteProperty System.Management.Automation.PSCustomObject computer=@{connector_guid=guid; hostname=hostname; external_ip=67.230.213.66; active=True; network_addresses=System.Object; links=}
connector_guid NoteProperty string connector_guid=44a2be60-a752-4e22-9659-31f244b821db
date NoteProperty datetime date=7/14/2020 8:57:41 AM
event_type NoteProperty string event_type=Microsoft Excel compromise
event_type_id NoteProperty long event_type_id=1107296263
file NoteProperty System.Management.Automation.PSCustomObject file=@{disposition=Unknown; identity=; parent=}
group_guids NoteProperty Object group_guids=System.Object
id NoteProperty long id=1826833066811084412
severity NoteProperty string severity=High
start_date NoteProperty datetime start_date=7/14/2020 8:48:56 AM
start_timestamp NoteProperty long start_timestamp=1594738136
timestamp NoteProperty long timestamp=1594738661
timestamp_nanoseconds NoteProperty long timestamp_nanoseconds=0

Next I setup a New-UDMontitor like this:

. ‘C:\Dev\Security\security-results.ps1’

New-UDPage -Name “Home” -Icon home -Content {

New-UdRow {

        New-UdColumn -Size 4 -Content {

            New-UdRow {

                New-UdColumn -Size 4 -Content {

                        New-UDMonitor -Title "Total Detections" -Type Line -DataPointHistory 20 -RefreshInterval 15 -ChartBackgroundColor '#5955FF90' -ChartBorderColor '#FF55FF90' @Colors -Endpoint {

                            ($monthlyResponse| Select-Object -ExpandProperty data).Count | Out-UDMonitorData

                        }

                      

                }

            }

        }

    }

}

When I run this variable manually here are my X and Y

PS C:\Users\adam> ($monthlyResponse| Select-Object -ExpandProperty data).Count | Out-UDMonitorData
{
“y”: 55,
“x”: “2020-07-14T15:46:08.799127Z”
}

On my Dashboard, i’m hoping to have the vertical column represent the number of malware detection’s, and the horizontal column show the month.

Thanks for reviewing this!

Hello @yoadam from the code you posted to me $monthlyResponse is $null as it is not set anywhere in the dashboard code you posted. You could look at running the script in cache, to access the variables inside the script if the imported script contains the monthlyResponse variable…I hope this helps :slight_smile:
I mean if your script is quick to run just put the whole script inside the endpoint scriptblock tags for the ud monitor…

Oh goodness. I’ve been staring at this and totally missed this. Thanks for point that out, i’ll also mess around with the cache, i’ve never used this before. Thank you!

No worries man glad I could shine some light on the situation…I posted a fully working dashboard here:- https://github.com/psDevUK/psUniversalDashboard that uses SQL queries in a CACHED method, as the SQL queries take a long time to run…had a few people say this helped them out, I did do it sometime ago, but hopefully can show you uses in a real-world dashboard.
If your new to universal dashboard, then def read https://docs.universaldashboard.io/endpoints/custom-variable-scopes to get an understanding…I also got some blogs here:- https://psdevuk.github.io/ud-flix but this onehttps://psdevuk.github.io/ud-flix/Content-vs-Endpoint/ might be a good read…peace

1 Like