# Health check service

The Sitefinity  Health Check service enables you to assess the core components of your Sitefinity CMS application. Once you enable the service, you can run background checks on whether the site is operational, responsive, and set up properly. The default checks are:

* System Bootstrap - Provides information whether Sitefinity CMS system is up and running.
* Startup - Provides information when Sitefinity startup is successfully completed.

You can configure additional checks out of the box, which you run on demand to make sure other key aspects of the web application are properly functioning:

* Database access
* Load balancing nodes communication
* Internet connectivity
* Redis check
* Search service availability
* License validity

## Set up the Health check service

To set up Health check service on a Sitefinity CMS site, you must first specify the name of the endpoint where you want to have the health check resolved. Follow these steps:

1. Edit the `web.config` of the Sitefinity site, for which you want health checks to run.
2. Add a new entry in the `appSettings `section with:
   * **key -**  sf:HealthCheckApiEndpoint
   * **value**  \*-\*specify on what endpoint you would like to access the health check service

For example:  `<add key="sf:HealthCheckApiEndpoint" value="restapi/health"/>`
3\. Save the edited file, and then restart the site.

Next you must enable and configure the health check service by following these steps:

1. Select *Administration » Settings*, and then choose *Advanced*.
2. Expand *System* and select *Health check service*.
3. Select the *Enable Health check service* checkbox.
4. Optionally, select the *Enable logging of health check tasks* checkbox.  Every time you demand the HTTP request URL, all information is stored in the `healthcheck.log` file, located in the` ~/App_Data/Sitefinity/Logs` folder, along with all responses, messages, and timestamps.
5. Optionally, select the *Enable HTTP status codes* checkbox. By default, the health check service returns a standard status code `200.` Once you enable the *HTTP status codes* option , you get status code `500 `for any failed heath check and status code `200` for heath checks that pass successfully.
6. Optionally, enter an *Аuthentication key*. This makes the health check service endpoint accessible only if you pass an HTTP header to the request with key `"authKey"` and value - the specified authentication key value.
7. Click *Save Changes* to record your entries.

## Configure health checks

