Artifactory Health Check
The Health check is a rapid and standardized way to validate the status of an API service. It is an API Monitoring method that checks API and alerts when it notices something is amiss. The API health check endpoint must check anything that interrupts the API from serving incoming requests.
Artifactory provides several REST API's to perform health Check. That can be configured in a Load Balancer or any other similar services to automate the health check. The three REST endpoints provided by Artifactory are as follows
- Readiness Probe
- Liveness Probe
Readiness Probe
The Readiness probe signals readiness to process the incoming API requests.While it responds successfully, it means that API service is “ready” to receive requests.
The readiness probe replaces the system/ping and gets a simple status response about the state of the Artifactory API services using the new Kubernetes style readiness probe. However system/ping will remain as the legacy artifactory system is still dependent on it .The probe is used to measure the system latency, also it provides customers with a significant metric to monitor and alert according to their own requirements standard.
For example :
To get a readiness probe response about the state of Artifactory use the following command.
curl -XGET http://localhost:8081/artifactory/api/v1/system/readiness -H 'Content-Type: text/plain'
{"code" : "OK"}
Liveness Probe
The Liveness probe says that the component has “liveness”.It means that the component will eventually be able to produce a result.
For example :
To get a liveness probe response about the state of Artifactory use the following command.
curl -XGET http://localhost:8081/artifactory/api/v1/system/liveness -H 'Content-Type: text/plain'
{"code" : "OK"}
Sample Response for Health Check on Artifactory:
For example :
To get an API health response for the different API services that artifactory uses type in the below command. It produces a response by content type in application/json format.
curl -XGET http://localhost:8046/router/api/v1/topology/health -H 'Content-Type: application/json'
As we can see in the above output snippet the , The state property of the json response shows the state of the API services which the artifactory uses . Here the state shows HEALTHY, which means the respective API service is up and running.
Service ID’s returned in the above health check response are identifiers for JFrog systems. Each microservice has their own Service ID. Access Federation and other E+ systems rely on these IDs to replicate things. Since Artifactory 7.X, different microservices have their own serviceID.
Artifactory Service ID example:
jfrt@01d8m3sm6q0rj21rqj47331ayc
Access Service ID example:
jfac@01cbdrkbfvv5t20g5ke9rk0339
A sample use case for unsuccessful scenario:
All of the artifactory services like Access, JFConnect, Event, Frontend, Integration, Metadata
Observability depends on an artifactory license. If the license is not configured all the services will be impacted and the services cannot process incoming requests.
In order to achieve the use case I removed the artifactory.cluster.license file in both HA instances.
Readiness Probe Response:
Liveness Probe Response:
UI Response:
Terminal Response :
As we can see in the below output snippet, The state property of the json response shows the state of the API services that the artifactory uses. Here the state shows UNHEALTHY, which means the respective API service is not up and running, it could be due to different issues. In our use case, since all the API services depend on the artifactory license, the services were down as we removed the license.
The Artifactory health check commands will be accessible externally using DNS. Instead of using localhost, we will utilize the DNS to retrieve the response.
For example:
curl -XGET http://<ARTIFACTORY-DNS>/artifactory/api/v1/system/readiness -H 'Content-Type: text/plain'
OK
For information on Xray health check please refer to this article