Under certain circumstances you may need get informed or to notify a party via email of an error in a log file. This article provides a step-by-step procedure on how to set up an email notification when a particular string is found in the output file of any application.
First, make sure that Monitoring Studio KM for PATROL is properly installed and running in your PATROL environment. Then, follow the instructions below:
This setup comprises three steps.
- Configuring the Monitoring Studio KM to perform File Monitoring and Analysis operation
- Configuring a String Search on the file
- Configuring an e-mail alert notification
File Monitoring and Analysis
- In the console, right click Monitoring Studio KM Commands New File Monitoring and Analysis
- Select the option LOG file and click Next.
- Specify the file name and the parameters to be monitored and click Next.
- Provide a name to identify the object.
- Select the thresholds you wish to set. It is advisable to use the default thresholds.
- Click Finish to complete the monitoring setup.
Performing String Search
The string search has to be performed on the identifier on which you have configured File monitoring and analysis.
- Right click the object KM Commands New String Search
- Provide the search criteria, that is the string to be matched and where to search. In this example, we chose to search for “ERROR” present “anywhere in the line”.
- Click Next.
- You can configure Monitoring Studio to automatically acknowledge alerts. The alerts can be acknowledged either by matching a string or by specifying a timeout. If you set an automatic acknowledgement, select the action to be performed when the specified condition is reached.
- Specify a display name and click Finish to create an object in the console to represent the String Search.
- Right click the newly added String Search Object KM Commands Set Alert Actions.
- Select a parameter from the list for which you need to send an alert and click Next. In this example “LastMatchingLines” is being selected.
- Select the Send an E-mail option to trigger an e-mail notification and click Next.
- Provide the e-mail addresses, SMTP server name, subject and body and click Next.
- If you wish to include the values of parameters retrieved by the Monitoring Studio KM, you can include macros in the body section.These macros are replaced by the stored values while sending the email. In this example, the body of the email contains all the lines which match the search criteria. For a list of available macros, click here.
- Click Finish to complete setup.
Note: This article is based on the “LastMatchingLines” parameter and will trigger an email alert when it finds the matching string in the file provided as input (file on which “File Monitoring and Analysis” and “String Search” has been implemented).
- Monitoring Studio: Monitoring Remote Log/Flat Files
- Log File Monitoring: Searching for a String and Triggering Alarm for each Occurrence
- Monitoring Studio: Counting the Number of Files in a Specific Directory
- Monitoring Studio: Increasing Maximum File Size Limit
- Using Macros to Customize PATROL Event Alert Actions