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.

Note: The endpoint for this case is set to the Web Socket URI path: /lab/notification/api. So the 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:

  1. Exact match of the parser’s endpoint attribute with the endpoint value in the message.
  2. Parser whose endpoint matches the start of the endpoint value in the message.

    For example, a parser with endpoint: /lab/notification/api will be used to parse messages containing endpoint= /lab/notification/api

  3. Parser whose endpoint is ANY.

    This is the last parser configuration used and if there is no ANY parser configuration set, the probe considers the message as unparsed.