3.2 Managing Trace Templates using cURL

There are several cURL commands that you can use to manage trace templates. You must include the -u flag and provide your  username and password for the commands to be permitted.

Creating a Template

When you create a trace template, you must give the template a unique name, which consists of the folder in which you want to save the template and a template name, separated by a dot: <folder name>.<template name>. If you do not determine in which  folder you want to save a template, the Default folder is used.

You must also specify the following and save in JSON format:

  • Maximum number of hits per node (agent or route) - enter a value for "max_hits"
  • Automatic timeout of the trace in milliseconds - enter a value for "lifetime"
  • Workflow(s)
  • Route(s) and/or Agents(s)
  • Field(s)
  • Field description(s)

{ "name": "<template name>",
 "max_hits": <max number of hits>,
 "lifetime": <lifetime in ms>,
 "workflow": [{
  "name": { "expr" : "<name of workflow>" },
  "routes": [
      { "name" : { "expr": "<route name>" },
        "fields" : [
            { "name": { "expr" : "<field name>" }, "description": "<field description>" }
        ]
      }
  ]
 }]
}

If you want to use a regular expression in a trace template, you can indicate this by including "regex": "true" after the object for which you are using regular expression:

"<object>":{"expr": "<regular expression", "regex":"true"}

Adding a Trace to an Agent

You can also add a trace to the APL code of an Analysis agent so that you can trace which functions change a UDR. To make this addition, you must modify the APL code in the relevant Analysis agent and specify the details in the trace template.

Add the following to the APL code:

trace(<udr>, "<string>");

In addition to the specifications listed in the section Creating a Template, specify the following in the trace template:

"agents": [
      { "name": {"expr": "<agent name>"}, 
        "fields": [ 
            { "name": { "expr" : "<field name>" }, "description": " <field description>" } ] } ]

See the example shown below, A trace template.

Adding a Template

You then use the following cURL command to add the trace template that you have created, to your list of templates, providing the location of the trace template and the name of the JSON file:

curl --request POST -u <username:password> http://localhost:9000/conditionaltrace/template -d "$(</{template location}/<template name>.json)"

Example - A trace template

{ "name": "pulse",
 "max_hits": 10,
 "lifetime": 10000,
 "workflow": [{
  "name": { "expr" : "Default.pulse.workflow_1" },
  "routes": [
      { "name" : { "expr": "r_1" },
        "fields" : [
            { "name": { "expr" : "Sequence" }, "description": " Sequence number to match" }
        ]
      }
  ],
  "agents": [
      { "name": {"expr": "Analysis_1"}, 
        "fields": [ 
            { "name": { "expr" : "Sequence" }, "description": " Sequence number to match" } ] } ]
 }]
}

After you add a template, it is saved in the  folder that you determine in the template name, as described above. If you have not determined in which folder the template is to be saved, it is automatically added to the Default folder in the Desktop as a Conditional Trace Template configuration. For further information, see 3.1 Managing Trace Templates in Desktop.

Deleting a Template

If you require to delete a template, use the following cURL command, and specify the template name:

curl --request DELETE -u <username:password> http://localhost:9000/conditionaltrace/template/<template name>

Listing all Templates

To list all of the templates that have been created, use the following cURL command:

curl --request GET -u <username:password> http://localhost:9000/conditionaltrace/templates/