Sidebar

How to return errors older than X hours or days or use a custom date range with errorManager.searchErrors()?

0 votes
400 views
asked Jun 9, 2016 by rich-c-2789 (16,240 points)
I need to get the errors that are more than 24 hours old.

1 Answer

0 votes

The searchText parameter uses the same searchText that is created from the "Search Messages" and "Distinct Errors" dialogs.

Valid format is:
[NodePath[!]=]Value[,error[!]=errorValue][,from=yyyyMMddHHmmssSSS][,to=yyyyMMddHHmmssSSS][,path=executionPath][,matchLevel=numeric value from 0 to 4,matchError=error text]
Commas are not allowed in values.  The matchLevel and matchError must be specified together.  matchError should be the last predicate if combined with other predicates. 

 

We can use these dialogs to start building the searchText with a date range.  This will be copied to our scheduled script where we will make the date range window adjust to the current date.

For example:

Creates the following searchText in the field below

error=disgracefulWebServiceFailure, from=20160608000000000, to=20160609000000000

With a bit of tweaking we can make this dynamic in our Scheduled Script:

//DateUtils will be used for date manipulation
var DateUtils = org.apache.commons.lang.time.DateUtils;
 
//Create the from date by subtracting 2 days from the current date
var fromDate = DateUtils.addDays(qie.deduceDate(qie.getSystemDate()), -2);
var fromDateText = "from=" + qie.formatDate('yyyyMMddHHmmssSSS', fromDate) + ", ";
 
//Create the to date by subtracting 1 day from the current date  
var toDate = DateUtils.addDays(qie.deduceDate(qie.getSystemDate()), -1);
var toDateText = "to=" + qie.formatDate('yyyyMMddHHmmssSSS', toDate) + ", ";
 
var searchText = fromDateText + toDateText + 'error=disgracefulWebServiceFailure';
var results = errorManager.searchErrors(searchText);
qie.debug('searchErrors returned ' + results.size() + ' messageQueueIds.');
qie.debug('The messageQueueIds returned: ' + results);
Additional

Also see these related questions:

How to automate resolving errors?

How to use errorManager.searchErrors() to return all errors?

How to use errorManager.searchErrors() to return errors that contain the given text?

How restrict the result returned by errorManager.searchErrors()?

Resources:

https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/DateUtils.html#addDays(java.util.Date, int)

 

 

answered Jun 9, 2016 by rich-c-2789 (16,240 points)
...