Adding health reports to microservices

duration 20 minutes

Prerequisites:

Explore how to report and check the health of a microservice with MicroProfile Health.

What you’ll learn

You will learn how to use MicroProfile Health to report the health status of microservices and take appropriate actions based on this report.

MicroProfile Health allows services to report their health, and it publishes the overall health status to a defined endpoint. A service reports UP if it is available and reports DOWN if it is unavailable. MicroProfile Health reports an individual service status at the endpoint and indicates the overall status as UP if all the services are UP. A service orchestrator can then use the health statuses to make decisions.

A service checks its own health by performing necessary self-checks and then reports its overall status by implementing the API provided by MicroProfile Health. A self-check can be a check on anything that the service needs, such as a dependency, a successful connection to an endpoint, a system property, a database connection, or the availability of required resources. MicroProfile offers checks for both liveness and readiness.

You will add liveness and readiness checks to the system and inventory services, which have been provided for you, and implement what is necessary to report health status by using MicroProfile Health.

Getting started

The fastest way to work through this guide is to clone the Git repository and use the projects that are provided inside:

git clone https://github.com/openliberty/guide-microprofile-health.git
cd guide-microprofile-health

The start directory contains the starting project that you will build upon.

The finish directory contains the finished project that you will build.

Try what you’ll build

The finish directory in the root directory of this guide contains two services that are configured to use MicroProfile Health. Feel free to give them a try before you proceed.

To try out the services, navigate to the finish directory and then run the Maven install and liberty:start-server goals to build the services and run them in Open Liberty:

cd finish
mvn install liberty:start-server

The system and inventory services can be found at the following URLs:

Visit the http://localhost:9080/health URL to see the overall health status of the application, as well as the aggregated data of the liveness and readiness checks. Two checks show the state of the system service, and the other two checks show the state of the inventory service. As you might expect, both services are in the UP state, and the overall health status of the application is in the UP state.

You can also access the /health/ready endpoint by visiting the http://localhost:9080/health/ready URL to view the data from the readiness health checks. Similarly, access the /health/live endpoint by visiting the http://localhost:9080/health/live URL to view the data from the liveness health checks.

When you are done checking out the services, stop the Open Liberty server by running the following command:

mvn liberty:stop-server

Adding health checks to microservices

Navigate to the start directory to begin.

A health report will be generated automatically for all services that enable MicroProfile Health. The mpHealth feature has already been enabled for you in the src/main/liberty/config/server.xml file.

All services must provide an implementation of the HealthCheck interface, which will be used to verify their health. MicroProfile Health offers health checks for both readiness and liveness. A readiness check allows third-party services, such as Kubernetes, to determine whether a microservice is ready to process requests. For example, a readiness check might check dependencies, such as database connections. A liveness check allows third-party services to determine whether a microservice is running. If the liveness check fails, the application can be terminated. For example, a liveness check might fail if the application runs out of memory.

server.xml

 1<server description="Sample Liberty server">
 2
 3  <featureManager>
 4    <feature>jaxrs-2.1</feature>
 5    <feature>jsonp-1.1</feature>
 6    <feature>cdi-2.0</feature>
 7    <feature>mpConfig-1.3</feature>
 8    <feature>mpRestClient-1.3</feature>
 9    <feature>mpHealth-2.0</feature>
10  </featureManager>
11
12  <httpEndpoint host="*" httpPort="${default.http.port}"
13    httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>
14
15  <webApplication location="microprofile-health.war" contextRoot="/"/>
16</server>

Adding health checks to the system service

Create the SystemReadinessCheck class.
src/main/java/io/openliberty/guides/system/SystemReadinessCheck.java

SystemReadinessCheck.java

 1package io.openliberty.guides.system;
 2
 3import javax.enterprise.context.ApplicationScoped;
 4import org.eclipse.microprofile.health.Readiness;
 5import org.eclipse.microprofile.health.HealthCheck;
 6import org.eclipse.microprofile.health.HealthCheckResponse;
 7
 8@Readiness
 9@ApplicationScoped
10public class SystemReadinessCheck implements HealthCheck {
11  @Override
12  public HealthCheckResponse call() {
13    if (!System.getProperty("wlp.server.name").equals("defaultServer")) {
14      return HealthCheckResponse.named(SystemResource.class.getSimpleName() + "Readiness")
15                                .withData("default server", "not available").down()
16                                .build();
17    }
18    return HealthCheckResponse.named(SystemResource.class.getSimpleName() + "Readiness")
19                              .withData("default server", "available").up().build();
20  }
21}

The @Readiness annotation indicates that this particular bean is a readiness health check procedure. By pairing this annotation with the ApplicationScoped context from the Contexts and Dependency Injections API, the bean is discovered automatically when the http://localhost:9080/health endpoint receives a request.

The call() method is used to return the health status of a particular service. In this case, you are simply checking if the server name is defaultServer and returning UP if it is, and DOWN otherwise. The HealthCheckResponse.named() method is used to indicate what service the health check is done for. Overall, this is a very simple implementation of the call() method. In a real development environment, you would want to orchestrate much more meaningful health checks.

Create the SystemLivenessCheck class.
src/main/java/io/openliberty/guides/system/SystemLivenessCheck.java

SystemLivenessCheck.java

 1package io.openliberty.guides.system;
 2
 3import java.lang.management.ManagementFactory;
 4import java.lang.management.MemoryMXBean;
 5
 6import javax.enterprise.context.ApplicationScoped;
 7import org.eclipse.microprofile.health.Liveness;
 8import org.eclipse.microprofile.health.HealthCheck;
 9import org.eclipse.microprofile.health.HealthCheckResponse;
10
11@Liveness
12@ApplicationScoped
13public class SystemLivenessCheck implements HealthCheck {
14
15  @Override
16  public HealthCheckResponse call() {
17    MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
18    long memUsed = memBean.getHeapMemoryUsage().getUsed();
19    long memMax = memBean.getHeapMemoryUsage().getMax();
20
21    return HealthCheckResponse.named(SystemResource.class.getSimpleName() + "Liveness")
22                              .withData("memory used", memUsed)
23                              .withData("memory max", memMax)
24                              .state(memUsed < memMax * 0.9).build();
25  }
26}

The @Liveness annotation indicates that this is a liveness health check procedure. In this case, you are checking the heap memory usage. If more than 90% of the maximum memory is being used, a status of DOWN will be returned.

Adding health checks to the inventory service

Create the InventoryReadinessCheck class.
src/main/java/io/openliberty/guides/inventory/InventoryReadinessCheck.java

InventoryReadinessCheck.java

 1package io.openliberty.guides.inventory;
 2
 3import javax.enterprise.context.ApplicationScoped;
 4import javax.inject.Inject;
 5import javax.ws.rs.client.Client;
 6import javax.ws.rs.client.ClientBuilder;
 7import javax.ws.rs.core.MediaType;
 8import javax.ws.rs.core.Response;
 9import org.eclipse.microprofile.health.Readiness;
10import org.eclipse.microprofile.health.HealthCheck;
11import org.eclipse.microprofile.health.HealthCheckResponse;
12
13@Readiness
14@ApplicationScoped
15public class InventoryReadinessCheck implements HealthCheck {
16  @Inject
17  InventoryConfig config;
18
19  public boolean isHealthy() {
20    if (config.isInMaintenance()) {
21      return false;
22    }
23    try {
24      String url = InventoryUtils.buildUrl("http", "localhost",
25          Integer.parseInt(System.getProperty("default.http.port")),
26          "/system/properties");
27      Client client = ClientBuilder.newClient();
28      Response response = client.target(url).request(MediaType.APPLICATION_JSON).get();
29      if (response.getStatus() != 200) {
30        return false;
31      }
32      return true;
33    } catch (Exception e) {
34      return false;
35    }
36  }
37
38  @Override
39  public HealthCheckResponse call() {
40    if (!isHealthy()) {
41      return HealthCheckResponse.named(InventoryResource.class.getSimpleName() + "Readiness")
42                                .withData("services", "not available").down()
43                                .build();
44    }
45    return HealthCheckResponse.named(InventoryResource.class.getSimpleName() + "Readiness")
46                              .withData("services", "available").up().build();
47  }
48
49}

