Adding a Message to the Heartbeat Status Output

Adding a Message to the Heartbeat Status Output

A quick walk through a basic rule that adds a text message to the heartbeat status. This method can provide greater clarity of status events at trace level 0. The method can be used to enhance other status messages as desired.

The normal output from the Heartbeat Status provides the basic information of Driver name, Channel and Status, and looks like:

DirXML Log Event -------------------
Driver: \MyTree\services\DriverSet\TestDriver
Channel: Publisher
Status: Success

With this limited information, it is not always clear this is a heartbeat status result as it may look just like other status messages that have similarly limited information. By adding a short text message to the document, the status output can enhanced to include a Message that indicates this is a heartbeat status result.

The default heartbeat status document (at trace level 3) looks something like:

<nds dtdversion="2.0">
  <source>
    <product instance="TestDriver" version="4.0">Test Driver</product>
  </source>
  <input>
    <status level="success" type="heartbeat"/>
  </input>
</nds>

Adding text to the status, "<status ...>Some Text</status>", will generate a "Message:" component for the status output. This can be implemented quickly using the "append XML text" action (the "<do-append-xml-text>" token) to add message text to the status document.

In this example the "type" value, from the event document, is copied to the text value along with some additional text and formatting. This provides a clean message in the output of "Status Type = heartbeat". The modified status document now looks like:

<nds dtdversion="2.0">
  <source>
    <product instance="TestDriver" version="4.0">Test Driver</product>
  </source>
  <input>
    <status level="success" type="heartbeat">Status Type = heartbeat</status>
  </input>
</nds>

The Heartbeat Status output now looks like:

DirXML Log Event -------------------
Driver: \MyTree\services\DriverSet\TestDriver
Channel: Publisher
Status: Success
Message: Status Type = heartbeat

The Rule:

	<rule>
		<description>Add Message to Heartbeat Status</description>
		<comment xml:space="preserve">Add a Message component to the normal Heartbeat Status Output</comment>
		<conditions>
			<and>
				<if-operation mode="nocase" op="equal">status</if-operation>
				<if-xpath op="true">@level="success"</if-xpath>
				<if-xpath op="true">@type="heartbeat"</if-xpath>
			</and>
		</conditions>
		<actions>
			<do-append-xml-text expression=".">
				<arg-string>
					<token-text xml:space="preserve">Status Type = </token-text>
					<token-xpath expression="./@type"/>
				</arg-string>
			</do-append-xml-text>
		</actions>
	</rule>

The rule's conditions ensure the actions only apply to Heartbeat Status events with a level of Success. (It is good practice to scope exactly what should be processed in your rule. As I am not aware of any other levels for heartbeat events, these conditions could have been simplified to checking for only "status" operations of type "heartbeat".)

The rule action appends the text of "Status Type = " and the value of the "type" tag, to the current node (which is the status operation) using the "append XML text" action (do-append-xml-text token).

As this example is modifying a heartbeat status, the rule should be placed at, or near, the end of the Command Transform Policy Set (CTP) in the Publisher channel. It could be included anywhere in the Publisher channel, though it does add additional text to higher level traces, so could be seen as adding more noise at higher trace levels if placed earlier.

This method can be expanded to add more details to any status document. Where status documents already include message content, additional formatting and carriage returns may be needed.

Cheers,

D

Labels (2)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
2 of 2
Last update:
‎2021-01-12 19:18
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.