Zabbix Documentation 4.4

3.04.04.4 (current)| In development:5.0 (devel)| Unsupported:1.82.02.22.43.23.44.2Guidelines

User Tools

Site Tools


manual:api:reference:item:get

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:api:reference:item:get [2017/10/06 14:12]
127.0.0.1 external edit
manual:api:reference:item:get [2019/08/14 06:44] (current)
miks.kronkalns Renamed "Check for error in regular expression" to "Check for error using regular expression"
Line 32: Line 32:
 | with_triggers | boolean | If set to ''​true''​ return only items that are used in triggers. | | with_triggers | boolean | If set to ''​true''​ return only items that are used in triggers. |
 ^ ||| ^ |||
-| selectHosts | query | Returns the host that the item belongs to as an array in the ''​hosts''​ property. | +| selectHosts | query | Return a ''​[[:​manual/​api/​reference/​host/​object|hosts]]''​ property ​with an array of hosts that the item belongs to 
-| selectInterfaces | query | Returns the host interface used by the item as an array in the ''​interfaces''​ property. | +| selectInterfaces | query | Return ​an ''​[[:​manual/​api/​reference/​hostinterface/​object|interfaces]]''​ property ​with an array of host interfaces used by the item 
-| selectTriggers | query | Return triggers that the item is used in in the ''​triggers''​ property. \\ \\ Supports ''​count''​. | +| selectTriggers | query | Return ​a ''​[[:​manual/​api/​reference/​trigger/​object|triggers]]''​ property with the triggers that the item is used in.\\ \\ Supports ''​count''​. ​ 
-| selectGraphs | query | Return ​graphs that contain the item in the ''​graphs''​ property. \\ \\ Supports ''​count''​. | +| selectGraphs | query | Return ​''​[[:​manual/​api/​reference/​graph/​object|graphs]]''​ property ​with the graphs that contain the item.\\ \\ Supports ''​count''​. ​ 
-| selectApplications | query | Return the applications that the item belongs to in the ''​applications''​ property. | +| selectApplications | query | Return ​an ''​[[:​manual/​api/​reference/​application/​object|applications]]''​ property with the applications that the item belongs to.  
-| selectDiscoveryRule | query | Return the LLD rule that created the item in the ''​discoveryRule''​ property. | +| selectDiscoveryRule | query | Return ​a ''​[[:​manual/​api/​reference/​drule/​object|discoveryRule]]''​ property with the LLD rule that created the item. | 
-| selectItemDiscovery | query | Return ​the item discovery object in the ''​itemDiscovery''​ property. The item discovery object links the item to an item prototype from which it was created. \\ \\  It has the following properties: \\ ''​itemdiscoveryid''​ - ''​(string)''​ ID of the item discovery; \\ ''​itemid''​ - ''​(string)''​ ID of the discovered item; \\ ''​parent_itemid''​ - ''​(string)''​ ID of the item prototype from which the item has been created; \\ ''​key_''​ - ''​(string)''​ key of the item prototype; \\ ''​lastcheck''​ - ''​(timestamp)''​ time when the item was last discovered; \\ ''​ts_delete''​ - ''​(timestamp)''​ time when an item that is no longer discovered will be deleted. | +| selectItemDiscovery | query | Return ​an ''​itemDiscovery''​ property ​with the item discovery object. The item discovery object links the item to an item prototype from which it was created. \\ \\  It has the following properties: \\ ''​itemdiscoveryid''​ - ''​(string)''​ ID of the item discovery; \\ ''​itemid''​ - ''​(string)''​ ID of the discovered item; \\ ''​parent_itemid''​ - ''​(string)''​ ID of the item prototype from which the item has been created; \\ ''​key_''​ - ''​(string)''​ key of the item prototype; \\ ''​lastcheck''​ - ''​(timestamp)''​ time when the item was last discovered; \\ ''​ts_delete''​ - ''​(timestamp)''​ time when an item that is no longer discovered will be deleted. | 
-| selectPreprocessing | query | Return ​item preprocessing options in ''​preprocessing''​ property. \\ \\ It has the following properties: \\ ''​type''​ - ''​(string)''​ The preprocessing option ​types: \\ 1 - Custom multiplier; \\ 2 - Right trim; \\ 3 - Left trim; \\ 4 - Trim; \\ 5 - Regular expression matching; \\ 6 - Boolean to decimal; \\ 7 - Octal to decimal; \\ 8 - Hexadecimal to decimal; \\ 9 - Simple change; \\ 10 - Change per second. \\ \\ ''​params''​ - ''​(string)''​ Additional parameters used by preprocessing option. Multiple parameters are separated by LF (\n)character. |+| selectPreprocessing | query | Return ​''​preprocessing''​ property ​with item preprocessing options.\\ \\ It has the following properties: \\ ''​type''​ - ''​(string)''​ The preprocessing option ​type: \\ 1 - Custom multiplier; \\ 2 - Right trim; \\ 3 - Left trim; \\ 4 - Trim; \\ 5 - Regular expression matching; \\ 6 - Boolean to decimal; \\ 7 - Octal to decimal; \\ 8 - Hexadecimal to decimal; \\ 9 - Simple change; \\ 10 - Change per second; \\ 11 - XML XPath; \\ 12 - JSONPath; \\ 13 - In range; \\ 14 - Matches regular expression; \\ 15 - Does not match regular expression; \\ 16 - Check for error in JSON; \\ 17 - Check for error in XML; \\ 18 - Check for error using regular expression; \\ 19 - Discard unchanged; \\ 20 - Discard unchanged with heartbeat; \\ 21 - JavaScript; \\ 22 - Prometheus pattern; \\ 23 - Prometheus to JSON. \\ \\ ''​params''​ - ''​(string)''​ Additional parameters used by preprocessing option. Multiple parameters are separated by LF (\n)character. \\ ''​error_handler''​ - ''​(string)''​ Action type used in case of preprocessing step failure: \\ 0 - Error message is set by Zabbix server; \\ 1 - Discard value; \\ 2 - Set custom value; \\ 3 - Set custom error message. \\ \\ ''​error_handler_params''​ - ''​(string)''​ Error handler parameters. |
 ^ ||| ^ |||
 |filter ​ | object |Return only those results that exactly match the given filter.\\ \\ Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. \\ \\ Supports additional filters: \\ ''​host''​ - technical name of the host that the item belongs to. | |filter ​ | object |Return only those results that exactly match the given filter.\\ \\ Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. \\ \\ Supports additional filters: \\ ''​host''​ - technical name of the host that the item belongs to. |