This time, you are checking whether or not the service is in maintenance or if it’s down. For simplicity, the custom io_openliberty_guides_inventory_inMaintenance MicroProfile Config property defined in the resources/CustomConfigSource.json file is used to indicate whether the service is in maintenance or not. This file has already been created for you. To check if the service is down, simply make a HTTP GET request to the system service and check the status returned by the response. You make a GET request to the system service rather than the inventory service because the inventory service depends on the system service. In other words, the inventory service wouldn’t work if the system service is down. If the status is not 200, then the service is not running. Based on these two factors, the isHealthy() method returns whether or not the inventory service is healthy.

If you are curious about the injected inventoryConfig object or if you want more information on MicroProfile Config, see Configuring microservices.

Create the InventoryLivenessCheck class.
src/main/java/io/openliberty/guides/inventory/InventoryLivenessCheck.java

InventoryLivenessCheck.java

 1package io.openliberty.guides.inventory;
 2
 3import javax.enterprise.context.ApplicationScoped;
 4
 5import java.lang.management.MemoryMXBean;
 6import java.lang.management.ManagementFactory;
 7
 8import org.eclipse.microprofile.health.Liveness;
 9
10import org.eclipse.microprofile.health.HealthCheck;
11import org.eclipse.microprofile.health.HealthCheckResponse;
12
13@Liveness
14@ApplicationScoped
15public class InventoryLivenessCheck implements HealthCheck {
16
17  @Override
18  public HealthCheckResponse call() {
19      MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
20      long memUsed = memBean.getHeapMemoryUsage().getUsed();
21      long memMax = memBean.getHeapMemoryUsage().getMax();
22
23      return HealthCheckResponse.named(InventoryResource.class.getSimpleName() + "Liveness")
24                                .withData("memory used", memUsed)
25                                .withData("memory max", memMax)
26                                .state(memUsed < memMax * 0.9).build();
27  }
28}

As with the system liveness check, you are checking the heap memory usage. If more than 90% of the maximum memory is being used, a DOWN status is returned.

CustomConfigSource.json

1{
2    "config_ordinal":700,
3    "io_openliberty_guides_inventory_inMaintenance":false
4}

Building and running the application

To build the application, run the Maven install phase from the command line in the start directory:

mvn install

This command builds the application and creates a .war file in the target directory. It also configures and installs Open Liberty into the target/liberty/wlp directory.

Next, run the Maven liberty:start-server goal:

mvn liberty:start-server

This goal starts an Open Liberty server instance. Your Maven pom.xml is already configured to start the application in this server instance.

While the server is running, navigate to the http://localhost:9080/health URL to find the aggregated liveness and readiness health reports on the two services.

You can also navigate to the http://localhost:9080/health/ready URL to view the readiness health report, or the http://localhost:9080/health/live URL to view the liveness health report.

Put the inventory service in maintenance by setting the io_openliberty_guides_inventory_inMaintenance property to true in the resources/CustomConfigSource.json file. Because this configuration file is picked up dynamically, simply refresh the http://localhost:9080/health URL you will see that the state of the inventory service has changed to DOWN. The overall state of the application has also changed to DOWN as a result. Point to the http://localhost:9080/inventory/systems URL to verify that the inventory service is indeed in maintenance. Set the io_openliberty_guides_inventory_inMaintenance property back to false once you are done.

CustomConfigSource.json

1{
2    "config_ordinal":700,
3    "io_openliberty_guides_inventory_inMaintenance":false
4}

Testing health checks

You will implement several test methods, testIfServicesAreUp(), testReadiness(), testLiveness(), and testIfInventoryServiceIsDown(), to validate the health of the system and inventory services.

Create the HealthTest class.
src/test/java/it/io/openliberty/guides/health/HealthTest.java

HealthTest.java

 1package it.io.openliberty.guides.health;
 2
 3import static org.junit.Assert.assertEquals;
 4import java.util.HashMap;
 5import javax.json.JsonArray;
 6import org.junit.After;
 7import org.junit.Before;
 8import org.junit.Test;
 9
