How to get alert History using JON CLI script?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Operations Network (ON)
    • 3.1.x

Issue

  • Is there way to get alert History using JON CLI script?
  • How to use AlertManager to get the alert History in JON?

Resolution

  • First define the AlertCriteria to filter the alerts and then use AlertManagerRemote to get details on alert history. Below example shows to get number of alert for resourceType JBossAS7 Standalone Server. Refer java docs of AlertCriteria and AlertManagerRemote for API details. In below output value of extraInfo from conditionLogs provide the details on exception stack-trace of event log.
rhqadmin@127.0.0.1:7080$ login rhqadmin rhqadmin 127.0.0.1 7080
rhqadmin@127.0.0.1:7080$ var criteria = new AlertCriteria()
rhqadmin@127.0.0.1:7080$ criteria.addFilterResourceTypeName('JBossAS7 Standalone Server')
rhqadmin@127.0.0.1:7080$ var alerts = AlertManager.findAlertsByCriteria(criteria)
rhqadmin@127.0.0.1:7080$ alerts.getTotalSize()
2
rhqadmin@127.0.0.1:7080$ alerts.get(0)
Alert:
   acknowledgeTime: -1
   acknowledgingSubject: 
            alertDefinition: org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Alerts for Event logs, conditionExpression=ANY, priority=High, resourceId=10124 ]
      alertNotificationLogs: [AlertNotificationLog{id=10012, alert=org.rhq.core.domain.alert.Alert[id=10002, alertDefinition=org.rhq.core.domain.alert.AlertDefinition[ id=10041, name=Alerts for Event logs, conditionExpression=ANY, priority=High, resourceId=10124 ], ctime=1403605129585], sender='Direct Emails', resultState=SUCCESS, message='Target addresses were: [dmasirka@redhat.com]<br/>Successfully sent to: [dmasirka@redhat.com]'}]

conditionLogs: [org.rhq.core.domain.alert.AlertConditionLog[ id=10027, value=WARN, 
extraInfo=[[org.quartz.impl.jdbcjobstore.JobStoreCMT] (QuartzScheduler_RHQScheduler-jon-1.gsslab.pnq.redhat.com1403266191779_ClusterManager) This scheduler instance (jon-1.gsslab.pnq.redhat.com1403266191779) is still active but was recovered by, org.rhq.core.domain.alert.AlertCondition[ id=10061, category=Log Event, name=WARN, comparator='null', threshold=null, option=org.quartz.impl.jdbcjobstore.JobStoreCMT ] ]]
                      ctime: 1403605129585
                         id: 10002
    recoveryAlertDefinition: org.rhq.core.domain.alert.AlertDefinition[ id=0, name=null, conditionExpression=null, priority=null,  ]
                 recoveryId: 0
                willRecover: false

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments