ironmansoftware / powershell-universal-legacy

PowerShell Universal is the ultimate platform for building web-based IT tools.
https://www.powershelluniversal.com
GNU Affero General Public License v3.0
128 stars 14 forks source link

Docker /w Persistent Data Dashboard Charts not working. #93

Closed mkellerman closed 3 years ago

mkellerman commented 3 years ago

Description

Same setup as #92

But this time, create a dashboard, add the Charts component, and add New-UDMonitor:

-UDDashboard -Title "Hello, World!" -Content {
    New-UDTypography -Text "Hello, World!"

    New-UDMonitor -Type Line -Title "CPU" -RefreshInterval 1 -DataPointHistory 100 -Endpoint {
        Get-Random | Out-UDMonitorData
    }

}

Logs:

[01-27-21 09:39:42 PM] Waiting for dashboard information... 
[01-27-21 09:39:42 PM] Dashboard information received. Starting dashboard. 
[01-27-21 09:39:42 PM] Creating services. 
[01-27-21 09:39:42 PM] /home/Universal/UniversalDashboard/Frameworks/v3 
[01-27-21 09:39:42 PM] ./data/UniversalDashboard/Components/UniversalDashboard.Charts/1.3.2 
[01-27-21 09:39:42 PM] /home/Universal/Cmdlets/Universal.psd1 
[01-27-21 09:39:42 PM] /home/Universal/Microsoft.PowerShell.SecretManagement/0.2.1/Microsoft.PowerShell.SecretManagement.psd1 
[01-27-21 09:39:42 PM] /home/Universal/UniversalDashboard/Frameworks/v3/UniversalDashboard.psd1 
[01-27-21 09:39:42 PM] ./data/UniversalDashboard/Components/UniversalDashboard.Charts/1.3.2 
[01-27-21 09:39:44 PM] Loading module: /home/Universal/Microsoft.PowerShell.SecretManagement/0.2.1/Microsoft.PowerShell.SecretManagement.psd1 
[01-27-21 09:39:44 PM] Loading module: /home/Universal/Cmdlets/Universal.psd1 
[01-27-21 09:39:44 PM] Loading module: /home/Universal/UniversalDashboard/Frameworks/v3/UniversalDashboard.psd1 
...
[01-27-21 09:40:09 PM] An error occurred: The term 'New-UDMonitor' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Endpoint: c0e31199-85e7-4a83-8308-bb7f4b9afe9f
Session: f415bbbc-bb56-40fe-a50a-af69a2508f47
File: /data/Repository/sample.ps1
Endpoint Start Line: 1
Endpoint End Line: 8
Stack Trace: at <ScriptBlock>, <No file>: line 3

Version Information

Internal Issue

We'll fill this out when we create an internal issue in our repository.

adamdriscoll commented 3 years ago

New-UDMonitor does not exist in the UDv3 framework. You need to include the chart component and use New-UDChartJSMonitor: https://docs.ironmansoftware.com/dashboard/components/data-visualization/charts#monitors

mkellerman commented 3 years ago

I did try that too..

[01-28-21 09:30:38 PM] An error occurred: The term 'New-UDChartJSMonitor' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Endpoint: b917af6d-c406-4848-8833-aef54a44ccab
Session: 0ca9fd42-dd4a-4663-a84e-e01f46142b74
File: /data/Repository/SQL Monitor.ps1
Endpoint Start Line: 1
Endpoint End Line: 9
Stack Trace: at <ScriptBlock>, <No file>: line 2
mkellerman commented 3 years ago

I got it working by forcing the import of the module inside the endpoint:

New-UDDashboard -Title "Hello, World!" -Content {

    Import-Module ./data/UniversalDashboard/Components/UniversalDashboard.Charts/1.3.2/UniversalDashboard.Charts.psd1

    New-UDChartJSMonitor -LoadData {
        $cache:sqlcounters = Invoke-RestMethod http://localhost:5000/api/sqlcounters
        $cache:sqlcounters.PageLookupsPerSecond | Out-UDChartJSMonitorData
    } -Labels "PageLookupsPerSecond" -ChartBackgroundColor "#297741" -RefreshInterval 10

}

I think the issue is that it's pointing to './data/UniversalDashboard/Components/UniversalDashboard.Charts/1.3.2' but not the 'UniversalDashboard.Charts.psd1'