For quite some time we’ve been building out Custos – a network service monitoring tool.
Recently, while working with a few teams to develop external APIs the discussion came around to monitoring API availability and performance.
This was exciting for us! One of the claims we make about Custos is that creating custom monitors is super easy. It follows that a service monitor for almost any API can be created with Custos.
In only a few short minutes we were able to construct a PHP based monitoring script that was able to run a proper HTTP-API request, collect metrics (size, speed) and send the reports to Custos. Super easy!
$ch = curl_init('http://server/api/listTarget'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); $body = curl_exec($ch); $info = curl_info($ch); $ttfb = $info['starttransfer_time'] * 1000; $ttlb = $info['total_time'] * 1000; $size = $info['size_download']; echo "status Goodn"; echo "detail Testing the List Target APIn"; echo "metric ttfb=$ttfbn"; echo "metric ttlb=$ttlbn"; echo "metric size=$sizen";
How cool was that?