HTTP Custom Action

HTTP actions can be created or edited per enterprise. The user can templatize the action to pick values from a generated alert. The HTTP action can be configured with retries.

Example of an HTTP Custom Action:

{
    "name": "simpleAction",
    "type": "HTTP_ACTION",
    "url": "http://localhost:8080/device/${SERIALNUMBER}/job/1/execute",
    "headers": {
        "Content-Type": "application/json"
        "tenant": "${GROUPNAME}"
    },
    "method": "POST",
    "body": "{\"severity\":\"${SEVERITY}\"}",
    "certificateType": "JKS",
    "certificate": "<Base64 encoded jks certificate string>"
    "properties": {
        "retryPolicy": "FIXED",
        "initialPeriod": "5000",
        "maxPeriod": "300000",
        "maxAttempts": "3",
        "requestsPerSecond": "60"
    }
}
Table 1. Rule parameter descriptions
Field Descriptions
*id The unique ID of the action, which is used while accessing various rules APIs. This is also used while associating this custom action to a rule. Refer to customActions field in rule creation.

*Read-only parameter.

name Name of the action. Must be unique within the tenant. Can contain alphanumeric characters and underscore.
*type Type of action. Supported value: HTTP_ACTION

* Mandatory parameter.

*group The tenant for which the action is created. This is set according to the tenant of the user creating the action, or the impersonated tenant set with tenant header.

*Read-only parameter.

*url The URL of the HTTP endpoint which needs to be called for per record created by the rule.

* Mandatory parameter.

headers HTTP headers to be sent while making the HTTP call. Takes a map of key-value pairs.

Optional parameter.

*method The HTTP method to be used when making the HTTP call. Can be among GET, POST, PUT, PATCH, DELETE.

* Mandatory parameter.

body Must contain the request body to be sent during the HTTP call.

Optional parameter.

certificateType To be specified if HTTPS url is used. Currently supported: JKS (Default).

Optional parameter.

certificate To be specified if HTTPS url is used. If certificateType is JKS, this should be the base64 encoded JKS certificate. This string can be generated on Linux machines using the Base64 encoding command: base64 -w0 certificateFile.jks

Optional parameter.

properties Optional parameter. If this is not set, the values are initialized to its default.
  • retryPolicy: The retry policy to be used when the HTTP call fails for a record. Should be FIXED/EXPONENTIAL. Default is FIXED.
    • FIXED: The interval between retries is a fixed duration.
    • EXPONENTIAL: The interval between retries doubles up after every failure. For example, if the first retry was done after 1 second, the next retry will be done 2 seconds after that, and the next retry will be done 4 seconds afterward.
  • initialPeriod: The period between retries in milliseconds. Default is 5000ms. For FIXED retry policy, the intervals between retries are fixed to this value. For EXPONENTIAL retry policy, this will be the interval after the first failure, and will be doubled up subsequently.
  • maxPeriod: The maximum period in milliseconds for an EXPONENTIAL retry policy, to retry. After this period is reached, the retries are stopped. Default is 300000ms.
  • maxAttempts: The maximum attempts to be made to send the record. After this many attempts are made, the record is no longer retried. Default is 3.
  • requestsPerSecond: Parameter to be set for rate throttling. Specifies the maximum requests to be sent per second for this action. Records beyond this limit are sent later, so as to meet the rate limit. Default is 60 requests per second.

The following three fields in the action body can be customized to use the values from the record. For each record, the placeholders will be replaced with the value in that record, and the call will then be made.

  • url
  • headers
  • body

To refer to a variable, the following syntax has to be used:

${<variable name>}

These variables need to be referred to in all-caps. Along with this, all the keys from the details map can also be used as variables. match the case sensitivity according to the alias provided for these fields during rule creation in the select field.