UDMONITOR Keep data

Hello,

I have created a dashbaord to monitor processor,memory,hard drive etc… But when i quit the page the log data is automatically deleted. When i return to the server page. The data collection begin from 0. I want to know if its possible to keep the data… for further analysis!

Thank you

Hey @itork,

UDMonitors currently do not store data: https://docs.universaldashboard.io/components/monitors they are designed to be transient by nature.

However, there are some options for working around this.

I am guessing you are doing something like this in your dashboard:

New-UdMonitor -Title "CPU (% processor time)" -Type Line -Endpoint {
     Get-Counter '\Processor(_Total)\% Processor Time' | Out-UDMonitorData
}

If you simply want to keep the data, you could add some lines to your endpoint to store the data locally.

New-UdMonitor -Title "CPU (% processor time)" -Type Line -Endpoint {
     $Counter =  Get-Counter '\Processor(_Total)\% Processor Time' 
     $Counter_JSON = $Process | ConvertTo-Json
     $Counter_JSON  | Out-File 'C:\Test\CounterData.json' -Append
     $Counter | Out-UDMonitorData
}

As you can see in my example we are still using the counter - so you will not see new data on refresh, BUT we are at least saving the data that could be easily loaded into another control.

I would suggest taking a look at the Scheduled Endpoints as well as this will help your detach your Data Collection / Data Storage from the UI: https://docs.universaldashboard.io/endpoints/scheduled-endpoints

Let me know if this helps or gives you any ideas, if not / if you are still curious I would be happy to put together a tutorial as I have been recently building some solutions for this problem.

3 Likes

Hello,

You got it. I test it and its work. I dont know the performance of a Json versus mysql. Problem solved.

thank you

Only reason I really gave JSON as an example as it is really easy to work with in PowerShell :slight_smile: Often when I am building out a proof of concept I start here since it is easy. If you wanted to make storing to flat file more reasonable you could roll the file by day as well.

Certainly if you want to store A LOT of data there are many better options such as mysql/postgres/etc. But it will be more complicated to get all your data logic function/modules in place but certainly a viable option! I should have some resources put together and posted for connecting to “common” databases in the next few weeks!