Time to upgrade! NAM is scheduled for end of support. It's time to move to Dynatrace our all-in-one software intelligence platform.

Universal decode script structure

Get to know the basic script structure and the required elements.

The Universal Decode script is created around two obligatory functions:

  • parse_request
  • parse_response

See the sampleScript.lua file for reference and examples on using the Lua functions against the HTTP traffic.

Script name

Start the script by declaring the script name. The script name value is available as a filtering dimension on the NAM Server, complimentary to the software service name and analogous to the analyzer name present for standard NAM analyzers. Use the following function:

 function script_name()
	return "My Universal Decode Script"


Universal Decode script must contain at least the two functions that are used to parse the request and response bodies:

  • parse_request(payload, stats)
  • parse_response(payload, stats)

The two functions reflect the response/request type of operation expected by Universal Decode.


  • payload
    Response or request content acting as an input parameter of a standard Lua string type.
  • stats
    A set of Universal Decode built-in methods serving as the interface to communicate with the RTM monitoring process to set the operation and hit attributes and metrics. It acts as the function output parameter. A separate stats object is created per hit; the same object is passed to both functions.

See the dummy example of the parse_request(payload, stats) function.

 function parse_request(payload, stats)
    return 0

It uses the setOperationName method to set the operation name to the fooName value extracted earlier from the payload using another accompanying function. The function must return a result code as in the example above. The following codes are available:

  • 0 - success
  • 1 - error, need more data
  • 2 - error
  • 3 - operation not supported

For example, you can end the condition with the 1 code if the analyzed payload contained no data.

Module information

You must place the Lua module information with the list of exported functions at the end of the script file.

local the_module = {}
the_module.parse_request = parse_request
the_module.parse_response = parse_response
return the_module

This standard syntax is obligatory to run the unit tests against parse_request and parse_response functions, and it does not need to be modified.