The Solr Ping request handler is an endpoint for load balancers or service warning systems can use to check the "up" status of a Solr server or container.

Config

Configure the request handler by adding the PingRequestHandler class to bottom of solrconfig.xml

<requestHandler name="/admin/ping" class="solr.PingRequestHandler">
	<lst name="invariants">
		<!-- specify the handler to delegate to -->
		<str name="qt">/search</str>
        <str name="q">some test query</str>
	</lst>
	<lst name="defaults">
		<str name="echoParams">all</str>
		<str name="df">article</str>
	</lst>
	<!-- relative paths are resolved against the data dir -->
	<str name="healthcheckFile">server-enabled.txt</str>
</requestHandler>

Invariants
These specify the handler.

Defaults
These ensure a request should be executed.

HealthcheckFile
If this file does not exist, the handler will throw an HTTP error even though the server is working fine and the query would have succeeded. See one way to create it below.

Example

On the Core Selector page of the Solr Admin UI, the Ping option will display the length of time a request took in milliseconds. If it shows a message like "Ping request handler is not configured with a healthcheck file," then generate the Healthcheck file automatically by appending the string admin/ping?action=enable to the end of the collection shard's URL (or shard replica) in another browser tab and hitting enter, for example:

http://host:port/solr/admin/ping?action=enable

This should return "QTime=0", and the Ping Healthcheck section on the Solr Admin UI Core Selector page will now a green checkmark in the Healthcheck Status section.

ping_requesthandler

This shows how any external system, or the PingRequestHandler itself, can be used to create/delete the health check file by specifying an “action” param in a request:

  • http://host:port/solr/admin/ping?action=enable – creates the health check file if it does not already exist.
  • http://host:port/solr/admin/ping?action=disable – deletes the health check file if it exists.
  • http://host:port/solr/admin/ping?action=status – returns a status code indicating if the healthcheck file exists (“enabled”) or not (“disabled”).

Configure Client

The Ping handler returns a simple "OK" or HTTP Error code response to requests. To monitor server status, configure requests that poll the PingRequestHandler and monitor the responses.

Load balancers can use the healthcheck file to determine whether the server should be “removed from rotation” for maintenance or upgrades.

Resources

https://lucene.apache.org/solr/4_8_0/solr-core/org/apache/solr/handler/PingRequestHandler.html

Example blog post that could be better - https://blog.thedigitalgroup.com/understanding-and-configuring-solrs-pingrequesthandler

Implicit RequestHandlers - https://lucene.apache.org/solr/guide/6_6/implicit-requesthandlers.html#implicit-requesthandlers

Server Health Tests - https://www.cloudera.com/documentation/enterprise/5-2-x/topics/cm_ht_solr_server.html

Request Parameters API - https://lucene.apache.org/solr/guide/6_6/request-parameters-api.html#request-parameters-api