REST API Sequence Monitoring


Overview

Modern web applications are built with an complex mix of HTML and API calls ie. applications are highly dependent on REST API calls to retrieve the data or perform an actions. When an API call fails, it can affect complete workflow of the application. Therefore, it is important to monitor each API call. REST API Sequence monitor is meant to monitor the complete workflow of REST-based mobile and web applications.

Creating a new REST API Sequence monitor

To configure REST API monitor, follow the steps mentioned below:

  1. Click on Add New Monitor link under New Monitor. Select REST API Sequence.
  2. Enter Display Name of the monitor.
  3. Specify the polling interval for which the status of the monitor should be updated (in minutes).
  4. Provide the transaction steps that are to be monitored. Each step represents an API call in your application's workflow. Transaction steps can be added by choosing any one of the following options:
    1. Import Steps: This option allows you to add the transaction steps by importing the recorded API transactions from the HAR file generated by the web browser. Click here to learn about generating HAR file
    2. Add Step: This options lets you to add the transaction steps manually into the monitor. After selecting this option, enter the following details:
      • Specify the step name that is to be added.
      • Enter the Endpoint URL of the REST API to be monitored. The URL must be in HTTP/HTTPS.
      • Enable the Stop on error option to make the monitor down when the step fails and stop further execution of steps.
      • Specify the Timeout in seconds.
      • Select the Form Submission Method used to access the API request using any one of the following HTTP methods: GET, POST, PUT, or DELETE.
      • If you select POST or PUT method, you will be asked to choose the Request Body Type from the following options:
        • FORM: If you select this, enter the Request body in a line-by-line format
        • Text: If you select this, enter the Request body in text format
        • XML: If you select this, enter the Request body in XML format
        • JSON: If you select this, enter the Request body in JSON format
      • Configure the HTTP Request Headers required to establish a connection with the API server.
      • Enter the credential details for user authentication, if required. or select credentials from a Credential Manager list. Choose None if no authentication is required. You can choose any of the following options:
        • Basic authentication: Authenticates the REST API endpoint using basic credentials such as username and password.
        • Credential Manager: Authenticates the REST API endpoint by selecting credentials from Credential Manager.
        • OAuth Token: Authenticates the REST API endpoint using an OAuth token.
        • Web Token: Authenticates the REST API endpoint using a Web Token.
      • Specify the list of success status code(s) that indicate successful response, separated by commas. Example: 202,200

        You can also provide the status code range separated with a colon. Example: 200:250

      • Specify the Response Type to be expected. For XML and JSON response, user can define specific response values to monitor in the Response Details tab in the Monitor Details page.
      • Enable the Add content check for response checkbox if you wish to perform content check in the API response. Once enabled, perform the following steps:
        • Specify the contents that should contain and/or should not contain while performing the check in the API response.
        • Enable the Do case sensitive keyword search checkbox if you wish to perform a content check for case-sensitive character strings.
        • Enable the Regular Expression checkbox if you wish to perform a content check based on regular expressions. (Refer Regex Guide for more info)
        Note:
        • Make sure that the content you try to match is present in the API response.
        • The content search is case-sensitive. If you provide two or more words, the content match is performed for the words separately. Space character will be acting as the delimiter.
        • For example, if you specify the content as 'applications manager'", the match is found for 'applications' and 'manager' separately. If you need the content match to be performed for the complete text, specify the two words in quotes, like "applications manager".
      • Select Response Format based on which values are to be extracted for parameter forwarding. Individual values from responses can be extracted using regular expressions, JSONPath expressions or XPath expressions for parameter forwarding. (Text, XML, or JSON)
      • Provide additional parameters required to fetch the values from the API response, in the form of 'name-value' pair. The value should be provided based on the API response type. ie.
        • For TEXT, provide value as regular expression.
        • For JSON, provide value as JSONPath expression.
        • For XML provide value as XPath expression.
        Refer Parameter Forwarding to know more.
      • Provide response headers required to fetch the values from the API response, in the form of 'name-value' pair. The value should be provided as a regular expression.

      After entering all the above details, click Save.

  5. Choose the Monitor Group from the combo box with which you want to associate REST API Sequence monitor (optional). You can choose multiple groups to associate your monitor.
  6. Click Add Monitor(s). This discovers the REST API sequence from the network and starts monitoring.

Note: A maximum of 25 steps are only allowed to be added in a monitor.

Parameter Forwarding

Parameter forwarding can be used to pass data and test data validation between chained requests. Individual values from API response are extracted using XPath, JSONPath, or Regular expressions and can be saved as custom parameters. Also, values can be extracted from response headers using a regular expression. These parameters can then be used to build custom query strings or POST data for subsequent steps. Based on your selection of Text, XML or JSON-based response data format, you can build custom Regex-based expressions, XPath expressions, or JSONPath based expression assertions. Upon invoking ${Parameter} argument into the HTTP requests of your successive steps, the output value of the invoked expression assertion will be used in these steps for various step validation scenarios.

Parameter forwarding in REST API Sequence Monitor

Invoking Parameter in REST API Sequence Monitor

Monitored Parameters

Go to the Monitors Category View by clicking the Monitors tab. Click on REST API Sequence under the Web Server/Services section. Displayed is the REST API Sequence Monitor's bulk configuration view distributed into three tabs:

  • Availability tab gives the Availability history for the past 24 hours or 30 days.
  • Performance tab gives the Health Status and events for the past 24 hours or 30 days.
  • List view enables you to perform bulk admin configurations.

Following are the list of metrics shown in the REST API Sequence Monitor in their corresponding tabs:

Performance Overview

Parameter Description
Average Response Time Average time taken to obtain complete response of all the APIs in the sequence (in ms).
Transaction Time Total time taken to complete all the transactions in the sequence (in ms).
Step Response Time Total time taken to obtain response of the API in a recorded step (in ms).
Page Size Total response size of the API in a recorded step (in bytes).

Response Details

Parameter Description
REST API Sequence
Step Name Name of the recorded step.
Response Time Time taken to obtain response of the API in a recorded step (in ms).
DNS Time Amount of time spent for resolving domain name for the request (in ms).
Connection Time Amount of time spent for establishing TCP connection with server (in ms).
First Byte Time Amount of time taken from when the connection to the server established until the first response starts coming in for the API (in ms).
Download Time Amount of time taken for receiving last byte of the response for the API (in ms).
Page Size Total response size of the API in a recorded step (in bytes).
Response Displays the response of the API obtained in the recorded step. You can also monitor specific values by defining custom attributes in the API response. Learn more

Custom attributes in API response

Based on the response obtained, the user can define their own attributes for monitoring specific values in the API response.

  • If the response is of XML type: Using the XSLT transformation, the user can define specific values to be monitored. Ensure that the following criterias are met:
    • The output method should be of type 'text'.

      Syntax: <xsl:output method="text"/>

    • The final output should be of the format AttrName::AttrVal. Example: Days:<xsl:value-of select="days"/> would create an attribute 'Name' whose value will be the value of the <days> tag present in the API Response.
  • If the response is of JSON type: The JSON schema can be used to configure user-defined attributes. Ensure that the following criterias are met :
    • The attribute should be defined as AttrName::AttrValue. Example: Temperature::response.weather.temperature will create an attribute name 'Temperature' containing the value of the temperature variable returned.
    • Multiple JSON Schemas can be defined by using new line as the delimiter.
    • If the JSON key itself contains a dot (.), then replace it with '_sep_'. This should be done for all the individual keys which contain a dot(.) in it. In the above example, say the last key 'temperature' was defined as 'temperature.celsius'. Then the format should be Temperature::response.weather.temperature_sep_celsius.