You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

The JITL Check Log Job template can be used to check the log of an previously executed job in the workflow. 

  • Users would like to analyze log output of previously executed jobs.
  • Analysis includes to identify warnings and errors.
  • Analysis includes to identify output for decision-making about next steps in a workflow.

The job template makes use of the JS7 - REST Web Service API to run reports from the JOC Cockpit.

FEATURE AVAILABILITY STARTING FROM RELEASE 2.7.2

Usage

When defining the job either:

  • invoke the Wizard that is available from the Job Properties tab in the Configuration view and select the JITL CheckLogJob Template and relevant arguments

or

  • specify the JITL job class and com.sos.jitl.jobs.checklog.CheckLogJob Java class name.


Example:

Download (upload .json) The workflow configuration can be downloaded from here: js7_checklog.workflow.json 

This example workflow includes 3 jobs

  • job1: Just producing a log.
  • job2: Analysing the log
  • job_result: Showing the outcome of job_checklog



To create the job job_checklog you can use the job wizzard like this.



Explanation:

  • Add an empty job from the instruction panel.
  • Specify a name and a label for the job.
  • Select an Agent.

In a next step invoke the job wizard that you find in the upper right corner of the job property editor. The wizard brings up the following popup window:


Explanation:

  • From the list of available job templates select the CheckLogJob.

Then hit the Next button to make the job wizard display available arguments:


When hitting the Submit button the wizard adds the required arguments to the job which should look like this:

Documentation

The EncryptJob class accepts the following arguments:


NameDescriptionDefault

job
[required]    

The job in the current workflow whose log is to be analysed

When the job occurs more than one time in the workflow, the parameter "label" must be specified


label
[required if job occurs more than one time]    

The label of the job whose log is to be analysed

When the job occurs more than one time in the workflow, the parameter "label" must be specified to unique identify the job whose log is to be analysed.


pattern
[required]    

The regular expression to be used to examine the log

The regular expression is applied to the log.

Exampe 1: get lines with errors

pattern = ".*error.*"
log = "One line with error" + "\r\n" + "Line without the word" + "\r\n" + "And one line with error in the middle";
==> Result:

  • js7CheckLogMatches: One line with error|And one line with error in the middle
  • js7CheckLogMatchedGroups:
  • js7CheckLogMatchCount: 2
  • js7CheckLogGroupCount: 0
  • js7CheckLogGroupsMatchesCount: 0


Example 2: get event ids with event###
pattern = "event:\d{3}";
log = "The first line with event:1234" + "\r\n" + "Line without event" + "\r\n" + "And one line with event:456 and event:555 in the middle";
==> Result:

  • js7CheckLogMatches: event:123|event:456|event:555
  • js7CheckLogMatchedGroups:
  • js7CheckLogMatchCount: 3
  • js7CheckLogGroupCount: 0
  • js7CheckLogGroupsMatchesCount:0


Example 3: Get all dates
pattern = "\d{1,2}.\d{1,2}.\d{4}";
log = "1.2.2002: first line" + "\r\n" + "04.0.1888: second line" + "\r\n" + "22.11.2001: third line";
==> Result:

  • js7CheckLogMatchedGroups:
  • js7CheckLogMatches: 1.1.2021|22.05.1996|1.04.1888
  • js7CheckLogMatchedGroups:
  • js7CheckLogMatchCount: 3
  • js7CheckLogGroupCount: 0
  • js7CheckLogGroupsMatchesCount:0


Example 4:
pattern = "(\d{1,2}.\d{1,2}.\d{4}).(.*)$";
log = "1.2.2002: first line" + "\r\n" + "04.0.1888: second line" + "\r\n" + "22.11.2001: third line";
==> Result:

  • js7CheckLogMatches: 1.2.2002: first line|04.0.1888: second line|22.11.2001: third line
  • js7CheckLogMatchedGroups: 1.2.2002|04.0.1888|22.11.2001
  • js7CheckLogMatchCount: 3
  • js7CheckLogGroupCount: 0
  • js7CheckLogGroupsMatchesCount:6

|

separator

To separate the matched values

Executing the regular expression on the log can result in several matches. The matches are returned in the variable js7CheckLogMatches or js7CheckLogMatchedGroups and separated from each other with ‘separator’.


multiline

Handling the log as one or multiple lines

Enables multiline mode. In multiline mode the expressions ^ and $ matchjust after or just before, respectively, a line terminator or the end of the input sequence. By default these expressions only match at the beginning and the end of the entire input sequence. Multiline mode can also be enabled via the embedded flagexpression (?m).

case_insensitive

Handling of upper/lowercase

Enables case-insensitive matching. By default, case-insensitive matching assumes that only characters in the US-ASCII charset are being matched. Unicode-aware case-insensitive matching can be enabled by specifying the UNICODE_CASE flag in conjunction with this flag. Case-insensitive matching can also be enabled via the embedded flag expression (?i). Specifying this flag may impose a slight performance penalty.

false

unix_lines

Handling of line mode

This flag enables Unix lines mode. In the Unix lines mode, only '\n' is used as a line terminator and ‘\r’ is treated as a literal character.

false


Return Values


The returncode of the job is 0 when the pattern matches. Otherwise it is 1.


NameDescription
js7CheckLogMatchedGroups

Matching groups separated by the separator sign

A string value holding the matching groups of the task log. An empty value is returned if the pattern doesn't not match In case of a pattern specifying capturing groups, the matching characters are provided for each group. The return variable holds values per group separated by the character specified from the separator argument.

js7CheckLogMatches

Matches separated by the separator sign

A string value holding the matching characters of the task log. An empty value is returned if the pattern doesn't not match The return variable holds values per match separated by the character specified from the separator argument.

js7CheckLogMatchCount

Count of matches

The count of matches

js7CheckLogGroupsMatchesCount

Count of matches

The count of matched groups. Depends on value for the parameter "multiline". multiline=false -- matched groups when the log is regarded as one line. multiline=true -- Sum of matched groups for each line.

js7CheckLogGroupCount

Count of groups

The number of groups in the pattern.


Further Resources





















  • No labels