Zabbix Documentation 4.2

2.23.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.43.23.4

User Tools

Site Tools


manual:config:items:itemtypes:http

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:config:items:itemtypes:http [2018/07/02 12:34]
natalja.cernohajeva Added information about HTTP item check execution (first three sentences in the Overview)
manual:config:items:itemtypes:http [2019/05/21 14:07] (current)
martins-v fixing copy-paste error
Line 2: Line 2:
  
 === Overview === === Overview ===
-HTTP item check is a check executed by Zabbix server. However, when hosts are monitored by a Zabbix proxy, HTTP item checks are executed by the proxy. ​ 
- 
-HTTP item checks do not require any agent running on a host being monitored. 
  
 This item type allows data polling using the HTTP/HTTPS protocol. Trapping is also possible using Zabbix sender or Zabbix sender protocol. This item type allows data polling using the HTTP/HTTPS protocol. Trapping is also possible using Zabbix sender or Zabbix sender protocol.
 +
 +HTTP item check is executed by Zabbix server. However, when hosts are monitored by a Zabbix proxy, HTTP item checks are executed by the proxy. ​
 +
 +HTTP item checks do not require any agent running on a host being monitored.
  
 HTTP agent supports both HTTP and HTTPS. Zabbix will optionally follow redirects (see the //Follow redirects// option below). Maximum number of redirects is hard-coded to 10 (using cURL option CURLOPT_MAXREDIRS). HTTP agent supports both HTTP and HTTPS. Zabbix will optionally follow redirects (see the //Follow redirects// option below). Maximum number of redirects is hard-coded to 10 (using cURL option CURLOPT_MAXREDIRS).
Line 22: Line 23:
   * Enter parameters of the item in the form   * Enter parameters of the item in the form
  
-|{{:​manual:​config:​items:​itemtypes:​http_item_new.png?600|}}|+{{:​manual:​config:​items:​itemtypes:​http_item_1.png?600|}}
  
 All mandatory input fields are marked with a red asterisk. ​ All mandatory input fields are marked with a red asterisk. ​
Line 30: Line 31:
 |//​Type// ​  ​|Select **HTTP agent** here.   | |//​Type// ​  ​|Select **HTTP agent** here.   |
 |//​Key// ​ |Enter a unique item key.  | |//​Key// ​ |Enter a unique item key.  |
-|//​URL// ​ |URL to connect to and retrieve data. For example:\\ %%https://​www.google.com%%\\ %%http://​www.zabbix.com/​download%%\\ Domain names can be specified in Unicode characters. They are automatically punycode-converted to ASCII when executing the web scenario step.\\ The //Parse// button can be used to separate optional query fields (like ?​name=Admin&​password=mypassword) from the URL, moving the attributes and values into //Query fields// for automatic URL-encoding.\\ Limited to 2048 characters.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_URL.html|CURLOPT_URL]] cURL option. ​ |+|//​URL// ​ |URL to connect to and retrieve data. For example:\\ %%https://​www.google.com%%\\ %%http://​www.zabbix.com/​download%%\\ Domain names can be specified in Unicode characters. They are automatically punycode-converted to ASCII when executing the HTTP check.\\ The //Parse// button can be used to separate optional query fields (like ?​name=Admin&​password=mypassword) from the URL, moving the attributes and values into //Query fields// for automatic URL-encoding.\\ Limited to 2048 characters.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_URL.html|CURLOPT_URL]] cURL option. ​ |
 |//Query fields// ​ |Variables for the URL (see above).\\ Specified as attribute and value pairs.\\ Values are URL-encoded automatically. Values from macros are resolved and then URL-encoded automatically.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_URL.html|CURLOPT_URL]] cURL option. ​ | |//Query fields// ​ |Variables for the URL (see above).\\ Specified as attribute and value pairs.\\ Values are URL-encoded automatically. Values from macros are resolved and then URL-encoded automatically.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_URL.html|CURLOPT_URL]] cURL option. ​ |
 |//Request type// ​ |Select request method type: //GET//, //POST//, //PUT// or //​HEAD// ​ | |//Request type// ​ |Select request method type: //GET//, //POST//, //PUT// or //​HEAD// ​ |
Line 41: Line 42:
 |//Retrieve mode// ​ |Select the part of response that must be retrieved:​\\ **Body** - body only\\ **Headers** - headers only\\ **Body and headers** - body and headers ​ | |//Retrieve mode// ​ |Select the part of response that must be retrieved:​\\ **Body** - body only\\ **Headers** - headers only\\ **Body and headers** - body and headers ​ |
 |//Convert to JSON// ​ |Headers are saved as attribute and value pairs under the %%"​%%header%%"​%% key.\\ If '​Content-Type:​ application/​json'​ is encountered then body is saved as an object, otherwise it is stored as string, for example:\\ {{:​manual:​config:​items:​itemtypes:​http_conv_json.png|}} ​ | |//Convert to JSON// ​ |Headers are saved as attribute and value pairs under the %%"​%%header%%"​%% key.\\ If '​Content-Type:​ application/​json'​ is encountered then body is saved as an object, otherwise it is stored as string, for example:\\ {{:​manual:​config:​items:​itemtypes:​http_conv_json.png|}} ​ |
-|//HTTP proxy// ​ |You can specify an HTTP proxy to use, using the format ''​%%http://​[username[:​password]@]proxy.mycompany.com[:​port]%%''​.\\ By default, 1080 port will be used.\\ If specified, the proxy will overwrite proxy related environment variables like http_proxy, HTTPS_PROXY. If not specified, the proxy will not overwrite proxy-related environment variables. The entered value is passed on %%"​%%as is%%"​%%,​ no sanity checking takes place.\\ You may also enter a SOCKS proxy address. If you specify the wrong protocol, the connection will fail and the item will become unsupported. With no protocol specified, the proxy will be treated as an HTTP proxy.\\ //Note// that only simple authentication is supported with HTTP proxy.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_PROXY.html|CURLOPT_PROXY]] cURL option. ​ |+|//HTTP proxy// ​ |You can specify an HTTP proxy to use, using the format ''​%%[protocol://][username[:​password]@]proxy.mycompany.com[:​port]%%''​.\\ The optional ''​%%protocol://​%%''​ prefix may be used to specify alternative proxy protocols (the protocol prefix support was added in cURL 7.21.7). With no protocol specified, the proxy will be treated as an HTTP proxy.\\ By default, 1080 port will be used.\\ If specified, the proxy will overwrite proxy related environment variables like http_proxy, HTTPS_PROXY. If not specified, the proxy will not overwrite proxy-related environment variables. The entered value is passed on %%"​%%as is%%"​%%,​ no sanity checking takes place.\\ You may also enter a SOCKS proxy address. If you specify the wrong protocol, the connection will fail and the item will become unsupported.\\ //Note// that only simple authentication is supported with HTTP proxy.\\ Supported macros: {HOST.IP}, {HOST.CONN},​ {HOST.DNS}, {HOST.HOST},​ {HOST.NAME},​ {ITEM.ID}, {ITEM.KEY}, user macros, low-level discovery macros.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_PROXY.html|CURLOPT_PROXY]] cURL option. ​ |
 |//HTTP authentication// ​ |Authentication type:​\\ ​ **None** - no authentication used.\\ **Basic authentication** - basic authentication is used.\\ **NTLM authentication** - NTLM ([[http://​en.wikipedia.org/​wiki/​NTLM|Windows NT LAN Manager)]] authentication is used.\\ Selecting an authentication method will provide two additional fields for entering a user name and password, where user macros and low-level discovery macros are supported.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_HTTPAUTH.html|CURLOPT_HTTPAUTH]] cURL option. ​ | |//HTTP authentication// ​ |Authentication type:​\\ ​ **None** - no authentication used.\\ **Basic authentication** - basic authentication is used.\\ **NTLM authentication** - NTLM ([[http://​en.wikipedia.org/​wiki/​NTLM|Windows NT LAN Manager)]] authentication is used.\\ Selecting an authentication method will provide two additional fields for entering a user name and password, where user macros and low-level discovery macros are supported.\\ This sets the [[https://​curl.haxx.se/​libcurl/​c/​CURLOPT_HTTPAUTH.html|CURLOPT_HTTPAUTH]] cURL option. ​ |
 |//SSL verify peer// ​ |Mark the checkbox to verify the SSL certificate of the web server. The server certificate will be automatically taken from system-wide certificate authority (CA) location. You can override the location of CA files using Zabbix server or proxy configuration parameter SSLCALocation.\\ This sets the [[http://​curl.haxx.se/​libcurl/​c/​CURLOPT_SSL_VERIFYPEER.html|CURLOPT_SSL_VERIFYPEER]] cURL option. ​ | |//SSL verify peer// ​ |Mark the checkbox to verify the SSL certificate of the web server. The server certificate will be automatically taken from system-wide certificate authority (CA) location. You can override the location of CA files using Zabbix server or proxy configuration parameter SSLCALocation.\\ This sets the [[http://​curl.haxx.se/​libcurl/​c/​CURLOPT_SSL_VERIFYPEER.html|CURLOPT_SSL_VERIFYPEER]] cURL option. ​ |
Line 49: Line 50:
 |//SSL key password// ​ |SSL private key file password.\\ Supported macros: user macros, low-level discovery macros.\\ This sets the [[http://​curl.haxx.se/​libcurl/​c/​CURLOPT_KEYPASSWD.html|CURLOPT_KEYPASSWD]] cURL option. ​ | |//SSL key password// ​ |SSL private key file password.\\ Supported macros: user macros, low-level discovery macros.\\ This sets the [[http://​curl.haxx.se/​libcurl/​c/​CURLOPT_KEYPASSWD.html|CURLOPT_KEYPASSWD]] cURL option. ​ |
 |//Enable trapping// ​ |With this checkbox marked, the item will also function as [[:​manual/​config/​items/​itemtypes/​trapper|trapper item]] and will accept data sent to this item by Zabbix sender or using Zabbix sender protocol. ​ | |//Enable trapping// ​ |With this checkbox marked, the item will also function as [[:​manual/​config/​items/​itemtypes/​trapper|trapper item]] and will accept data sent to this item by Zabbix sender or using Zabbix sender protocol. ​ |
-|//Allowed hosts// ​  ​|Visible only if //Enable trapping// ​ checkbox is marked.\\ List of comma delimited IP addresses, optionally in CIDR notation, or hostnames.\\ If specified, incoming connections will be accepted only from the hosts listed here.\\ If IPv6 support is enabled then '​127.0.0.1',​ '::​127.0.0.1',​ '::​ffff:​127.0.0.1'​ are treated equally and '::/​0'​ will allow any IPv4 or IPv6 address.\\ '​0.0.0.0/​0'​ can be used to allow any IPv4 address.\\ Note, that "​IPv4-compatible IPv6 addresses"​ (0000::/96 prefix) are supported but deprecated by [[https://​tools.ietf.org/​html/​rfc4291#​section-2.5.5|RFC4291]].\\ Example: Server=127.0.0.1,​192.168.1.0/​24,::​1,​2001:​db8::/​32,​zabbix.domain\\ Spaces and [[manual:​config:​macros:​usermacros|user macros]] are allowed in this field. ​ |+|//Allowed hosts// ​  ​|Visible only if //Enable trapping// ​ checkbox is marked.\\ List of comma delimited IP addresses, optionally in CIDR notation, or hostnames.\\ If specified, incoming connections will be accepted only from the hosts listed here.\\ If IPv6 support is enabled then '​127.0.0.1',​ '::​127.0.0.1',​ '::​ffff:​127.0.0.1'​ are treated equally and '::/​0'​ will allow any IPv4 or IPv6 address.\\ '​0.0.0.0/​0'​ can be used to allow any IPv4 address.\\ Note, that "​IPv4-compatible IPv6 addresses"​ (0000::/96 prefix) are supported but deprecated by [[https://​tools.ietf.org/​html/​rfc4291#​section-2.5.5|RFC4291]].\\ Example: Server=127.0.0.1,​ 192.168.1.0/​24, 192.168.3.1-255,​ 192.168.1-10.1-255, ::​1,​2001:​db8::/​32,​ zabbix.domain\\ Spaces and [[manual:​config:​macros:​usermacros|user macros]] ​are allowed in this field.\\ Host macros: {HOST.HOST},​ {HOST.NAME},​ {HOST.IP}, {HOST.DNS}, {HOST.CONN} ​are allowed in this field. ​ |
  
 <note tip>If the //HTTP proxy// field is left empty, another way for using an HTTP proxy is to set proxy-related environment variables. ​ <note tip>If the //HTTP proxy// field is left empty, another way for using an HTTP proxy is to set proxy-related environment variables. ​
Line 151: Line 152:
 </​code>​ </​code>​
   * Now use a JSONPath preprocessing step to get the item value: ''​$.hits.hits[0]._source.value''​   * Now use a JSONPath preprocessing step to get the item value: ''​$.hits.hits[0]._source.value''​
 +
 +== Example 3 ==
 +
 +Checking if Zabbix API is alive, using ''​[[:​manual/​api/​reference/​apiinfo/​version|apiinfo.version]]''​.
 +
 +  * Item configuration:​
 +
 +{{:​manual:​config:​items:​itemtypes:​example3_a.png|}}
 +
 +Note the use of the POST method with JSON data, setting request headers and asking to return headers only:
 +
 +  * Item value preprocessing with regular expression to get HTTP code:
 +
 +{{:​manual:​config:​items:​itemtypes:​example3_b.png|}}
 +
 +  * Checking the result in //Latest data//:
 +
 +{{:​manual:​config:​items:​itemtypes:​example3_c.png?​600|}}
 +
 +== Example 4 ==
 +
 +Retrieving weather information by connecting to the Openweathermap public service.
 +
 +  * Configure a master item for bulk data collection in a single JSON:
 +
 +{{:​manual:​config:​items:​itemtypes:​example4_a.png|}}
 +
 +Note the usage of macros in query fields. Refer to the [[https://​openweathermap.org/​current|Openweathermap API]] for how to fill them.
 +
 +Sample JSON returned in response to HTTP agent:
 +
 +<code json>
 +{
 + "​body":​ {
 + "​coord":​ {
 + "​lon":​ 40.01,
 + "​lat":​ 56.11
 + },
 + "​weather":​ [{
 + "​id":​ 801,
 + "​main":​ "​Clouds",​
 + "​description":​ "few clouds",​
 + "​icon":​ "​02n"​
 + }],
 + "​base":​ "​stations",​
 + "​main":​ {
 + "​temp":​ 15.14,
 + "​pressure":​ 1012.6,
 + "​humidity":​ 66,
 + "​temp_min":​ 15.14,
 + "​temp_max":​ 15.14,
 + "​sea_level":​ 1030.91,
 + "​grnd_level":​ 1012.6
 + },
 + "​wind":​ {
 + "​speed":​ 1.86,
 + "​deg":​ 246.001
 + },
 + "​clouds":​ {
 + "​all":​ 20
 + },
 + "​dt":​ 1526509427,
 + "​sys":​ {
 + "​message":​ 0.0035,
 + "​country":​ "​RU",​
 + "​sunrise":​ 1526432608,
 + "​sunset":​ 1526491828
 + },
 + "​id":​ 487837,
 + "​name":​ "​Stavrovo",​
 + "​cod":​ 200
 + }
 +}
 +</​code>​
 +
 +The next task is to configure dependent items that extract data from the JSON.
 +
 +  * Configure a sample dependent item for humidity:
 +
 +{{:​manual:​config:​items:​itemtypes:​example4_b.png|}}
 +
 +Other weather metrics such as '​Temperature'​ are added in the same manner.
 +
 +  * Sample dependent item value preprocessing with JSONPath:
 +
 +{{:​manual:​config:​items:​itemtypes:​example4_c.png|}}
 +
 +  * Check the result of weather data in //Latest data//:
 +
 +{{:​manual:​config:​items:​itemtypes:​example4_d.png?​600|}}
 +
 +== Example 5 ==
 +
 +Connecting to Nginx status page and getting its metrics in bulk.
 +
 +  * Configure Nginx following the [[https://​nginx.ru/​en/​docs/​http/​ngx_http_stub_status_module.html|official guide]].
 +
 +  * Configure a master item for bulk data collection:
 +
 +{{:​manual:​config:​items:​itemtypes:​example5_a.png?​500|}}
 +
 +Sample Nginx stub status output:
 +
 +  Active connections:​ 1 Active connections:​
 +  server accepts handled requests
 +   52 52 52 
 +  Reading: 0 Writing: 1 Waiting: 0
 +
 +The next task is to configure dependent items that extract data.
 +
 +  * Configure a sample dependent item for requests per second:
 +
 +{{:​manual:​config:​items:​itemtypes:​example5_b.png|}}
 +
 +  * Sample dependent item value preprocessing with regular expression:
 +
 +{{:​manual:​config:​items:​itemtypes:​example5_c.png?​600|}}
 +
 +  * Check the complete result from stub module in //Latest data//:
 +
 +{{:​manual:​config:​items:​itemtypes:​example5_d.png?​600|}}