Line 68: Line 68:
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 86: Line 86:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 117: Line 117:
             "​snmpv3_contextname":​ "",​             "​snmpv3_contextname":​ "",​
             "​error":​ "",​             "​error":​ "",​
-            "​lastlogsize":​ "​0",​ 
             "​logtimefmt":​ "",​             "​logtimefmt":​ "",​
             "​templateid":​ "​22680",​             "​templateid":​ "​22680",​
Line 128: Line 127:
             "​publickey":​ "",​             "​publickey":​ "",​
             "​privatekey":​ "",​             "​privatekey":​ "",​
-            "​mtime":​ "​0",​ 
             "​lastns":​ "​564054253",​             "​lastns":​ "​564054253",​
             "​flags":​ "​0",​             "​flags":​ "​0",​
Line 136: Line 134:
             "​inventory_link":​ "​0",​             "​inventory_link":​ "​0",​
             "​lifetime":​ "​0s",​             "​lifetime":​ "​0s",​
-            "​evaltype":​ "​0"​+            "​evaltype": "​0",​ 
 +            "​jmx_endpoint":​ "",​ 
 +            "​master_itemid":​ "​0",​ 
 +            "​timeout":​ "​3s",​ 
 +            "​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"​
         },         },
         {         {
Line 165: Line 183:
             "​snmpv3_contextname":​ "",​             "​snmpv3_contextname":​ "",​
             "​error":​ "",​             "​error":​ "",​
-            "​lastlogsize":​ "​0",​ 
             "​logtimefmt":​ "",​             "​logtimefmt":​ "",​
             "​templateid":​ "​17354",​             "​templateid":​ "​17354",​
Line 176: Line 193:
             "​publickey":​ "",​             "​publickey":​ "",​
             "​privatekey":​ "",​             "​privatekey":​ "",​
-            "​mtime":​ "​0",​ 
             "​lastns":​ "​564256864",​             "​lastns":​ "​564256864",​
             "​flags":​ "​0",​             "​flags":​ "​0",​
Line 184: Line 200:
             "​inventory_link":​ "​0",​             "​inventory_link":​ "​0",​
             "​lifetime":​ "​0s",​             "​lifetime":​ "​0s",​
-            "​evaltype":​ "​0"​+            "​evaltype": "​0",​ 
 +            "​jmx_endpoint":​ "",​ 
 +            "​master_itemid":​ "​0",​ 
 +            "​timeout":​ "​3s",​ 
 +            "​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"​
         },         },
         {         {
Line 212: Line 248:
             "​snmpv3_contextname":​ "",​             "​snmpv3_contextname":​ "",​
             "​error":​ "",​             "​error":​ "",​
-            "​lastlogsize":​ "​0",​ 
             "​logtimefmt":​ "",​             "​logtimefmt":​ "",​
             "​templateid":​ "​22671",​             "​templateid":​ "​22671",​
Line 223: Line 258:
             "​publickey":​ "",​             "​publickey":​ "",​
             "​privatekey":​ "",​             "​privatekey":​ "",​
-            "​mtime":​ "​0",​ 
             "​lastns":​ "​564661387",​             "​lastns":​ "​564661387",​
             "​flags":​ "​0",​             "​flags":​ "​0",​
Line 231: Line 265:
             "​inventory_link":​ "​0",​             "​inventory_link":​ "​0",​
             "​lifetime":​ "​0s",​             "​lifetime":​ "​0s",​
-            "​evaltype":​ "​0"​+            "​evaltype": "​0",​ 
 +            "​jmx_endpoint":​ "",​ 
 +            "​master_itemid":​ "​0",​ 
 +            "​timeout":​ "​3s",​ 
 +            "​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"​
         }         }
     ],     ],
