-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdashboard.ps1
87 lines (73 loc) · 2.56 KB
/
dashboard.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Get-UDDashboard | Stop-UDDashboard
$EndpointListPage = New-UDPage -Name "Endpoints list" -Icon link -Content {
New-UDRow {
New-UDColumn -Size 6 {
New-UDGrid -Title "Endpoints list" -Headers @("Method","URL","Feature","Active") -Properties @("method","url","feature","active") -AutoRefresh -RefreshInterval 20 -Endpoint {
Import-Module PowerXaaS
Get-PXEndpoint | Out-UDGridData
}
}
}
}
$UsagePage = New-UDPage -Name "Usage and return codes" -Icon link -Content {
New-UDRow {
New-UDColumn -Size 6 {
New-UDGrid -Title "Usage stats" -Headers @("Method","URL","ReturnCode","Count") -Properties @("Method","Url","ReturnCode","Count") -AutoRefresh -RefreshInterval 20 -Endpoint {
Import-Module PowerXaaS
Get-PXUsageStats | Out-UDGridData
}
}
}
}
$RequestCountPage = New-UDPage -Name "Requests count" -Icon link -Content {
New-UDRow {
New-UDColumn -Size 6 {
New-UDChart -Title "Requests count (last 24 hours)" -Type Line -AutoRefresh -RefreshInterval 20 -Endpoint {
### Retrieve data
Import-Module PowerXaaS
$Data = Get-PXUsageStats -Raw | Select @{N="ByHour"; E={$_.timestamp.substring(0,11)}} | Group-Object -NoElement -Property ByHour
### Compute data
$Stats = @()
$h = [int]((get-date).AddHours(-24).tostring("HH"))
$d = [int]((get-date).AddHours(-24).tostring("yyyyMMdd"))
ForEach ($count in 1..24)
{
$hour = $h + $count
$day = $d
if ($hour -ge 24)
{
$hour = $hour - 24
$day = $d + 1
}
if (([string]$hour).length -eq 1)
{
$hour = "0$hour"
}
$r = $Data | where {$_.Name -eq "$day-$hour"}
if ($r)
{
$Stats += [PSCustomObject]@{
Count = $r.Count
Name = $r.Name
}
}
else
{
$Stats += [PSCustomObject]@{
Count = 0
Name = "$day-$hour"
}
}
}
$Stats = $Stats | sort Name
### Render data
$Stats | Out-UDChartData -DataProperty "Name" -LabelProperty "Name" -Dataset @(
New-UDChartDataset -DataProperty "Count" -Label "Requests" -BackgroundColor "#803AE8CE" -HoverBackgroundColor "#803AE8CE"
)
}
}
}
}
$Dashboard = New-UDDashboard -Title "IAS/SYS/WIN" -Page @($UsagePage, $RequestCountPage, $EndpointListPage)
Start-UDDashboard -Port 8086 -Dashboard ( $DashBoard )
Start-Process http://localhost:8086