10public class HealthTest {
11
12    private JsonArray servicesStates;
13    private static HashMap<String, String> endpointData;
14
15    private String HEALTH_ENDPOINT = "/health";
16    private String READINESS_ENDPOINT = "/health/ready";
17    private String LIVENES_ENDPOINT = "/health/live";
18
19    @Before
20    public void setup() {
21        endpointData = new HashMap<String, String>();
22    }
23
24    @Test
25    public void testIfServicesAreUp() {
26        endpointData.put("SystemResourceReadiness", "UP");
27        endpointData.put("SystemResourceLiveness", "UP");
28        endpointData.put("InventoryResourceReadiness", "UP");
29        endpointData.put("InventoryResourceLiveness", "UP");
30
31        servicesStates = HealthTestUtil.connectToHealthEnpoint(200, HEALTH_ENDPOINT);
32        checkStates(endpointData, servicesStates);
33    }
34
35    @Test
36    public void testReadiness() {
37        endpointData.put("SystemResourceReadiness", "UP");
38        endpointData.put("InventoryResourceReadiness", "UP");
39
40        servicesStates = HealthTestUtil.connectToHealthEnpoint(200, READINESS_ENDPOINT);
41        checkStates(endpointData, servicesStates);
42    }
43
44    @Test
45    public void testLiveness() {
46        endpointData.put("SystemResourceLiveness", "UP");
47        endpointData.put("InventoryResourceLiveness", "UP");
48
49        servicesStates = HealthTestUtil.connectToHealthEnpoint(200, LIVENES_ENDPOINT);
50        checkStates(endpointData, servicesStates);
51    }
52
53    @Test
54    public void testIfInventoryServiceIsDown() {
55        endpointData.put("SystemResourceReadiness", "UP");
56        endpointData.put("SystemResourceLiveness", "UP");
57        endpointData.put("InventoryResourceReadiness", "UP");
58        endpointData.put("InventoryResourceLiveness", "UP");
59
60        servicesStates = HealthTestUtil.connectToHealthEnpoint(200, HEALTH_ENDPOINT);
61        checkStates(endpointData, servicesStates);
62
63        endpointData.put("InventoryResourceReadiness", "DOWN");
64        HealthTestUtil.changeInventoryProperty(HealthTestUtil.INV_MAINTENANCE_FALSE,
65                                               HealthTestUtil.INV_MAINTENANCE_TRUE);
66        servicesStates = HealthTestUtil.connectToHealthEnpoint(503, HEALTH_ENDPOINT);
67        checkStates(endpointData, servicesStates);
68   }
69
70    private void checkStates(HashMap<String, String> testData, JsonArray servStates) {
71        testData.forEach((service, expectedState) -> {
72            assertEquals("The state of " + service + " service is not matching.",
73                         expectedState,
74                         HealthTestUtil.getActualState(service, servStates));
75        });
76    }
77
78    @After
79    public void teardown() {
80        HealthTestUtil.cleanUp();
81    }
82
83}

Let’s break down the test cases:

  • The testIfServicesAreUp() test case compares the generated health report with the actual status of the services.

  • The testReadiness() test case compares the generated health report for the readiness checks with the actual status of the services.

  • The testLiveness() test case compares the generated health report for the liveness checks with the actual status of the services.

  • The testIfInventoryServiceIsDown() test case puts the inventory service in maintenance by setting the io_openliberty_guides_inventory_inMaintenance property to true and comparing the generated health report with the actual status of the services.

A few more tests have been included to verify the basic functionalitiy of the system and inventory services. They can be found under the src/test/java/it/io/openliberty/guides/inventory/InventoryEndpointTest.java and src/test/java/it/io/openliberty/guides/system/SystemEndpointTest.java files. If a test failure occurs, then you might have introduced a bug into the code. These tests will run automatically as a part of the Maven build process when you run the mvn install command. You can also run these tests separately from the build by using the mvn verify command, but first make sure that the server is stopped.

CustomConfigSource.json

1{
2    "config_ordinal":700,
3    "io_openliberty_guides_inventory_inMaintenance":false
4}

InventoryEndpointTest.java

  1package it.io.openliberty.guides.inventory;
  2
  3import static org.junit.Assert.assertEquals;
  4import static org.junit.Assert.assertTrue;
  5import javax.json.JsonObject;
  6import javax.ws.rs.client.Client;
  7import javax.ws.rs.client.ClientBuilder;
  8import javax.ws.rs.core.MediaType;
  9import javax.ws.rs.core.Response;
 10import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
 11import org.junit.After;
 12import org.junit.Before;
 13import org.junit.BeforeClass;
 14import org.junit.Test;
 15
 16public class InventoryEndpointTest {
 17
 18  private static String port;
 19  private static String baseUrl;
 20
 21  private Client client;
 22
 23  private final String SYSTEM_PROPERTIES = "system/properties";
 24  private final String INVENTORY_SYSTEMS = "inventory/systems";
 25
 26  @BeforeClass
 27  public static void oneTimeSetup() {
 28    port = System.getProperty("liberty.test.port");
 29    baseUrl = "http://localhost:" + port + "/";
 30  }
 31
 32  @Before
 33  public void setup() {
 34    client = ClientBuilder.newClient();
 35    client.register(JsrJsonpProvider.class);
 36  }
 37
 38  @After
 39  public void teardown() {
 40    client.close();
 41  }
 42
 43  @Test
 44  public void testSuite() {
 45    this.testEmptyInventory();
 46    this.testHostRegistration();
 47    this.testSystemPropertiesMatch();
 48    this.testUnknownHost();
 49  }
 50
 51  public void testEmptyInventory() {
 52    Response response = this.getResponse(baseUrl + INVENTORY_SYSTEMS);
 53    this.assertResponse(baseUrl, response);
 54
 55    JsonObject obj = response.readEntity(JsonObject.class);
 56
 57    int expected = 0;
 58    int actual = obj.getInt("total");
 59    assertEquals("The inventory should be empty on application start but it wasn't",
 60                 expected, actual);
 61
 62    response.close();
 63  }
 64
 65  public void testHostRegistration() {
 66    this.visitLocalhost();
 67
 68    Response response = this.getResponse(baseUrl + INVENTORY_SYSTEMS);
 69    this.assertResponse(baseUrl, response);
 70
 71    JsonObject obj = response.readEntity(JsonObject.class);
 72
 73    int expected = 1;
 74    int actual = obj.getInt("total");
 75    assertEquals("The inventory should have one entry for localhost", expected,
 76                 actual);
 77    boolean localhostExists = obj.getJsonArray("systems").getJsonObject(0)
 78                                 .get("hostname").toString()
 79                                 .contains("localhost");
 80    assertTrue("A host was registered, but it was not localhost",
 81               localhostExists);
 82
 83    response.close();
 84  }
 85
 86  public void testSystemPropertiesMatch() {
 87    Response invResponse = this.getResponse(baseUrl + INVENTORY_SYSTEMS);
 88    Response sysResponse = this.getResponse(baseUrl + SYSTEM_PROPERTIES);
 89
 90    this.assertResponse(baseUrl, invResponse);
 91    this.assertResponse(baseUrl, sysResponse);
 92
 93    JsonObject jsonFromInventory = (JsonObject) invResponse.readEntity(JsonObject.class)
 94                                                           .getJsonArray("systems")
 95                                                           .getJsonObject(0)
 96                                                           .get("properties");
 97
 98    JsonObject jsonFromSystem = sysResponse.readEntity(JsonObject.class);
 99
100    String osNameFromInventory = jsonFromInventory.getString("os.name");
101    String osNameFromSystem = jsonFromSystem.getString("os.name");
102    this.assertProperty("os.name", "localhost", osNameFromSystem,
103                        osNameFromInventory);
104
105    String userNameFromInventory = jsonFromInventory.getString("user.name");
106    String userNameFromSystem = jsonFromSystem.getString("user.name");
107    this.assertProperty("user.name", "localhost", userNameFromSystem,
108                        userNameFromInventory);
109
110    invResponse.close();
111    sysResponse.close();
112  }
113
114  public void testUnknownHost() {
115    Response response = this.getResponse(baseUrl + INVENTORY_SYSTEMS);
116    this.assertResponse(baseUrl, response);
117
118    Response badResponse = client.target(baseUrl + INVENTORY_SYSTEMS + "/"
119        + "badhostname").request(MediaType.APPLICATION_JSON).get();
120
121    String obj = badResponse.readEntity(String.class);
122
123    boolean isError = obj.contains("error");
124    assertTrue("badhostname is not a valid host but it didn't raise an error",
125               isError);
126
127    response.close();
128    badResponse.close();
129  }
130
131  /**
132   * <p>
133   * Returns response information from the specified URL.
134   * </p>
135   *
136   * @param url
137   *          - target URL.
138   * @return Response object with the response from the specified URL.
139   */
140  private Response getResponse(String url) {
141    return client.target(url).request().get();
142  }
143
144  /**
145   * <p>
146   * Asserts that the given URL has the correct response code of 200.
147   * </p>
148   *
149   * @param url
150   *          - target URL.
151   * @param response
152   *          - response received from the target URL.
153   */
154  private void assertResponse(String url, Response response) {
155    assertEquals("Incorrect response code from " + url, 200,
156                 response.getStatus());
157  }
158
159  /**
160   * Asserts that the specified JVM system property is equivalent in both the
161   * system and inventory services.
162   *
163   * @param propertyName
164   *          - name of the system property to check.
165   * @param hostname
166   *          - name of JVM's host.
167   * @param expected
168   *          - expected name.
169   * @param actual
170   *          - actual name.
171   */
172  private void assertProperty(String propertyName, String hostname,
173      String expected, String actual) {
174    assertEquals("JVM system property [" + propertyName + "] "
175        + "in the system service does not match the one stored in "
176        + "the inventory service for " + hostname, expected, actual);
177  }
178
179  /**
180   * Makes a simple GET request to inventory/localhost.
181   */
182  private void visitLocalhost() {
183    Response response = this.getResponse(baseUrl + SYSTEM_PROPERTIES);
184    this.assertResponse(baseUrl, response);
185    response.close();
186
187    Response targetResponse = client.target(baseUrl + INVENTORY_SYSTEMS
188        + "/localhost").request().get();
189    targetResponse.close();
190  }
191}

