Skip to content

JSON API Monitoring with the HTTP Agent Item

Video Lecture

JSON API Monitoring with the HTTP Agent Item JSON API Monitoring with the HTTP Agent Item

Description

Many devices and services now provide REST APIs that you can query and get JSON formatted data as a response. In this video I will show you how to create an Item that uses the HTTP Agent type to query an external REST API and extract its data.

In case you don't have a REST API handy that you can query, I have created a test REST API you can use. It has several methods that return test data.

Like with Web Scenarios, the HTTP agent item type is executed from the Zabbix server, or proxy if the host is monitored by proxy.

Note

The returned data is randomized. This is testing data only for the purpose of demonstrating reading it in Zabbix.

Get A List of Example Users and Scores

Request

https://sbcode.net/api/getTestUsers

Response

[{"id":0,"name":"Red Cat","score":80},{"id":1,"name":"Green Dog","score":8},{"id":2,"name":"Blue Bird","score":82},{"id":3,"name":"Yellow Tiger","score":19},{"id":4,"name":"Orange Koala","score":22}]

JSONPath to extract Yellow Tigers score

$[3].score

JSONPath to extract Yellow Tigers ID

$[3].id

Get a specific Example User and Score by ID

Request

https://sbcode.net/api/getTestUsers/1

Response

{"id":1,"name":"Green Dog","score":29}

JSONPath to extract Green Dogs score

$.score

Get A List of Example Users and Scores (Requires Basic Authentication)

Username : user

Password : pass

Request

https://sbcode.net/api/getTestUsersAuth

Response

[{"id":0,"name":"Red Cat","score":65},{"id":1,"name":"Green Dog","score":72},{"id":2,"name":"Blue Bird","score":91},{"id":3,"name":"Yellow Tiger","score":89},{"id":4,"name":"Orange Koala","score":47}]

JSONPath to extract Red Cats score

$[0].score

Get a specific Example User and Score by ID (Requires Basic Authentication)

https://sbcode.net/api/getTestUsersAuth/1

Response

{"id":1,"name":"Green Dog","score":45}

JSONPath to extract Green Dogs score

$.score

Test some JSON path queries on your JSON API responses.

https://jsonpath.com/

Zabbix JSONPath Examples

Comments