integer/array discoveryrule.get(object parameters)
The method allows to retrieve LLD rules according to the given parameters.
This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.
(object) Parameters defining the desired output.
The method supports the following parameters.
| Parameter | Type | Description | 
|---|---|---|
| itemids | ID/array | Return only LLD rules with the given IDs. | 
| groupids | ID/array | Return only LLD rules that belong to the hosts from the given groups. | 
| hostids | ID/array | Return only LLD rules that belong to the given hosts. | 
| inherited | boolean | If set to truereturn only LLD rules inherited from a template. | 
| interfaceids | ID/array | Return only LLD rules use the given host interfaces. | 
| monitored | boolean | If set to truereturn only enabled LLD rules that belong to monitored hosts. | 
| templated | boolean | If set to truereturn only LLD rules that belong to templates. | 
| templateids | ID/array | Return only LLD rules that belong to the given templates. | 
| selectDiscoveryData | query | Return a discoveryDataproperty with the LLD rule discovery object data. The LLD rule discovery object links a discovered LLD rule to an LLD rule prototype from which it was discovered. | 
| selectDiscoveryRulePrototypes | query | Return a discoveryRulePrototypesproperty with LLD rule prototypes that belong to the LLD rule.Supports count. | 
| selectFilter | query | Return a filterproperty with data of the filter used by the LLD rule. | 
| selectGraphs | query | Returns a graphsproperty with graph prototypes that belong to the LLD rule.Supports count. | 
| selectHostPrototypes | query | Return a hostPrototypesproperty with host prototypes that belong to the LLD rule.Supports count. | 
| selectHosts | query | Return a hostsproperty with an array of hosts that the LLD rule belongs to. | 
| selectItems | query | Return an itemsproperty with item prototypes that belong to the LLD rule.Supports count. | 
| selectTriggers | query | Return a triggersproperty with trigger prototypes that belong to the LLD rule.Supports count. | 
| selectLLDMacroPaths | query | Return an lld_macro_pathsproperty with a list of LLD macros and paths to values assigned to each corresponding macro. | 
| selectPreprocessing | query | Return a preprocessingproperty with LLD rule preprocessing options. | 
| selectOverrides | query | Return an lld_rule_overridesproperty with a list of override filters, conditions and operations that are performed on prototype objects. | 
| filter | object | Return only those results that exactly match the given filter. Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against. Does not support properties of textdata type.Supports additional properties: host- technical name of the host that the LLD rule belongs to. | 
| limitSelects | integer | Limits the number of records returned by subselects. Applies to the following subselects: selectItems,selectGraphs,selectTriggers. | 
| sortfield | string/array | Sort the result by the given properties. Possible values: itemid,name,key_,delay,type,status. | 
| countOutput | boolean | These parameters are described in the reference commentary. | 
| editable | boolean | |
| excludeSearch | boolean | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean | 
(integer/array) Returns either:
countOutput parameter has been used.Retrieve all discovery rules for specific host ID.
{
           "jsonrpc": "2.0",
           "method": "discoveryrule.get",
           "params": {
               "output": "extend",
               "hostids": "10202"
           },
           "id": 1
       }Response:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "itemid": "27425",
                   "type": "0",
                   "snmp_oid": "",
                   "hostid": "10202",
                   "name": "Network interface discovery",
                   "key_": "net.if.discovery",
                   "delay": "1h",
                   "status": "0",
                   "trapper_hosts": "",
                   "templateid": "22444",
                   "valuemapid": "0",
                   "params": "",
                   "ipmi_sensor": "",
                   "authtype": "0",
                   "username": "",
                   "password": "",
                   "publickey": "",
                   "privatekey": "",
                   "flags": "1",
                   "interfaceid": "119",
                   "description": "Discovery of network interfaces as defined in global regular expression \"Network interfaces for discovery\".",
                   "lifetime": "30d",
                   "jmx_endpoint": "",
                   "master_itemid": "0",
                   "timeout": "",
                   "url": "",
                   "query_fields": [],
                   "posts": "",
                   "status_codes": "200",
                   "follow_redirects": "1",
                   "post_type": "0",
                   "http_proxy": "",
                   "headers": [],
                   "retrieve_mode": "0",
                   "request_method": "0",
                   "output_format": "0",
                   "ssl_cert_file": "",
                   "ssl_key_file": "",
                   "ssl_key_password": "",
                   "verify_peer": "0",
                   "verify_host": "0",
                   "allow_traps": "0",
                   "uuid": "",
                   "lifetime_type": "0",
                   "enabled_lifetime_type": "2",
                   "enabled_lifetime": "0",
                   "state": "0",
                   "error": "",
                   "parameters": []
               },
               {
                   "itemid": "27426",
                   "type": "0",
                   "snmp_oid": "",
                   "hostid": "10202",
                   "name": "Mounted filesystem discovery",
                   "key_": "vfs.fs.discovery",
                   "delay": "1h",
                   "status": "0",
                   "trapper_hosts": "",
                   "templateid": "22450",
                   "valuemapid": "0",
                   "params": "",
                   "ipmi_sensor": "",
                   "authtype": "0",
                   "username": "",
                   "password": "",
                   "publickey": "",
                   "privatekey": "",
                   "flags": "1",
                   "interfaceid": "119",
                   "description": "Discovery of file systems of different types as defined in global regular expression \"File systems for discovery\".",
                   "lifetime": "30d",
                   "jmx_endpoint": "",
                   "master_itemid": "0",
                   "timeout": "",
                   "url": "",
                   "query_fields": [],
                   "posts": "",
                   "status_codes": "200",
                   "follow_redirects": "1",
                   "post_type": "0",
                   "http_proxy": "",
                   "headers": [],
                   "retrieve_mode": "0",
                   "request_method": "0",
                   "output_format": "0",
                   "ssl_cert_file": "",
                   "ssl_key_file": "",
                   "ssl_key_password": "",
                   "verify_peer": "0",
                   "verify_host": "0",
                   "allow_traps": "0",
                   "uuid": "",
                   "lifetime_type": "0",
                   "enabled_lifetime_type": "2",
                   "enabled_lifetime": "0",
                   "state": "0",
                   "error": "",
                   "parameters": []
               }
           ],
           "id": 1
       }Retrieve the name of the LLD rule "24681" and its filter conditions. The filter uses the "and" evaluation type, so the formula property is empty and eval_formula is generated automatically.
{
           "jsonrpc": "2.0",
           "method": "discoveryrule.get",
           "params": {
               "output": ["name"],
               "selectFilter": "extend",
               "itemids": ["24681"]
           },
           "id": 1
       }Response:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "itemid": "24681",
                   "name": "Filtered LLD rule",
                   "filter": {
                       "evaltype": "1",
                       "formula": "",
                       "conditions": [
                           {
                               "macro": "{#MACRO1}",
                               "value": "@regex1",
                               "operator": "8",
                               "formulaid": "A"
                           },
                           {
                               "macro": "{#MACRO2}",
                               "value": "@regex2",
                               "operator": "9",
                               "formulaid": "B"
                           },
                           {
                               "macro": "{#MACRO3}",
                               "value": "",
                               "operator": "12",
                               "formulaid": "C"
                           },
                           {
                               "macro": "{#MACRO4}",
                               "value": "",
                               "operator": "13",
                               "formulaid": "D"
                           }
                       ],
                       "eval_formula": "A and B and C and D"
                   }
               }
           ],
           "id": 1
       }Retrieve LLD rule for host by rule URL field value. Only exact match of URL string defined for LLD rule is supported.
{
           "jsonrpc": "2.0",
           "method": "discoveryrule.get",
           "params": {
               "hostids": "10257",
               "filter": {
                   "type": 19,
                   "url": "http://127.0.0.1/discoverer.php"
               }
           },
           "id": 1
       }Response:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "itemid": "28336",
                   "type": "19",
                   "snmp_oid": "",
                   "hostid": "10257",
                   "name": "API HTTP agent",
                   "key_": "api_discovery_rule",
                   "delay": "5s",
                   "status": "0",
                   "trapper_hosts": "",
                   "templateid": "0",
                   "valuemapid": "0",
                   "params": "",
                   "ipmi_sensor": "",
                   "authtype": "0",
                   "username": "",
                   "password": "",
                   "publickey": "",
                   "privatekey": "",
                   "flags": "1",
                   "interfaceid": "5",
                   "description": "",
                   "lifetime": "30d",
                   "jmx_endpoint": "",
                   "master_itemid": "0",
                   "timeout": "",
                   "url": "http://127.0.0.1/discoverer.php",
                   "query_fields": [
                       {
                           "name": "mode",
                           "value": "json"
                       },
                       {
                           "name": "elements",
                           "value": "2"
                       }
                   ],
                   "posts": "",
                   "status_codes": "200",
                   "follow_redirects": "1",
                   "post_type": "0",
                   "http_proxy": "",
                   "headers": [
                       {
                           "name" : "X-Type",
                           "value": "api"
                       },
                       {
                           "name": "Authorization",
                           "value": "Bearer mF_A.B5f-2.1JcM"
                       }
                   ],
                   "retrieve_mode": "0",
                   "request_method": "1",
                   "output_format": "0",
                   "ssl_cert_file": "",
                   "ssl_key_file": "",
                   "ssl_key_password": "",
                   "verify_peer": "0",
                   "verify_host": "0",
                   "allow_traps": "0",
                   "uuid": "",
                   "lifetime_type": "0",
                   "enabled_lifetime_type": "2",
                   "enabled_lifetime": "0",
                   "state": "0",
                   "error": "",
                   "parameters": []
               }
           ],
           "id": 1
       }Retrieve one LLD rule that has various override settings.
{
           "jsonrpc": "2.0",
           "method": "discoveryrule.get",
           "params": {
               "output": ["name"],
               "itemids": "30980",
               "selectOverrides": ["name", "step", "stop", "filter", "operations"]
           },
           "id": 1
       }Response:
{
           "jsonrpc": "2.0",
           "result": [
               {
                   "name": "Discover database host",
                   "overrides": [
                       {
                           "name": "Discover MySQL host",
                           "step": "1",
                           "stop": "1",
                           "filter": {
                               "evaltype": "2",
                               "formula": "",
                               "conditions": [
                                   {
                                       "macro": "{#UNIT.NAME}",
                                       "operator": "8",
                                       "value": "^mysqld\\.service$",
                                       "formulaid": "A"
                                   },
                                   {
                                       "macro": "{#UNIT.NAME}",
                                       "operator": "8",
                                       "value": "^mariadb\\.service$",
                                       "formulaid": "B"
                                   }
                               ],
                               "eval_formula": "A or B"
                           },
                           "operations": [
                               {
                                   "operationobject": "3",
                                   "operator": "2",
                                   "value": "Database host",
                                   "opstatus": {
                                       "status": "0"
                                   },
                                   "optag": [
                                       {
                                           "tag": "database",
                                           "value": "mysql"
                                       }
                                   ],
                                   "optemplate": [
                                       {
                                           "templateid": "10170"
                                       }
                                   ]
                               }
                           ]
                       },
                       {
                           "name": "Discover PostgreSQL host",
                           "step": "2",
                           "stop": "1",
                           "filter": {
                               "evaltype": "0",
                               "formula": "",
                               "conditions": [
                                   {
                                       "macro": "{#UNIT.NAME}",
                                       "operator": "8",
                                       "value": "^postgresql\\.service$",
                                       "formulaid": "A"
                                   }
                               ],
                               "eval_formula": "A"
                           },
                           "operations": [
                               {
                                   "operationobject": "3",
                                   "operator": "2",
                                   "value": "Database host",
                                   "opstatus": {
                                       "status": "0"
                                   },
                                   "optag": [
                                       {
                                           "tag": "database",
                                           "value": "postgresql"
                                       }
                                   ],
                                   "optemplate": [
                                       {
                                           "templateid": "10263"
                                       }
                                   ]
                               }
                           ]
                       }
                   ]
               }
           ],
           "id": 1
       }CDiscoveryRule::get() in ui/include/classes/api/services/CDiscoveryRule.php.