Web API Reference Guide > Available API Methods > Monitoring Rules Methods > The monitorSetRule Method

The monitorSetRule Method

Add/modify a monitor rule.

Version: 1.3

Required Permissions: Full

HTTP method: POST

Supported by Editions: Zend Server

Request Parameters:  

Parameter

 Type

Required

Description

rulesIds

Integer

Yes

The ruleId of the rule to be set. -1 for new rule

ruleProperties

Array

Yes

Associative array with the following mandatory rule properties: "rule_type_id", "rule_parent_id", "app_id", "name", "enabled" (1|0), "description", "url" and the following optional property: "creator" (0|1|2) - creator field with value “0” indicates that this is a Global rule, while value “1” indicates that this is a user defined rule and value“2” indicates that this rule originated from an application package. Default value is 1

ruleConditions

Array

No

Optional Array of conditions, each condition should have the following list of properties: "condition_id", "operation", "attribute", "operand" .

ruleTriggers

Array

Yes

List of triggers. Each trigger is an associative array, with the following properties: triggerProperties - Mandatory Array with the following properties: "severity" (integer), "trigger_id" triggerConditions - Optional Array of conditions, each condition should have the following list of properties: "condition_id", "operation", "attribute", "operand" triggerActions - Optional Array of actions, each action should have the following list of properties: "action_id", "action_type" (integer), "action_url", "tracing_duration" (integer)

acceptDuplicate

Boolean

No

When creating a new rule, determines behavior when rule duplication is detected. When TRUE, the duplicate call is accepted as valid and the existing rule is returned. When FALSE, the duplicate call is declined and returns an error. In both cases no changes are performed to the system. Default is FALSE.

Expected Response Code: 202 Accepted

Response Type: A list of the rule elements that were modified/added

Possible Action Specific Error Codes:

HTTP Code

Error Code

Description

500

internalServerError

The system could not retrieve the requested rules’ information, possibly due to database error

404

noSuchMonitorRule

The requested rule was not found

Example

Usage Example

Request (headers removed for the purpose of clarity)

POST /ZendServer/Api/monitorSetRule

Response (not all headers are shown)

HTTP/1.0 200 OK

<?xml version="1.0" encoding="UTF-8"?>

<zendServerAPIResponse xmlns="http://www.zend.com/server/api/1.3">

<requestData>

<apiKeyName><![CDATA[Admin]]></apiKeyName>

<method>monitorSetRule</method>

</requestData>

<responseData>

<rules>

<rule>

<id>1219644587</id>

<parentId></parentId>

<appId>1</appId>

<name>High Memory Usage (Absolute)</name>

<enabled>false</enabled>

<type>request-relative-large-mem-usage</type>

<order>1</order>

<url><![CDATA[...url...]]></url>

<creator>1</creator>

<description>Triggered … memory</description>

<conditions>

<condition>

<operation>string-in-list</operation>

<attribute>function-name</attribute>

<value>fopen|fclose</value>

</condition>

</conditions>

<triggers>

<trigger>

<severity>normal</severity>

<conditions>

<condition>

<operation>number-greater-than</operation>

<attribute>mem-usage</attribute>

<value>5120</value>

</condition>

</conditions>

<actions>

<action>

<type>send-mail</type>

<sendMailTo>![CDATA[Address]]</sendMailTo>

</action>

<action>

<type>tracing</type>

<mode>persist</mode>

</action>

</actions>

</trigger>

</triggers>

</rule>

</rules>

</responseData>

</zendServerAPIResponse>

 

Read Also

  Available API Methods    
  Monitoring Rules Methods