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: ConfigurationHosts

    • 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:

    1. {
    2. "name" : "YQ2VAY-",
    3. "cluster_name" : "elasticsearch",
    4. "cluster_uuid" : "kH4CYqh5QfqgeTsjh2F9zg",
    5. "version" : {
    6. "number" : "6.1.3",
    7. "build_hash" : "af51318",
    8. "build_date" : "2018-01-26T18:22:55.523Z",
    9. "build_snapshot" : false,
    10. "lucene_version" : "7.1.0",
    11. "minimum_wire_compatibility_version" : "5.6.0",
    12. },
    13. }
    • 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:
    1. {
    2. "_scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAAkFllRMlZBWS1UU1pxTmdEeGVwQjRBTFEAAAAAAAAAJRZZUTJWQVktVFNacU5nRHhlcEI0QUxRAAAAAAAAACYWWVEyVkFZLVRTWnFOZ0R4ZXBCNEFMUQAAAAAAAAAnFllRMlZBWS1UU1pxTmdEeGVwQjRBTFEAAAAAAAAAKBZZUTJWQVktVFNacU5nRHhlcEI0QUxR",
    3. "took": 18,
    4. "timed_out": false,
    5. "_shards": {
    6. "total": 5,
    7. "successful": 5,
    8. "skipped": 0,
    9. "failed": 0
    10. },
    11. "hits": {
    12. "total": 1,
    13. "max_score": 1.0,
    14. "hits": [{
    15. "_type": "values",
    16. "_id": "dqX9VWEBV6sEKSMyk6sw",
    17. "_score": 1.0,
    18. "itemid": 28275,
    19. "value": "0.138750",
    20. "clock": 1517566136,
    21. "ns": 25388713,
    22. "ttl": 604800
    23. }
    24. }]
    25. }
    26. }
    • 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:

    17 HTTP agent - 图3

    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:

    17 HTTP agent - 图5

    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:

    17 HTTP agent - 图8

    • 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:

    17 HTTP agent - 图10

    Sample Nginx stub status output:

    1. Active connections: 1 Active connections:
    2. server accepts handled requests
    3. 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:

    17 HTTP agent - 图13