Thursday, November 12, 2015

WLS: Configure Watch and Notification

Following post will help you to setup monitoring about the state of your system and send notification to selected recipients.

To set up your notification alerts you will need to cover these main steps:

1. Configure New Mail Session
2. Configure New Diagnostic Module
3. Configure New Collected Metrics
4. Configure New Notification
5. Configure New Watch rule

In the below example, we will set up alerts on the state of the Weblogic Managed Server to get an alert when a server is in the RUNNING state.

1. Configure Mail Session:
    Note: Mail sessions facilitate the process of using the JavaMail APIs, which provide applications and other J2EE modules with access to Internet Message Access Protocol (IMAP)- and Simple Mail Transfer Protocol (SMTP)-capable mail servers on your network or the Internet.

  • Go to Services -> Mail Sessions and click "New" to create a new Mail Session
  • Provide Name, JNDI Name and JavaMail Properties as follow:

Name – WLSMailAlert
JNDI Name – WLSMailAlert

JavaMail Properties:
mail.debug="true"
mail.transport.protocol=smtp
mail.smtp.user=admin
mail.smpt.password=password
mail.smtp.port=25
mail.smtp.from="admin@abc.com"
mail.smtp.host=smtp.abc.com
  • Click Next and Target the mail session to a server(s) and click finish. This is needed to expose the mail session on the servers JNDI tree.


2. Configure New Diagnostic Module
    Note: Most of the times Weblogic will have Diagnostic Module (Module-FMWDFW) configured and targeted to all servers. Below steps will help you if its not exists.
  • Go to Diagnostics -> Diagnostics Modules and click "New" to create a new diagnostics module.
  • Provide a Name and Description.

          Name – WLDMServerState
          Description – WLDF module to monitor server state

  • Select the newly created module and select "Targets" tab. Select required server(s) as Target and Save.



3. Configure New Collected Metrics
    Note: This metric is collected at a configurable interval, by default 300000ms i.e 300 sec(5 mins).  It means recipients will be notified for every 5 mins.
  • Select the newly created module "WLDMServerState" and select "Collected Metrics" tab. Click New.
  • Select "ServerRuntime" and click "Next"
  • Select "weblogic.management.runtime.ServerRuntimeMBean" from the drop down and click "Next"
  • From the list of collected attributes select "State" and shuffle it to the "Chosen" category. Click "Next"
  • From the instances list, select the required servers and shuffle to the "Chosen" category. Click "Finish"



4. Configure New Notification

  • Select the newly created module "WLDMServerState" and go to "Watches and Notifications" tab  --> "Notification" sub-tab
  • Click "New" to create a new Notification
  • Select "SMTP (E-Mail)"for Type and click "Next"
  • Provide a name – WLSServerStateAlert and Select "Enable Notification" check box. Click "Next"
  • Configure the following properties for the "SMTP Properties" page

           Mail Session Name – select "WLSMailAlert" (Created in step 1)
           E-Mail Recipients – admin@abc.com

  • Click "Finish"



5. Configure New Watch rule

  • Select the newly created module "WLDMServerState" and go to "Watches and Notifications" tab  --> "Watches" sub-tab
  • Click "New" to create a new Watch. Provide the name and select the type as "Collected Metrics". Also make sure the watch is enabled.

           Name – ServerStateWatch

  • Click "Next". Click "Add Expressions"
  • Select "ServerRuntime" and click “Next”
  • Select "weblogic.management.runtime.ServerRuntimeMBean" from the dropdown and click "Next"
  • Select the instance for the appropriate server from the list for "Instance" dropdown and click "Next"
  • Select "State" from "Message Attribute", Operator as "=", and Value as "RUNNING"
  • Click "Finish" to go back to "Create Watch" page
  • Rule value will be similar to (${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=adf_server1,Type=ServerRuntime//State} = 'RUNNING')
  • Click "Next" in "Create Watch" page. Select "Use an automatic reset alarm" and click "Next". (Set the "Automatic reset period" reduce mail alerts)
  • From the list of available notifications select "WLSMailAlert" and shuffle it to the "Chosen" category. Click "Finish"



Note: This Watch will be triggered every time the server state is RUNNING. And notification will be sent based on the Collected Metric’s sampling period i.e. 5 mins.

Note: Check Domain log file to find alerts related to configured watch.
Sample Domain Log:
####<Nov 11, 2015 11:03:16 PM CST> <Notice> <Diagnostics> <hostxxx.abc.com> <adf_server1> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <f50689c08d6d3474:5aefc86b:150f9d35d8e:-8000-0000000000000800> <1447304596087> <BEA-320068> <Watch 'ServerStateWatch' with severity 'Notice' on server 'adf_server1' has triggered at Nov 11, 2015 11:03:16 PM CST. Notification details:
WatchRuleType: Harvester
WatchRule: (${ServerRuntime//[weblogic.management.runtime.ServerRuntimeMBean]com.bea:Name=adf_server1,Type=ServerRuntime//State} = 'RUNNING')
WatchData: com.bea:Name=adf_server1,Type=ServerRuntime//State = RUNNING
WatchAlarmType: AutomaticReset
WatchAlarmResetPeriod: 60000

Sample Notification:



No comments:

Post a Comment

Provide your thoughts !