Specifying multiple parser configurations to parse different JSON structures
If the probe’s transport is configured to retrieve JSON alarms using resynchronization and notification, and has different alarm structures, you can configure the probe’s JSON parser with different settings to parse the JSON alarms and generate elements from them.
The following configuration file is provided with the probe as a template:
{
"eventSources" : [ {
"endpoint" : "/notification",
"name" : "NotificationAlarmParser",
"config" : {
"dataToRecord" : [ ],
"messagePayload" : "json",
"messageHeader" : "",
"jsonNestedPayload" : "",
"jsonNestedHeader" : "",
"messageDepth" : 3
}
}, {
"endpoint" : "/resync",
"name" : "ResyncAlarmParser",
"config" : {
"dataToRecord" : [ ],
"messagePayload" : "json",
"messageHeader" : "",
"jsonNestedPayload" : "",
"jsonNestedHeader" : "",
"messageDepth" : 3
}
}, {
"name" : "OtherAlarmParser",
"type" : "ANY",
"config" : {
"dataToRecord" : [ ],
"messagePayload" : "json",
"messageHeader" : "",
"jsonNestedPayload" : "",
"jsonNestedHeader" : "",
"messageDepth" : 5
}
}]
}Each alarm that the probe receives from the transport
contains an endpoint value to indicate the source
of the alarm. For example, for the Web Socket transport, the endpoint for
resynchronization alarms is resync and the endpoint for
notification is the Web Socket URI. To determine the endpoint value
to use in the configuration file, you should run the probe with debug
level logging and use the endpoint logged when an alarm is received.
When a probe receives an alarm from the source, the following messages are logged.
endpoint attribute should be set to /lab/notification/api.
2017-06-23T12:06:51: Debug: D-JPR-000-000: Received message from websocket.
2017-06-23T12:06:51: Debug: D-JPR-000-000: Received message with length of 824
from endpoint /lab/notification/api: <MESSAGE > …The probe parser uses the following criteria, in order, when performing the parser configuration lookup:
- Exact match of the parser’s
endpointattribute with theendpointvalue in the message. - Parser whose
endpointmatches the start of theendpointvalue in the message.For example, a parser with
endpoint: /lab/notification/api will be used to parse messages containingendpoint= /lab/notification/api - Parser whose
endpointisANY.This is the last parser configuration used and if there is no
ANYparser configuration set, the probe considers the message as unparsed.