...
See Guangrong's wikiĀ Installation of Holmes (for Testing Purpose)
Test Resource
Code Block |
---|
language | bash |
---|
title | alarm_on.json |
---|
collapse | true |
---|
|
{
"event": {
"commonEventHeader":{
"sourceId":"example-vserver-name-val-75044",
"startEpochMicrosec":1413378172000000,
"eventId":"ab305d54-85b4-a31b-7db2-fb6b9e546015",
"sequence":0,
"domain":"fault",
"lastEpochMicrosec":1413378172000000,
"eventName":"Fault_MultiCloud_VMFailure",
"sourceName":"example-vserver-name-val-75044",
"priority":"High",
"version":3.0,
"reportingEntityName":"Multi-Cloud"
},
"faultFields": {
"eventSeverity":"CRITICAL",
"alarmCondition":"Guest_Os_Failure",
"faultFieldsVersion":2.0,
"specificProblem":"Fault_MultiCloud_VMFailure",
"alarmInterfaceA":"aaaa",
"eventSourceType":"other",
"vfStatus":"Active"
}
}
} |
Code Block |
---|
language | bash |
---|
title | alarm_off.json |
---|
collapse | true |
---|
|
{
"event": {
"commonEventHeader":{
"sourceId":"example-vserver-name-val-75044",
"startEpochMicrosec":1413378172000000,
"eventId":"ab305d54-85b4-a31b-7db2-fb6b9e546015",
"sequence":0,
"domain":"fault",
"lastEpochMicrosec":1413378172000000,
"eventName":"Fault_MultiCloud_VMFailureCleared",
"sourceName":"example-vserver-name-val-75044",
"priority":"High",
"version":3.0,
"reportingEntityName":"Multi-Cloud"
},
"faultFields": {
"eventSeverity":"CRITICAL",
"alarmCondition":"Guest_Os_Failure",
"faultFieldsVersion":2.0,
"specificProblem":"Fault_MultiCloud_VMFailure",
"alarmInterfaceA":"aaaa",
"eventSourceType":"other",
"vfStatus":"Active"
}
}
} |
Code Block |
---|
language | bash |
---|
title | policy_onset_input.json |
---|
collapse | true |
---|
|
{
"closedLoopEventClient": null,
"policyVersion": null,
"policyName": null,
"policyScope": null,
"target_type": "VM",
"AAI": {
"vserver.prov-status": "example-prov-status-val-9845",
"vserver.resource-version": "1509546979412",
"vserver.is-closed-loop-disabled": "false",
"vserver.vserver-name2": "example-vserver-name2-val-55230",
"vserver.vserver-id": "example-vserver-id-val-64888",
"vserver.vserver-selflink": "example-vserver-selflink-val-91298",
"vserver.in-maint": "true",
"vserver.vserver-name": "example-vserver-name-val-75044",
"generic-vnf.vnf-id": "example-vnf-id-val-31366",
"generic-vnf.service-instance-id": ""
},
"closedLoopAlarmStart": 1413378172000000,
"closedLoopEventStatus": "ONSET",
"version": "1.0.2",
"closedLoopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",
"target": "vserver.vserver-name",
"closedLoopAlarmEnd": 0,
"requestID": "a0d549da-cd11-4425-af1f-fa40fdfc44ff",
"from": "DCAE"
} |
Code Block |
---|
language | bash |
---|
title | policy_abated_input.json |
---|
collapse | true |
---|
|
{
"closedLoopEventClient": null,
"policyVersion": null,
"policyName": null,
"policyScope": null,
"target_type": "VM",
"AAI": {
"vserver.vserver-name2": "example-vserver-name2-val-55230",
"vserver.vserver-id": "example-vserver-id-val-64888",
"vserver.vserver-selflink": "example-vserver-selflink-val-91298",
"vserver.vserver-name": "example-vserver-name-val-75044"
},
"closedLoopAlarmStart": 1413378172000000,
"closedLoopEventStatus": "ABATED",
"version": "1.0.2",
"closedLoopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",
"target": null,
"closedLoopAlarmEnd": 1413378172000000,
"requestID": "a0d549da-cd11-4425-af1f-fa40fdfc44ff",
"from": "DCAE"
} |
Code Block |
---|
language | bash |
---|
title | sampleves |
---|
collapse | true |
---|
|
{
"event":{
"commonEventHeader":{
"version": 3.0,
"eventName": "Slave MPU is offline",
"domain": "fault",
"eventId": "1501489595451",
"eventType": "applicationVnf",
"nfcNamingCode": "",
"nfNamingCode": "",
"sourceId": "example-vnf-id-val-31366",
"sourceName": "example-vnf-name-val-51172",
"reportingEntityId": "0000ZTHX1",
"reportingEntityName": "0000ZTHX1",
"priority": "High",
"startEpochMicrosec": 1501518702,
"lastEpochMicrosec": 1501518702,
"sequence": 960
},
"faultFields":{
"faultFieldsVersion": 2.0,
"eventSeverity": "CRITICAL",
"eventSourceType": "PgwFunction",
"eventCategory": "equipmentAlarm",
"alarmCondition": "The slave MPU board is offline or abnormal",
"specificProblem": "Slave MPU is offline",
"vfStatus": "Active",
"alarmInterfaceA": "VNF_194.15.13.138",
"alarmAdditionalInformation": [{
"name":"specificProblemID",
"value": "315"
}, {
"name":"objectUID",
"value":"0000ZTHX1PGWGJI6V1"
}, {
"name":"locationInfo",
"value":"MPU_22_20_0"
}, {
"name":"addInfo",
"value":"Aid:17;AlarmCode:110010;AlarmReasonCode:110010;Remark:\"DeployUnit=22,Node=21,SubNode=0\";"
}]
}
}
} |
Code Block |
---|
language | bash |
---|
title | abatedves |
---|
collapse | true |
---|
|
{
"event":{
"commonEventHeader":{
"version": 3.0,
"eventName": "Slave MPU is offlineCleared",
"domain": "fault",
"eventId": "1501489595451",
"eventType": "applicationVnf",
"nfcNamingCode": "",
"nfNamingCode": "",
"sourceId": "example-vnf-id-val-31366",
"sourceName": "example-vnf-name-val-51172",
"reportingEntityId": "0000ZTHX1",
"reportingEntityName": "0000ZTHX1",
"priority": "High",
"startEpochMicrosec": 1501518702,
"lastEpochMicrosec": 1501518702,
"sequence": 960
},
"faultFields":{
"faultFieldsVersion": 2.0,
"eventSeverity": "CRITICAL",
"eventSourceType": "PgwFunction",
"eventCategory": "equipmentAlarm",
"alarmCondition": "The slave MPU board is offline or abnormal",
"specificProblem": "The slave MPU board is offline or abnormal",
"vfStatus": "Active",
"alarmInterfaceA": "VNF_194.15.13.138",
"alarmAdditionalInformation": [{
"name":"specificProblemID",
"value": "315"
}, {
"name":"objectUID",
"value":"0000ZTHX1PGWGJI6V1"
}, {
"name":"locationInfo",
"value":"MPU_22_20_0"
}, {
"name":"addInfo",
"value":"Aid:17;AlarmCode:110010;AlarmReasonCode:110010;Remark:\"DeployUnit=22,Node=21,SubNode=0\";"
}]
}
}
} |
Code Block |
---|
language | bash |
---|
title | holmesrule |
---|
collapse | true |
---|
|
{
"ruleName": "VoLTE",
"loopControlName": "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 presented as readable format in the following. You need to convert it to valid json string when uploading to Holmes.
Code Block |
---|
title | Rule content field |
---|
linenumbers | true |
---|
collapse | true |
---|
|
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 |
---|
language | bash |
---|
title | Holmes 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 oldolder 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
Code Block |
---|
language | bash |
---|
title | Update Holmes Rules |
---|
|
curl -X GET http://10.0.14.1/api/holmes-rule-mgmt/v1/rule |python -m json.tool
curl -X DELETE http://10.0.14.1/api/holmes-rule-mgmt/v1/rule/rule_1508902811935
curl -X PUT -H 'Content-Type: application/json' -d @holmesrule http://10.0.14.1/api/holmes-rule-mgmt/v1/rule |