Reporting Services本地使用情况跟踪

时间:2018-09-07 15:57:35

标签: sql sql-server reporting-services powerbi

我想跟踪本地服务器上存在的SSRS和Power BI报告的使用情况。应用程序服务提供了这些指标,但本地版本位于SQL Server上,因此您必须使用ExecutionLog3表。

该表更难查询PBIX报告,因为它并不直接说明什么是真正的“用法”

1 个答案:

答案 0 :(得分:0)

也许有更好的方法来编写此代码,但它使您几乎可以跟踪所有报告的内部使用情况-SSRS和Power BI

declare @results TABLE
(
    Report  NVARCHAR(50),
    ExecutionTime DATETIME,
    UserName NVARCHAR(25),
    ExecutionId NVARCHAR(50)
)


INSERT INTO @results 
SELECT
       Name,
       TimeStart,
       UserName,
       ExecutionId
  FROM (SELECT TimeStart,
               Catalog.Name,
               UserName,
               ExecutionId
          FROM Catalog
               INNER JOIN 
               ExecutionLog3
                 ON Catalog.Path = ExecutionLog3.ItemPath
         WHERE Type IN (2) --ssrs
       ) AS RE
UNION ALL
    SELECT 
       Name,
       TimeStart,
        UserName,
        ExecutionId
  FROM (SELECT  TimeStart,
               Catalog.Type,
               Catalog.Name,
                UserName,
                ExecutionId
          FROM Catalog
               INNER JOIN 
               ExecutionLog3
                 ON Catalog.Path = ExecutionLog3.ItemPath
         WHERE Type IN (13) --power BI
         AND ItemAction = 'ConceptualSchema'
         AND Format = 'PBIX'
       ) AS RE
       Order By TimeStart DESC

;WITH cte AS
(
   SELECT *,
         ROW_NUMBER() OVER (PARTITION BY ExecutionId ORDER BY ExecutionTime DESC) AS rn
   FROM @results
)
SELECT
Report,
ExecutionTime,
UserName
FROM cte
WHERE rn = 1
ORDER BY ExecutionTime DESC