dcsimg

How do I configure date macros in Webtrends?

Products

Webtrends Analytics 8.x
Webtrends Analytics 9.x

Cause

WebTrends has the ability to retrieve log files based on what are referred to as date macros. Date macros are expressions used to represent certain dates and/or date ranges, and these enable users to automate and streamline performance. Date macros are also used for the naming convention of regularly scheduled exports.

The following basic macros can be utilized for log file retrieval:

%dd% – Current day (two-digit)
%mm% – Current month (two-digit)
%yy% – Current year (two-digit)
%yyyy% – Current year (four-digit)
%Mon% – Current month (abbreviation)

Note: The abbreviation is case sensitive. %Mon% can return Jan, Feb, or Mar; %mon% returns jan, feb, or mar.

Date macros allow users to specify the computer’s current system date in a variety of ways. Date macros work similar to wildcards. It is necessary to specify what is common among the file names, then use the date macro to fill in the details. By default, the date macro uses the computer’s current system date.

There is a special sort of date macro used to adjust a certain number of days from the current system date. The format of this macro is as follows:

%dd-n%

Date Macro Example 1: Log file path to gather logs for the current day.

The log files are located in the C:\WINNT\system32\logfiles\w3svc1 directory and have the following names:

ex090811.log
ex090812.log
ex090813.log
ex090814.log
ex090815.log

By default the structure is two-digit year (yy); two-digit month (mm), and two-digit day (dd).

1) The prefix and extension are common to all logs in this directory: ex______.log

2) The date is fully numeric with a two-digit year. Insert the format specifier macros between the prefix and extension.

ex%yy%%mm%%dd%.log

3) The complete path to use would be as follows:

C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd%.log


Date Macro Example 2: Report for previous day.

The log files are located in the C:\WINNT\system32\logfiles\w3svc1 directory and are named as follows:

ex090811.log
ex090812.log
ex090813.log
ex090814.log
ex090815.log

The %dd-n% variable must be used to adjust from the current system date, then specify the format correctly using the date macro format specifiers.

1) The prefix and extension are common to all logs in this directory: ex______.log

2) The date is fully numeric with a two-digit year. Insert the specifier macros between the prefix and extension.

ex%yy%%mm%%dd%.log

3) Specify the previous day’s date rather than the current system date it will be read as follows:

%dd-1%.

The complete path to use would be as follows:

C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-1%.log

Note:
To specify a sequence of a time period, e.g., days, it requires a line for each day. The example below shows the lines required for the past five days of log files:


C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-5%.log
C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-4%.log
C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-3%.log
C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-2%.log
C:\WINNT\system32\logfiles\w3svc1\ex%yy%%mm%%dd-1%.log

Using only the first line above would tell Webtrends to analyze the log files from five days ago, rather than log files for the past five days. The date macros above will analyze, sequentially, the log files from five days ago, then four days ago, three days ago, two days ago, and yesterday. Macros such as these commonly range from five days to two weeks. It is recommended not to use three days or fewer due to the possibility that some issue may occur over a holiday weekend which prevents analysis from taking place, after which the issue is corrected and analysis continues but a gap may appear in report data if not addressed immediately.

Advanced Macros:

Enhanced Date Macro Support for Log File Specification:
%dd+n%, %dd-n% (The current day plus or minus n days)
%mm+n%, %mm-n% (The current month, plus or minus n months)
%yy+n%, %yy-n% (The current year plus or minus n years)
%yyyy+n% (The current four-digit year plus n years)
%yyyy-n% (The current four-digit year minus n years)
%dy% (The current day of year (001-366))
%wy% (The current week of year (00-53))
%dw% (The current day of week (0-6))
%wm% (The current week of month (0-5))

Date Macro Support for Specifying Report Ranges:

%dd% (The current day of the month (01-31))
%mm% (The current month of the year (01-12))
%mon% (The current month by name (abbreviated) (jan-dec))
%yy%, %yyyy% y(The current year (2- or 4- digits))

Examples:

Today’s date is 05/26/2009 and today’s log file is ex20090526.log.

ex%yyyy%%mm%%dd%.log
Pulls today’s log file – ex20090526.log

ex%yyyy%%mm-1%%dd%.log
Pulls last month’s log file – ex20090426.log

ex%yyyy%%mm%%dd-5%.log
Pulls the log file from five days ago – ex20090521.log

ex%yyyy-1%%mm%%dd%.log
Pulls last year’s log file – ex20090526.log

Today’s date is 02/22/2009 and today’s log file is log200953.txt
(where 53 is the day of the year)

log%yyyy%%dy%.txt
Pulls today’s log file – log200953.txt

Today’s date is 03/20/2009

log%yyyy%%dy%.txt
Pulls today’s log file where log file name is log200979.txt
(79 is the day of the year)

log%yyyy%%wy%.txt
Pulls this week’s log file where log file name is log200912.txt
(12 is the week of the year)

log%yyyy%%Mon%%wm%.txt
Pulls this week’s log file where log file name is log2009Mar3.txt
(3 is the week of the month)

log%yyyy%%wy%%dw%.txt
Pulls todays log file where the log file name is log2004122.txt
(12 is the week of the year and 2 is the day of the week)