We had an issue a couple of days ago where two points of failure caused some downtime and so I spent most of today revisiting all my monitors to give us as much warning as possible if one of our services fails.
One particular API I set up lives on the as400 (iSeries) and operates off of it’s ZendCore server in PHP. I quickly scripted a page to verify: connection between ZendCore PHP and db2, that the connection to that endpoint was in fact SSL, and on what port.
The PHP code is very simple and returns a JSON string that looks like this:
{ "AS400CONNECTION": true, "SSL": true, "PORT": "633" }
The slight problem today was figuring out how to get Site 24×7 to not just verify the link, but check the JSON values and verify it is what I need. If not, then send the alert. In this case, I want to verify AS400CONNECTION is true and SSL is true.
Site 24×7 suggests using a REST API monitor and then asserting the value in JSONPath. I was completely new to this and finding a good clean example was a bit tough, hopefully this saves someone some time. Here’s how I setup the JSONPath expression:
$[?(@.AS400CONNECTION==true)]
$[?(@.SSL==true)]
For a full screenshot of the setup I did to make this work click here.