Line 240: Line 294:
 === Finding dependent items by key === === Finding dependent items by key ===
  
-Retrieve all Dependent ​items from host with ID "​10116"​ that have the word "​apache"​ in the key.+Retrieve all dependent ​items from host with ID "​10116"​ that have the word "​apache"​ in the key.
  
 Request: Request:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 263: Line 317:
  
 Response: Response:
-<​code ​js>+<​code ​java>
 { {
     "​jsonrpc":​ "​2.0",​     "​jsonrpc":​ "​2.0",​
Line 288: Line 342:
             "​formula":​ "",​             "​formula":​ "",​
             "​error":​ "",​             "​error":​ "",​
-            "​lastlogsize":​ "​0",​ 
             "​logtimefmt":​ "",​             "​logtimefmt":​ "",​
             "​templateid":​ "​0",​             "​templateid":​ "​0",​
Line 299: Line 352:
             "​publickey":​ "",​             "​publickey":​ "",​
             "​privatekey":​ "",​             "​privatekey":​ "",​
-            "​mtime":​ "​0",​ 
             "​flags":​ "​0",​             "​flags":​ "​0",​
             "​interfaceid":​ "​0",​             "​interfaceid":​ "​0",​
Line 313: Line 365:
             "​master_itemid":​ "​25545",​             "​master_itemid":​ "​25545",​
             "​jmx_endpoint":​ "",​             "​jmx_endpoint":​ "",​
 +            "​timeout":​ "​3s",​
 +            "​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",​
             "​lastclock":​ "​0",​             "​lastclock":​ "​0",​
             "​lastns":​ "​0",​             "​lastns":​ "​0",​
Line 339: Line 409:
             "​formula":​ "",​             "​formula":​ "",​
             "​error":​ "",​             "​error":​ "",​
-            "​lastlogsize":​ "​0",​ 
             "​logtimefmt":​ "",​             "​logtimefmt":​ "",​
             "​templateid":​ "​0",​             "​templateid":​ "​0",​
Line 350: Line 419:
             "​publickey":​ "",​             "​publickey":​ "",​
             "​privatekey":​ "",​             "​privatekey":​ "",​
-            "​mtime":​ "​0",​ 
             "​flags":​ "​0",​             "​flags":​ "​0",​
             "​interfaceid":​ "​0",​             "​interfaceid":​ "​0",​
Line 364: Line 432:
             "​master_itemid":​ "​25545",​             "​master_itemid":​ "​25545",​
             "​jmx_endpoint":​ "",​             "​jmx_endpoint":​ "",​
 +            "​timeout":​ "​3s",​
 +            "​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",​
             "​lastclock":​ "​0",​             "​lastclock":​ "​0",​
             "​lastns":​ "​0",​             "​lastns":​ "​0",​
Line 370: Line 456:
         }         }
     ],     ],
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +=== Find HTTP agent item ===
 +
 +Find HTTP agent item with post body type XML for specific host id.
 +
 +Request:
 +
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​item.get",​
 +    "​params":​ {
 +        "​hostids":​ "​10255",​
 +        "​filter":​ {
 +            "​type":​ "​19",​
 +            "​post_type":​ "​3"​
 +        }
 +    },
 +    "​id":​ 3,
 +    "​auth":​ "​d678e0b85688ce578ff061bd29a20d3b"​
 +}
 +</​code>​
 +
 +Response:
 +
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ [
 +        {
 +            "​itemid":​ "​28252",​
 +            "​type":​ "​19",​
 +            "​snmp_community":​ "",​
 +            "​snmp_oid":​ "",​
 +            "​hostid":​ "​10255",​
 +            "​name":​ "​template item",
 +            "​key_":​ "​ti",​
 +            "​delay":​ "​30s",​
 +            "​history":​ "​90d",​
 +            "​trends":​ "​365d",​
 +            "​status":​ "​0",​
 +            "​value_type":​ "​3",​
 +            "​trapper_hosts":​ "",​
 +            "​units":​ "",​
 +            "​snmpv3_securityname":​ "",​
 +            "​snmpv3_securitylevel":​ "​0",​
 +            "​snmpv3_authpassphrase":​ "",​
 +            "​snmpv3_privpassphrase":​ "",​
 +            "​formula":​ "",​
 +            "​error":​ "",​
 +            "​logtimefmt":​ "",​
 +            "​templateid":​ "​0",​
 +            "​valuemapid":​ "​0",​
 +            "​params":​ "",​
 +            "​ipmi_sensor":​ "",​
 +            "​authtype":​ "​0",​
 +            "​username":​ "",​
 +            "​password":​ "",​
 +            "​publickey":​ "",​
 +            "​privatekey":​ "",​
 +            "​flags":​ "​0",​
 +            "​interfaceid":​ "​0",​
 +            "​port":​ "",​
 +            "​description":​ "",​
 +            "​inventory_link":​ "​0",​
 +            "​lifetime":​ "​30d",​
 +            "​snmpv3_authprotocol":​ "​0",​
 +            "​snmpv3_privprotocol":​ "​0",​
 +            "​state":​ "​0",​
 +            "​snmpv3_contextname":​ "",​
 +            "​evaltype":​ "​0",​
 +            "​jmx_endpoint":​ "",​
 +            "​master_itemid":​ "​0",​
 +            "​timeout":​ "​3s",​
 +            "​url":​ "​localhost",​
 +            "​query_fields":​ [
 +                {
 +                    "​mode":​ "​xml"​
 +                }
 +            ],
 +            "​posts":​ "<​body>​\r\n<​![CDATA[{$MACRO}<​foo></​bar>​]]>​\r\n</​body>",​
 +            "​status_codes":​ "​200",​
 +            "​follow_redirects":​ "​0",​
 +            "​post_type":​ "​3",​
 +            "​http_proxy":​ "",​
 +            "​headers":​ [],
 +            "​retrieve_mode":​ "​1",​
 +            "​request_method":​ "​3",​
 +            "​output_format":​ "​0",​
 +            "​ssl_cert_file":​ "",​
 +            "​ssl_key_file":​ "",​
 +            "​ssl_key_password":​ "",​
 +            "​verify_peer":​ "​0",​
 +            "​verify_host":​ "​0",​
 +            "​allow_traps":​ "​0",​
 +            "​lastclock":​ "​0",​
 +            "​lastns":​ "​0",​
 +            "​lastvalue":​ "​0",​
 +            "​prevvalue":​ "​0"​
 +        }
 +    ],
 +    "​id":​ 3
 +}
 +</​code>​
 +
 +=== Retrieving items with preprocessing rules ===
 +Reatrieve all items and their preprocessing rules from host with ID "​10254"​.
 +
 +Request:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​method":​ "​item.get",​
 +    "​params":​ {
 +        "​output":​ ["​itemid",​ "​name",​ "​key_"​],​
 +        "​selectPreprocessing":​ "​extend",​
 +        "​hostids":​ "​10254"​
 +    },
 +    "​auth":​ "​038e1d7b1735c6a5436ee9eae095879e",​
 +    "​id":​ 1
 +}
 +</​code>​
 +
 +Response:
 +<code java>
 +{
 +    "​jsonrpc":​ "​2.0",​
 +    "​result":​ {
 +        "​itemid":​ "​23865",​
 +        "​name":​ "http agent example JSON",
 +        "​key_":​ "​json",​
 +        "​preprocessing":​ [
 +            {
 +                "​type":​ "​12",​
 +                "​params":​ "​$.random",​
 +                "​error_handler":​ "​1",​
 +                "​error_handler_params":​ ""​
 +            }
 +        ]
 +    },
     "​id":​ 1     "​id":​ 1
 } }