简体   繁体   中英

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) 

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()) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM