Features

BOOM ... Health Checks!

Website Monitoring Magazine

koality.io is incredibly strong when it comes to looking at a website from the outside and then saying whether it works - from a user's point of view, from a search engine's point of view, or from a bot's point of view. We try to cover 360° and take everything important in monitoring.

Nevertheless, every project on the web also has its individual problems that can't be checked with standard checks. We at koality.io have been sitting together for a while now, thinking about how to implement these custom checks in a way that doesn't dilute the idea behind our product, which is to be an easy-to-use service. So the big question is, how can you think in terms of standard and still allow for custom checks? And as you can guess, the answer is "Health Checks."

What are health checks?

Quite simple, actually. For us, health checks are information about whether an application and its infrastructure are working. The best way to do this is to supplement the data we measure from the outside to give us an overall picture. This is then summarized in a response that koality.io can read. Sounds very simple at first. It is.

But what could such health checks contain? We have put together a few ideas:

  • Server monitoring: How full is the hard disk? How has the CPU usage been in the last five minutes? Is my server swapping?

  • Infrastructure: Is MySQL running? Is there a database backup every hour? Is Redis still accessible? Can I reach all web services from the server?

  • Application: Are my cron jobs running? Is the cache directory writable? How many entries did the error log have in the last 60 minutes?

Of course, there are already tools that monitor exactly this, but often it's easier to quickly build the one small check you want yourself and then plug it into standard monitoring than it is to maintain a Prometheus or teach Icinga to the project managers. And let's not kid ourselves: most projects - especially in agencies - can't handle any more complexity.

How can I build my own checks?

This is the great thing about this approach. It is very easy for any developer to implement such checks in any language. The only thing you need to do is to provide a JSON document in response to an HTTP request. And that's exactly what we developers do all day long.

It was important to us to take an open standard for the health checks and then, in the best case, to extend it in only two places. We succeeded in doing that. The IETF (Internet Engineering Task Force) has published an RFC that deals exactly with this topic. In principle, it defines a fairly simple JSON format that reflects the health of an application or server.

{
    "status": "pass",
    "output": "Storage server is up and running.",
    "checks": {
        "leankoala.device.space.used": {
            "status": "pass",
            "output": "Enough space left on device. 66% used (\/).",
            "observedValue": 0.66,
            "observedUnit": "percent",
            "metricType": "time_series_percent",
            "observedValuePrecision": 2,
            "limit": 0.9,
            "limitType": "max"
        },
        "leankoala.apps.chrome": {
            "status": "pass",
            "output": "Number of processes \"chromium\" was within limits. Current number is 35.",
            "description": "Number of chrome browsers running.",
            "observedValue": 35,
            "observedUnit": "process",
            "metricType": "time_series_numeric",
            "observedValuePrecision": 0,
            "limit": 50,
            "limitType": "max"
        }
    }
}

This is a simple example that checks how many Chrome processes are running in the background and whether the disk is not too full. You can see from the example that we are also using this new feature a lot, because these are exactly the two parameters that we are interested in for a worker.

In our case, it's PHP that creates that file. Basically, it doesn't matter who does it - the main thing is to follow the standard. In koality.io you just have to enter the URL where this document will be delivered and you are done. As soon as one of the checks returns an error, an alert is sent via E_mail, Slack or Teams. Simple.

If you add to the metric_type field and put time_series_numeric there, you get another wonderful view about the historical values in the koality.io backend.

I don't think it's ever been easier to implement and monitor your own metrics via a monitoring tool.

Activate plugin

The plugin for Health Check support can be easily activated in the Marketplace in the koality.io backend. After that it will run immediately. Currently it is beta, but fully functional.

Health Foundation

koality.io wouldn't be koality.io if we didn't try to standardize this standard as well. For this reason we have already created a PHP base library called HealthFoundation, which everyone can use. There is already relatively much of what you need included. But it is also open source for the reason that we hope that you will include your standard checks.

The first dozen checks are already implemented and will be developed further as soon as we have a need. If you have one, feel free to submit a pull request.

Will there be prefabricated health checks for my framework?

The answer is YES. We believe that this kind of monitoring is so simple that experienced developers won't need more than one day to adapt it for their CMS or store system. After that, you should be happy to make it available to everyone. If it turned out to be a good plugin, we would make a real koality.io plugin out of it and put it in our marketplace. However, this is not absolutely necessary, since the Health Check plugin is already available to everyone. As always, of course, we are happy to support if you have something nice in mind. Just contact us via Twitter.

Which systems are already supported?

Through our HealthFoundation every PHP project is already able to create a simple Health-Check, but of course we are busy and have the first real plugins ready or in work. This list will be updated constantly.

Which systems have already been requested?

Of course we get daily requests when we will offer a plugin for framework XY. We want to list the most frequent ones here. Maybe one or the other would like to become active with us here.

  • Symfony 5
  • Joomla!
  • Typo3
  • WooCommerce
  • WordPress

Security

When you build your own health checks, you obviously have to make sure that you take the necessary security measures. The minimum is HTTPS transmission of the data and an endpoint secured by a hash as complex as possible. Of course, only if it is worth protecting the data.

If you like this article, please subscribe to our newsletter. After that you will not become one of our articles about monitoring and agencies.

Yes, I want to subscribe to your newsletter