Friday 24 April 2009

Monitor / Audit your Data Warehouse load

One of the most important means of monitoring the run of your Data Warehouse load, is getting insight in the status of running jobs, the duration of the jobs (in history) and which jobs doesn't seem to end. An execution of a simple update script of an admin table before the start of a job and after the end of a job can result in a table like:





































































































































































































































































































































RunIDProcessActionObjectNewUpdatedDeletedLoad_startLoad_end
1EDW - HRMPublish HRM_cubeHRM_Montly.mdc4/15/09 8:09:38 AM4/15/09 8:10:02 AM
1EDW - HRMFTP HRM cubeHRM_Montly.mdc4/15/09 8:09:22 AM4/15/09 8:09:38 AM
1EDW - HRMCreate HRM cubeHRM_Montly.mdc4/15/09 8:09:21 AM4/15/09 8:09:22 AM
1EDW - HRMLoad new facts into aggregate table in Business ModelBSM.FCT_Hour_Monthly11408004/15/09 8:09:21 AM4/15/09 8:09:21 AM
1EDW - HRMDelete existing facts from aggregate table in Business ModelBSM.FCT_Hour_Monthly003444/15/09 8:09:03 AM4/15/09 8:09:21 AM
1EDW - HRMLoad Dimension Supplier into BSM (Refresh)BSM.DIM_Supplier3004/15/09 8:09:02 AM4/15/09 8:09:03 AM
1EDW - HRMLoad Dimension Organisational Unit into BSM (Refresh)BSM.DIM_OrganisationalUnit23004/15/09 8:09:00 AM4/15/09 8:09:02 AM
1EDW - HRMLoad Dimension Employee into BSM (Refresh)BSM.DIM_Employee45632004/15/09 7:59:20 AM4/15/09 8:09:00 AM
1EDW - HRMLoad Date Dimension into Business Model (Refresh)BSM.DIM_Date365004/15/09 7:59:18 AM4/15/09 7:59:20 AM
1EDW - HRMLoad new and changed hour facts into ODSODS.FCT_Hour45632004/15/09 7:59:16 AM4/15/09 7:59:18 AM
1EDW - HRMLoad new and changed targets into ODSODS.FCT_Target12004/15/09 7:59:15 AM4/15/09 7:59:16 AM
1EDW - HRMLoad new and changed suppliers into ODSODS.DIM_Supplier0004/15/09 7:59:08 AM4/15/09 7:59:15 AM
1EDW - HRMLoad new and changed organisational units into ODSODS.DIM_OrganisationalUnit0104/15/09 7:58:58 AM4/15/09 7:59:08 AM
1EDW - HRMLoad new and changed employees into ODSODS.DIM_Employee1204/15/09 7:58:55 AM4/15/09 7:58:58 AM
1EDW - HRMTransformation step: create hierarchy for organisational unitSTG.OrganisationalUnit02304/15/09 7:58:52 AM4/15/09 7:58:53 AM
1EDW - HRMTransformation step: calculate productivitySTG.Hour04563204/15/09 7:58:49 AM4/15/09 7:58:52 AM
1EDW - HRMLookup surrogate key supplierSTG.Supplier0304/15/09 7:58:23 AM4/15/09 7:58:49 AM
1EDW - HRMLookup surrogate key organisational unitSTG.OrganisationalUnit02304/15/09 7:51:56 AM4/15/09 7:58:04 AM
1EDW - HRMLookup surrogate key employeeSTG.employee0245604/15/09 7:51:28 AM4/15/09 7:51:56 AM
1EDW - HRMDetect corrected hoursSTG.Hour03504/15/09 7:51:24 AM4/15/09 7:51:28 AM
1EDW - HRMDetect changed supplier attributesSTG.Hour0004/15/09 7:51:22 AM4/15/09 7:51:24 AM
1EDW - HRMDetect changed organisational unit attributesSTG.OrganisationalUnit0104/15/09 7:51:18 AM4/15/09 7:51:22 AM
1EDW - HRMDetect changed employee attributesSTG.Employee2004/15/09 7:51:15 AM4/15/09 7:51:18 AM
1EDW - HRMExtract Monthly TargetsSTG.Target12004/15/09 7:50:54 AM4/15/09 7:51:15 AM
1EDW - HRMExtract Fact HoursSTG.Hour45632004/15/09 7:50:49 AM4/15/09 7:50:52 AM
1EDW - HRMExtract Dimension SupplierSTG.Supplier3004/15/09 7:50:17 AM4/15/09 7:50:49 AM
1EDW - HRMExtract Dimension Organisational UnitSTG.OrganisationalUnit23004/15/09 7:49:21 AM4/15/09 7:50:17 AM
1EDW - HRMExtract Dimension EmployeeSTG.Employee2456004/15/09 7:49:20 AM4/15/09 7:49:21 AM



Firstly, create an admin table:

-- Create MetaData layer

create schema mda

-- Create Admin table

CREATE TABLE [mda].[admin_run](
[Runid] [int] NULL,
[Process] [varchar](50) ,
[Action] [varchar](50) ,
[Object] [varchar](50) ,
[Inserted] [int] NULL,
[Updated] [int] NULL,
[Deleted] [int] NULL,
[LoadStart] [datetime] NULL,
[LoadEnd] [datetime] NULL
)
Secondly, create stored procedures to update the table:

CREATE PROCEDURE [mda].[PUpdate_Admin_Run_Start]

(
@Runid int
, @Process varchar(255)
, @Action varchar(255)
, @Object varchar(255)
)

AS

BEGIN

insert into mda.admin_run
(
RunID
, Process
, Action
, Object
, Inserted
, Updated
, Deleted
, LoadStart
)
values
(
@RunID
, @Process
, @Action
, @Object
, ''
, ''
, ''
, getdate()
)

END
CREATE PROCEDURE [mda].[PUpdate_Admin_Run_End]
( @RunId int
, @Action varchar(50)
, @Records_New int = 0
, @Records_Updated int = 0
, @Records_Deleted int = 0 )
AS
BEGIN
update mda.admin_run
set LoadEnd = getdate()
,Inserted = @Records_new
,Updated = @Records_updated
,Deleted = @Records_deleted
where RunId = @RunId
and LoadEnd is null
and Action = @Action
END
Below you find an example script which updates the admin table:
begin
declare @Records_inserted int
declare @Records_updated int
declare @Records_deleted int
declare @Runid int
declare @Process varchar(50)
declare @Action varchar(50)
declare @Object varchar(50)
declare @rows int

select @rows = count(*) from mda.admin_run
if @rows = 0 set @Runid = 1 else select @runid = max(runid) from mda.admi_run

set @Process = 'EDW - HRM'
set @Action = 'Extract Dimension Employee'
set @Object = 'STG.Employee'
exec mda.PUpdate_Admin_Run_Start @RunID,@Process,@Action,@Object
--load script
select getdate()

set @Records_Inserted = @@rowcount
exec mda.PUpdate_Admin_Run_End @RunID,@Action,@Records_Inserted, @Records_updated, @Records_deleted
end

No comments:

Post a Comment

Thanks for your comment.