Search code examples
sql-serverrefreshpower-bi-report-serversql-agent

Monitor Power BI Refreshes from SQL Query


We have numerous Power BI dashboards that have Scheduled Refreshes. These refreshes are SQL Agent jobs with names that are GUIDs. I'd like to be able to check on failed SQL Agent jobs and know what Power BI report/dashboard had it's refresh fail.

Is there a way to use T-SQL to resolve the name GUIDs to the Power BI report? Something like:

SELECT * 
FROM msdb.dbo.sysjobs J 
JOIN ReportServer.dbo.Catalog C 
  ON CAST(C.ItemID AS UNIQUEIDENTIFIER) = CAST(J.name AS UNIQUEIDENTIFIER) 

Solution

  • I thought I would share what I figured out, in case others need to query the same info:

    In the ReportServer database, the ExecutionLogStorage table had data I was looking for to tie the scheduled refreshes to the Catalog table. There is a field in there called Request Type. RequestType 2 is the Cache Refreshes.

    • 0 = Interactive,
    • 1 = Subscription,
    • 2 = Cache Refresh

    So, I used the following query to start reviewing the statuses of our Power BI Cache Refreshes:

    SELECT L.TimeStart, L.TimeEnd, C.Path, L.AdditionalInfo, L.Status, 
        ROW_NUMBER() OVER (PARTITION BY C.Path ORDER BY L.TimeEnd DESC) AS rn, L.ExecutionId 
    FROM ReportServer.dbo.ExecutionLogStorage L WITH(NOLOCK)
    LEFT OUTER JOIN ReportServer.dbo.Catalog C WITH(NOLOCK) ON (L.ReportID = C.ItemID)
    WHERE L.RequestType = 2 --cache refreshes
    AND L.TimeEnd >= DATEADD(DAY,-1,GETDATE())