Forum Discussion

Jeremy_Wanamake's avatar
8 years ago

Custom datasource collection interval and on-demand collection

We use JDBC to run queries against SQL Server and MySQL databases. Some of the queries we'd like to run are resource intensive and cannot be run during business hours. We'd like to be able to set a custom collection time for these datasources. On demand collection would be helpful as well.

  • Jeremy,

    One way to do this is to write a powershell script that checks the time now, and if its between 1 a.m. and 2 .a.m runs the query, if not does nothing but report the values returned from the last time it ran. 

    Incorporate this into a datasource and its only going to run the query at that time. You set the ds to run every hour, but it wont run the query until the right time.

    David

  • Thanks David. That's a good approach. I was using the a JDBC query directly within the datasource but it should be straightforward to move it into a PowerShell script. I will give that at try.

  • @Dave Lee Q, Do you have a sample script on how to return the last value? Is there some built-in api to get the prev value? should I store it in a file and just use that value?

  • @DanAvni, you could query the rest API for the last datapoint, however it's most effective just store the last values in a file on the collector and pick that up during the off hours.