April 13, 2010

Qlikview Log Viewer

I have developed a simple Qlikview model that reads the log files for the Qlikview models in the same folder and shows a simple status dashboard showing the last reload date, success or failure of the reload, the number of reload errors if any and the relative time that the reload took. See image below:


To use, just copy the qvw file into the same folder and enable logging on the models that you wish to monitor, and set this model to reload periodically. If you have a series of models reloading overnight, just ensure that this model runs last.

Clicking on one of the model names displays the log data for the last reload of that model.

The load script is:

SET ThousandSep=' ';
SET DecimalSep='.';
SET MoneyThousandSep=' ';
SET MoneyDecimalSep='.';
SET MoneyFormat='R # ##0.00;R-# ##0.00';
SET TimeFormat='hh:mm:ss';
SET DateFormat='YYYY/MM/DD';
SET TimestampFormat='YYYY/MM/DD hh:mm:ss';
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

For each File in filelist ('*.log')

tmpLOG:
REPLACE LOAD
Date#(@1:9, 'MM/dd/yyyy') as Date,
Time#(@10:17, 'hh:mm:ss') as Time,
@20:24 as SourceLine,
RecNo() AS LogLine,
PurgeChar(Trim(@25:n), chr(9)) as Detail,
FileName() AS LogFile,
FileTime('$(File)') AS LogDate
FROM '$(File)'
(fix, codepage is 1252);

Let zStartts = TimeStamp#(Date(Peek('Date', 0), 'yyyy/MM/dd') & ' ' & Peek('Time', 0), TimestampFormat);
Let zEndts = TimeStamp#(Date(Peek('Date', -1), 'yyyy/MM/dd') & ' ' & Peek('Time', -1), TimestampFormat);
Let zInterval = Interval(zEndts - zStartts, 'hh:mm:ss');

Let zFileName = Peek('LogFile');

LOG:
LOAD *,
'$(zInterval)' AS ElapsedTime
RESIDENT tmpLOG
WHERE Len(Date) > 0 AND Len(Detail) > 0;


ERRORLOG:
LOAD
LogFile,
LogDate,
Count(*) AS ErrorCount
RESIDENT tmpLOG
WHERE Detail LIKE 'Error:*'
GROUP BY LogFile, LogDate;

DROP TABLE tmpLOG;

Next File

You may need to tweak the data formats to suit your system.

Load the model here. You will require a licensed version of Qlikview to open this model. If you are using the community download version of QV, you can roll your own by creating a new model, copying and pasting the script above, and importing this XML sheet layout.

The standard free software disclaimers apply.

No comments:

Post a Comment