Once enabled, the health check service is available at the configured endpoint, for example \*[https://www.yourwebsite.com/restapi/health\*. By](https://www.yourwebsite.com/restapi/health*.%C2%A0By) default, the health check service will return a response with information about the status of the two default checks:

* **SystemIsBootstrapped**  Provides information on whether Sitefinity CMS system is up and running.
* **StartUpFinished**  Provides information when Sitefinity startup is successfully completed.

For example, this is the default health check service response when both checks pass successfully:

> info **NOTE**: Health check results are cached for 10 seconds. If you run the check again within the 10 seconds, you get the same response.

Sitefinity CMS enables you to check other elements of the system in addition to Bootstrap and Startup operations. To include other checks in the health check service, follow these steps:

1. In your Sitefinity CMS administrative backend, navigate to *Administration*  \* » Settings »\* *Advanced*.
2. Expand *System*  and select *Health check service » Health checks*
3. Click on Create new
4. Fill in the following information:
   1. **Enable health check**   - select the checkbox to make sure the health check is included
   2. **Health check name**   - type in a friendly name for the health check you want to add
   3. **Critical**   - select this checkbox if you want this check to affect the end result when calling the health check service. By default, only the *SystemIsBootstrapped* and *StartUpFinished* health checks are critical. When a health check is not critical, it can fail but the end result of calling the health check will still be successful, if the critical health checks have passed successfully.
   4. **Groups**   - you can mark different health checks with the same group. This approach is similar to classifying them. When calling the health check service, you can optionally pass a group name, and have only the checks that are marked with this group execute
   5. **Type**  - configure the specific CLR type matching the health check you want to add. The health check types you can add out of the box are:  <table><colgroup><col><col><col><col></colgroup>

<tbody><tr><td>

<strong>Health check</strong>

</td><td>

<strong>Description</strong>

</td><td>

<strong>Type</strong>

</td></tr><tr><td>

System Bootstrap

</td><td>

Default check.<br>Provides information whether Sitefinity CMS system is up and running.

</td><td>

<code>Telerik.Sitefinity.Health.SystemIsBootstrapped</code>

</td></tr><tr><td>

Start Up

</td><td>

Default check.<br>Provides information when Sitefinity CMS startup is successfully completed.

</td><td>

<code>Telerik.Sitefinity.Health.StartUpFinished</code>

</td></tr><tr><td>

Database access

</td><td>

Provides information whether Sitefinity CMS database is accessible.

</td><td>

<code>Telerik.Sitefinity.Health.DatabaseCheck</code>

</td></tr><tr><td>

NLB communication

</td><td>

Provides information whether communication between nodes is working.

</td><td>

<code>Telerik.Sitefinity.Health.NlbCheck</code>

</td></tr><tr><td>

Internet connectivity

</td><td>

Provides information if internet connectivity to a given URL (provided as a parameter when calling the health  check service).

</td><td>

<code>Telerik.Sitefinity.Health.InternetConnectivityCheck</code>

</td></tr><tr><td>

Redis check

</td><td>

Provides information if a load balanced environment with Redis is working.

</td><td>

<code>Telerik.Sitefinity.Health.RedisCheck</code>

</td></tr><tr><td>

Search service check

</td><td>

Provides information whether the search service is working (valid for external search services only).

</td><td>

<code>Telerik.Sitefinity.Search.Impl.HealthChecks.SearchServiceConnectivityCheck</code>

</td></tr><tr><td>

License check

</td><td>

Provides information whether your Sitefinity license is valid.<br>

</td><td>

<code>Telerik.Sitefinity.Health.LicenseCheck</code><br>

</td></tr></tbody></table>
5. Click *Save changes*

### Configure parameters for health checks

Some health checks require that you configure a parameter as part of their setup process. For example, when you configure an *Internet connectivity* health check you also need to provide a URL address the health check to ping in order to verify successful internet connectivity.

> important **IMPORTANT**: You configure parameters **only** for the checks that require them. In addition, you only use the **required** parameter and key. The table below captures the available parameters for the different out of the box health checks:

<table><colgroup><col><col><col><col></colgroup>
<tbody><tr><td>

<strong>Health check </strong>

</td><td>

<strong>Type </strong>

</td><td>

<strong>Required parameter</strong> 

</td></tr><tr><td>

Internet connectivity

</td><td>

`Telerik.Sitefinity.Health.InternetConnectivityCheck` 

</td><td>

  <p>Key:<span class="UserInput" style="font-weight:bold;"> url</span></p><p>Value:</p><p>Any existing URL, for example:</p><p>[**http://www.bing.com**](http://www.bing.com/)</p>&nbsp;or [**http://www.google.com**](http://www.google.com/)&nbsp;
</td></tr><tr><td>

Redis check 

</td><td>

`Telerik.Sitefinity.Health.RedisCheck` 

</td><td>

 

<p>Key: <strong class="UserInput">requestTimeout</strong></p><p>Value:</p><p>Any number, representing a time period in milliseconds.</p><p>Default value is <strong class="UserInput">1000</strong></p>
  > info **NOTE**: If you do not enter any value, the check considers the **requestTimeout** value to be the default one.

</td></tr></tbody></table>

To configure parameters for health checks, follow these steps:

1. Expand the node for your newly created health check.
2. Click *Parameters*.
3. Click the *Create new* button.
4. Enter the key of the parameter, for example, *url*.  For details, refer to the table above.
5. Enter the parameter value, for this example, [http://www.google.com](http://www.google.com/).
6. Save your changes.

After you add health checks and their parameters, you must restart the site to enable the updated Health check service.

## Run health checks

You run health checks by making an HTTP request to the health check endpoint. The response returns the status of all enabled health checks.To run a general health check, including all additional checks you configured, make an HTTP request to the health check service endpoint:

`http://server:port/<path_value>`

where:

* `server:port`  is the host and port where the site you want check is running, for example, `mysite.com`
* `<path_value>`   defines the path where the health check service is accessible. You can replace it with any value, for example: `http://mysite.com/restapi/health`

## Use health check groups

You can group checks and associate them with a group name, acting as a tag to better filter the set of results you require. Thus, by running checks by a query parameter that interprets arguments in the query string, you define what checks to run.

You run group health checks by making an HTTP request with the following syntax:

`server:port/<path_value>?type=groupname,groupname,…`

Where `?type=groupname,groupname,…` is the list of groups that you defined on individual health checks. When these parameters are omitted, all enabled checks will run.

For example, group the health checks for connectivity to **Google** and **bing** under the group name *Internet*. Next, run the health check with the following HTTP request: `mysite.com/restapi/health?type=Internet`

## Interpret Health Check results

After you enable the health check service, you can run a health check on the running site at any time.

To run a health check, simply make an HTTP request:\
`server:port/<path_value>?type=groupname,groupname,…`

where:

* `server:port`  is the host and port where the site you want check is running, for example, mysite.com
* `<path_value>`   defines the path where the health check service is accessible. You can replace it with any value, for example, `http://mysite.com/restapi/health`
* `?type=groupname,groupname,…`  is the list of groups that you defined on individual health checks. When these parameters are omitted, all enabled checks will run.

The following example demonstrates how overall health check results are affected by the groups and configurations you set.

You configure the following:

<table><colgroup><col><col><col></colgroup>
<tbody><tr><td>

<strong>Health check</strong>

</td><td>

<strong>Group</strong>

</td><td>

<strong>Critical</strong>

</td></tr><tr><td>

Internet connectivity check <strong>Google</strong>

</td><td>

`internet`

</td><td>

Yes 

</td></tr><tr><td>

Internet connectivity check <strong>bing</strong>

</td><td>

`internet`

</td><td>

Yes 

</td></tr><tr><td>

Redis check

</td><td>

`redis`

</td><td>

Yes

</td></tr></tbody></table>

You run the following HTTP request:

`mysite.com/restapi/health?type=internet, redis`

You get the following health check result:

[![With internet and redis groups](https://www.progress.com/documentation/sitefinity-cms/assets/f573f3fea362b0494cd991535a0df170/with-internet-and-redis-groups.png "With internet and redis groups")](https://www.progress.com/documentation/sitefinity-cms/assets/f573f3fea362b0494cd991535a0df170/with-internet-and-redis-groups.png)

In the example above, the overall result of the health check is `false`. The reasons are:

Redis check is critical. Therefore, since Redis check is unsuccessful, the overall result is `false`.

Network load balancing is not active, so the Redis test failed. By disabling the Redis check and restarting the site, that check is skipped and the overall health check result is **true**.
