There are many mechanisms for monitoring the health of Sitecore, but Heartbeat.aspx is the simplest. It is easy to monitor with third party tools and requires no knowledge of technological underpinnings. With the release of Sitecore 9, however, things have gotten a bit more complicated. Heartbeat checks every database, even unused ones. this can lead to false negatives and problems monitoring site health in different environments. Fortunately, there is a solution!
Sitecore allows you to specify a list of excluded connections, so you can check only the required databases for a given environment. However, Sitecore does not provide a simple tool to get the status of every connection. Enter EKG: A tool that checks every connection, shows you the status of each database, and provides a pre-formatted Sitecore.Services.Heartbeat.ExcludeConnection config section to paste into a patch file in your App_Config.
First, lets look at the important parts of the code. This is implemented as a legacy Forms page but should be easy enough to follow if you have only had exposure to MVC.
This code iterates through the available connection strings, checks each one, and returns a database status report:
In addition, it returns a formatted XML section that can be placed into a patch file in your App_Config folder to exclude the failing databases from the Heartbeat check:
There are a couple of caveats:
- This will need to be set for each environment.
- You need some understanding of what each database does, and whether it is supposed to be excluded.
- You will need to remember to change the Exclude Connection config if you make any changes to your environment. Failing to do so will give you false positives.
You can download the EKG.aspx source code here. It should be placed in the /sitecore/service folder.