Overview
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).
See also known issues for when using HTTPS protocol.
Zabbix server/proxy must be initially configured with cURL (libcurl) support.
Configuration
To configure an HTTP item:
Go to: Configuration → Hosts
Click on Items in the row of the host
Click on Create item
Enter parameters of the item in the form
All mandatory input fields are marked with a red asterisk.
The fields that require specific information for HTTP items are:
If the HTTP proxy field is left empty, another way for using an HTTP proxy is to set proxy-related environment variables.
For HTTPS - set the HTTPS_PROXY
environment variable. For example:
HTTPS_PROXY=. More details are available by running a shell command: # man curl.
[1] Zabbix supports certificate and private key files in PEM format only. In case you have your certificate and private key data in PKCS #12 format file (usually with extention *.p12 or *.pfx) you may generate the PEM file from it using the following commands:
Examples
Example 1
Send simple GET requests to retrieve data from services such as Elasticsearch:
Create a GET item with URL:
localhost:9200/?pretty
Notice the response:
{
"name" : "YQ2VAY-",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "kH4CYqh5QfqgeTsjh2F9zg",
"version" : {
"number" : "6.1.3",
"build_hash" : "af51318",
"build_date" : "2018-01-26T18:22:55.523Z",
"build_snapshot" : false,
"lucene_version" : "7.1.0",
"minimum_wire_compatibility_version" : "5.6.0",
},
}
- Now extract the version number using a JSONPath preprocessing step:
$.version.number
Example 2
Send simple POST requests to retrieve data from services such as Elasticsearch:
Create a POST item with URL:
[http://localhost:9200/str/values/_search?scroll=10s](http://localhost:9200/str/values/_search?scroll=10s "http://localhost:9200/str/values/_search?scroll=10s")
Configure the following POST body to obtain the processor load (1 min average per core)
- Received:
{
"_scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAAkFllRMlZBWS1UU1pxTmdEeGVwQjRBTFEAAAAAAAAAJRZZUTJWQVktVFNacU5nRHhlcEI0QUxRAAAAAAAAACYWWVEyVkFZLVRTWnFOZ0R4ZXBCNEFMUQAAAAAAAAAnFllRMlZBWS1UU1pxTmdEeGVwQjRBTFEAAAAAAAAAKBZZUTJWQVktVFNacU5nRHhlcEI0QUxR",
"took": 18,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [{
"_type": "values",
"_id": "dqX9VWEBV6sEKSMyk6sw",
"_score": 1.0,
"itemid": 28275,
"value": "0.138750",
"clock": 1517566136,
"ns": 25388713,
"ttl": 604800
}
}]
}
}
- 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 [apiinfo.version]($dfe5c4170a80f935.md "manual:api:reference:apiinfo:version")
.
- Item configuration:
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:
- Checking the result in Latest data:
Example 4
Retrieving weather information by connecting to the Openweathermap public service.
- Configure a master item for bulk data collection in a single JSON:
Note the usage of macros in query fields. Refer to the Openweathermap API for how to fill them.
Sample JSON returned in response to HTTP agent:
The next task is to configure dependent items that extract data from the JSON.
- Configure a sample dependent item for humidity:
Other weather metrics such as ‘Temperature’ are added in the same manner.
- Sample dependent item value preprocessing with JSONPath:
- Check the result of weather data in Latest data:
Example 5
Connecting to Nginx status page and getting its metrics in bulk.
Configure Nginx following the .
Configure a master item for bulk data collection:
Sample Nginx stub status output:
Active connections: 1 Active connections:
server accepts handled requests
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:
- Sample dependent item value preprocessing with regular expression: