Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleholmesrule
collapsetrue
{

"rulenameruleName": "VoLTE",

"loopcontrolnameloopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",

"description": "This rule is designed for the correlation analysis for the VoLTE use case.",

"content": "package org.onap.holmes.droolsRule;\n\nimport org.onap.holmes.common.dmaap.DmaapService;\nimport org.onap.holmes.common.api.stat.VesAlarm;\nimport org.onap.holmes.common.aai.CorrelationUtil;\nimport org.onap.holmes.common.dmaap.entity.PolicyMsg;\nimport org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;\nimport org.onap.holmes.common.utils.DroolsLog;\n \n\nrule \"Relation_analysis_Rule\"\nsalience 200\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0,\n            $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\n\t\t\t$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),\n\t\t\t$startEpochMicrosec: startEpochMicrosec,\n            specificProblem in (\"Fault_MultiCloud_VMFailure\"),\n            $eventId: eventId)\n        $child : VesAlarm( eventId != $eventId, parentId == null,\n            CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),\n            specificProblem in (\"Slave MPU is offline\"),\n            startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )\n    then\n\t\t$child.setParentId($root.getEventId());\n\t\tupdate($child);\n\t\t\nend\n\nrule \"root_has_child_handle_Rule\"\nsalience 150\nno-loop true\n\twhen\n\t\t$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)\n\t\t$child : VesAlarm(eventId != $eventId, parentId == $eventId)\n\tthen\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_no_child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,\n            sourceId != null && !sourceId.equals(\"\"),\n\t\t\tsourceName != null && !sourceName.equals(\"\"),\n            specificProblem in (\"Fault_MultiCloud_VMFailure\"))\n    then\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_cleared_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)\n    then\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\tretract($root);\nend\n\nrule \"child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)\n    then\n\t\tretract($child);\nend",

"enabled": 1

}


To illustrate, the content field in the above rule is like this in clean format:presented as readable format in the following. You need to convert it to valid json string when uploading to Holmes.

Code Block
titleRule content field
linenumberstrue
collapsetrue
package org.onap.holmes.droolsRule;


import org.onap.holmes.common.dmaap.DmaapService;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.common.aai.CorrelationUtil;
import org.onap.holmes.common.dmaap.entity.PolicyMsg;
import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.utils.DroolsLog;


rule "Relation_analysis_Rule"
salience 200
no-loop true
    when
        $root : VesAlarm(alarmIsCleared == 0,
            $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),
			$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),
			$startEpochMicrosec: startEpochMicrosec,
            specificProblem in (\"Fault_MultiCloud_VMFailure\"),
            $eventId: eventId)
        $child : VesAlarm( eventId != $eventId, parentId == null,
            CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),
            specificProblem in (\"Slave MPU is offline\"),
            startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )
    then
		$child.setParentId($root.getEventId());
		update($child);
end


rule "root_has_child_handle_Rule"
salience 150
no-loop true
	when
		$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)
		$child : VesAlarm(eventId != $eventId, parentId == $eventId)
	then
		DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
		PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");
        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");
		$root.setRootFlag(1);
		update($root);
end


rule "root_no_child_handle_Rule\"
salience 100
no-loop true
    when
        $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,
            sourceId != null && !sourceId.equals(\"\"),
    		sourceName != null && !sourceName.equals(\"\"),
            specificProblem in (\"Fault_MultiCloud_VMFailure\"))
    then
		DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
		PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");
        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");
		$root.setRootFlag(1);
		update($root);
nend


rule "root_cleared_handle_Rule"
salience 100
no-loop true
    when
        $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)
    then
		DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
		PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");
        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");
		retract($root);
end


rule "child_handle_Rule"
salience 100
no-loop true
    when
        $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)
    then
		retract($child);
end"



Before install Holmes dockers, you need to install postgres

...

Code Block
languagebash
titleHolmes Manual Setup Steps
# Remove the current running instances
docker rm -f holmes-rule-management 
docker rm -f holmes-engine-management 

# Download latest images
docker login -u docker -p docker nexus3.onap.org:10001
docker pull nexus3.onap.org:10001/onap/holmes/rule-management
docker pull nexus3.onap.org:10001/onap/holmes/engine-management

# Start two Holmes docker containers
sudo docker run --name holmes-rule-management -p 9101:9101 -d -e URL_JDBC=10.0.4.1 -e MSB_ADDR=10.0.14.1 -e TESTING=1 -e HOST_IP=10.0.4.1 nexus3.onap.org:10001/onap/holmes/rule-management
sudo docker run --name holmes-engine-management -p 9102:9102 -d -e URL_JDBC=10.0.4.1 -e MSB_ADDR=10.0.14.1 -e TESTING=1 -e HOST_IP=10.0.4.1 nexus3.onap.org:10001/onap/holmes/engine-management

# Check health
curl http://10.0.14.1/api/holmes-rule-mgmt/v1/healthcheck
curl http://10.0.14.1/api/holmes-engine-mgmt/v1/healthcheck

# Start with an old image
#sudo docker run --name Start with an older image
#sudo docker run --name holmes-engine-management -p 9102:9102 -d -e URL_JDBC=10.0.4.1 -e MSB_ADDR=10.0.14.1 -e TESTING=1 -e HOST_IP=10.0.4.1 e7d17bb9a869

# Check health
curl http://10.0.14.1/api/holmes-rule-mgmt/v1/healthcheck
curl http://10.0.14.1/api/holmes-engine-mgmt/v1/healthcheck

# Configure sub and pub topics for Holmes by using registered msb url
curl -X PUT -H 'Content-Type: application/json' -d '{"name":"unauthenticated.SEC_FAULT_OUTPUT", "url":"http://10.0.11.1:3904/events/unauthenticated.SEC_FAULT_OUTPUT"}' http://10.0.14.1/api/holmes-engine-mgmt/v1/dmaap/sub 
curl -X PUT -H 'Content-Type: application/json' -d '{"name":"unauthenticated.DCAE_CL_OUTPUT", "url":"http://10.0.11.1:3904/events/unauthenticated.DCAE_CL_OUTPUT"}'  http://10.0.14.1/api/holmes-engine-mgmt/v1/dmaap/pub

# Upload Holmes rules defined in file holmesrule
curl -X PUT -H 'Content-Type: application/json' -d @holmesrule http://10.0.14.1/api/holmes-rule-mgmt/v1/rule

# Simulate alarm_on event from MultiVIM to VES
curl -i -X POST -d @alarm_on.json --header "Content-Type: application/json" http://localhost:80808081/eventListener/v5 -k


Update Holmes rules by deleting the existing rule with rule_id and upload the new rule

...