SystemEndpointTest.java

 1package it.io.openliberty.guides.system;
 2
 3import static org.junit.Assert.assertEquals;
 4import javax.json.JsonObject;
 5import javax.ws.rs.client.Client;
 6import javax.ws.rs.client.ClientBuilder;
 7import javax.ws.rs.client.WebTarget;
 8import javax.ws.rs.core.Response;
 9import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
10import org.junit.Test;
11
12public class SystemEndpointTest {
13
14  @Test
15  public void testGetProperties() {
16    String port = System.getProperty("liberty.test.port");
17    String url = "http://localhost:" + port + "/";
18
19    Client client = ClientBuilder.newClient();
20    client.register(JsrJsonpProvider.class);
21
22    WebTarget target = client.target(url + "system/properties");
23    Response response = target.request().get();
24
25    assertEquals("Incorrect response code from " + url, 200,
26                 response.getStatus());
27
28    JsonObject obj = response.readEntity(JsonObject.class);
29
30    assertEquals("The system property for the local and remote JVM should match",
31                 System.getProperty("os.name"), obj.getString("os.name"));
32
33    response.close();
34  }
35}

Running the tests

If the server is still running from the previous steps, stop it using the Maven liberty:stop-server goal from command line in the start directory:

mvn liberty:stop-server

Then, verify that the tests pass using the Maven verify goal:

mvn verify

It may take some time before build is complete. If the tests pass, you will see a similar output to the following:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running it.io.openliberty.guides.health.HealthTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.504 sec - in it.io.openliberty.guides.health.HealthTest
Running it.io.openliberty.guides.inventory.InventoryEndpointTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.326 sec - in it.io.openliberty.guides.inventory.InventoryEndpointTest
Running it.io.openliberty.guides.system.SystemEndpointTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 sec - in it.io.openliberty.guides.system.SystemEndpointTest

Results :

Tests run: 6, Failures: 0, Errors: 0, Skipped: 0

To see whether the tests detect a failure, manually change the configuration of io_openliberty_guides_inventory_inMaintenance from false to true in the resources/CustomConfigSource.json file. Re-run the Maven build. You will see a test failure occur because the initial status of the inventory service is DOWN.

Great work! You’re done!

You just learned how to add health checks to report the states of microservices by using MicroProfile Health in Open Liberty. Then, you wrote tests to validate the generated health report.

Feel free to try one of the related MicroProfile guides. They demonstrate additional technologies that you can learn and expand on top of what you built here.

Guide Attribution

Adding health reports to microservices by Open Liberty is licensed under CC BY-ND 4.0

Copied to clipboard
Copy code block
Copy file contents

Prerequisites:

Nice work! Where to next?

What did you think of this guide?

Extreme Dislike Dislike Like Extreme Like

What could make this guide better?

Raise an issue to share feedback

Create a pull request to contribute to this guide

Need help?

Ask a question on Stack Overflow

Like Open Liberty? Star our repo on GitHub.

Star