Management Pack Health Model Exercise #10 - Creating a Delimited Text Log Alerting Rule
This document is part of the Operations Manager Management Pack Authoring Guide .
Overview
The following procedure shows how to create an alert rule using the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions.
Product Versions
This exercise applies to the following products:
- System Center Operations Manager 2007 R2
- System Center 2012 Operations Manager
- System Center 2012 Operations Manager SP1
Prerequisites
Before you perform this procedure, you must first complete the following prerequisite procedures:
- Creating a New Management Pack - Create the management pack.
- Creating a Class - Create the class that is the target for the rule.
Revisions
The Microsoft System Center team has validated this procedure as of the original revision. We will continue to review any changes and periodically provide validations on later revisions as they are made. Please feel free to make any corrections or additions to this procedure that you think would assist other users
Sample Code
A sample of the completed code for each exercise is available in the TechNet Gallery. There is a separate sample for each exercise that includes the management pack completed at the end of that exercise and each preceding exercise. This strategy allows you to work through each exercise in order and then compare your results. For VSAE, this also includes the Visual Studio solution.
Details
The monitor created in this procedure has the following characteristics:
- Runs on any computer that has an instance of MyComputerRole1.
- Watches a log file that has a naming pattern of MyApp*.log located in the c:\logs directory. The file is expected to be comma delimited.
- Creates an alert with a critical state when the string “error” is found in the second field.
- Includes the first, third, and fourth fields in the description of the alert.
- Suppresses alerts when the name of the logging computer and the value in the first field match.
Authoring Console Procedure
- In the Authoring Console, select Health Model, and then select Rules.
- Right-click in the Rules pane, select New, select Alerting, and then select Text Log (Delimited).
- On the General page, do the following:
- In the ElementID box, type MyMP.Rule.AlertOnDelimitedTextLog.
- In the Display Name box, type MyApplication Delimited Log Error.
- In the Target box, select MyMP.MyComputerRole1.
- In the Category box, select Alert. Click Next.
- On the Application Log Data Source page, do the following:
- In the Directory box, type c:\logs.
- In the Pattern box, type MyApp*.log.
- In the Separator box, type a COMMA.
- Click Next.
- On the Build Event Expression page, do the following:
- Click Insert.
- In the Parameter Name box type Params/Param[2].
- In the Operator box select Contains.
- In the Value box type error.
- Click Next.
- On the Configure Alerts page, do the following:
- In the Alert name box, type Error found in MyApplication delimited text log.
- Click the button to the right side of the Alert description box.
- Clear the text in the Value box.
- Select Data, then Params, then Param.
- Replace the text <<INT>> with 1.
- Move to the end of the line and press the ENTER key.
- Select Data, then Params, then Param.
- Replace the text <<INT>> with 3.
- Move to the end of the line and press the ENTER key.
- Select Data, then Params, then Param.
- Replace the text <<INT>> with 4.
- Move to the end of the line and press the ENTER key**.**
- Click OK.
- Click Finish.
- Right-click MyMP.Rule.AlertOnDelimitedTextLog and select Properties.
- On the Modules page, do the following:
- Click the Edit button next to the Action pane.
- Click the Configure button.
- Click the Alert Suppression button
- Select Logging Computer and Parameter 1.
- Click OK.
- Click OK.
- Click OK.
- Click OK.
Visual Studio Authoring Extensions Procedure
- Add a reference to the Application Log management pack:
- In Solution Explorer, right click References and then select Add Reference.
- Select the Browse tab.
- Navigate to C:\Program Files (x86)\System Center 2012 Visual Studio Authoring Extensions\References\OM2007R2\System.Performance.Library.mp. You may need to modify this path based on your installation location of VSAE.
- Select System.ApplicationLog.Library.mp and click OK.
- Click on System.ApplicationLog.Library in the Solution Explorer.
- In the Properties pane change the **Alias **to AppLog.
- Create the Rule:
- In Solution Explorer, right click Right click the name of the solution, select Add and then select New Item.
- Select Rule (Alert).
- Change the name of the template to Rules.mptg and click Add.
- Configure the Rule Properties:
- Right click the entry for NewAlertRule and select Properties Window.
- Change the ID to Rule.AlertOnDelimitedTextLog.
- Change the Display Name to MyApplication Delimited Log Error.
- Select the Rule Target:
- Select Target and click the ellipse (...) button on the right of the field.
- Select MyMP.MyComputerRole1 and click OK.
- Select the Rule modules:
Select Data Sources and click the ellipse (...) button on the right of the field.
Click Add.
Select Data Source Type ID and click the ellipse (...) button on the right of the field.
Select System.ApplicationLog.GenericCSVLog.FilteredEventProvider and click OK.
Select Data Source Configuration and click the ellipse (...) button on the right of the field.
Copy the following XML into the configuration window between the <Configuration> tags. Note that you can use Intellisense to manually type in each entry.
<LogFileDirectory>c:\logs</LogFileDirectory> <LogFilePattern>MyApp*.log</LogFilePattern> <LogIsUTF8>false</LogIsUTF8> <Separator>","</Separator> <Expression> <RegExExpression> <ValueExpression> <XPathQuery Type="String">Params/Param[2]</XPathQuery> </ValueExpression> <Operator>ContainsSubstring</Operator> <Pattern>error</Pattern> </RegExExpression> </Expression>
Click OK.
- Configure the Alert:
In the Alert Name field, type Error found in MyApplication delimited text log.
Select Alert Description and click the ellipse (...) button on the right of the field.
Type the following into the Specify alert description box and click OK.
$Data/Params/Param[1]$ $Data/Params/Param[3]$ $Data/Params/Param[4]$
- Save and Compile the Project:
- Select File, and then click Save Rules.mptg.
- Select Build and then Build Solution.
- Ensure that you don't receive any errors.