DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How to Introduce a New API Quickly Using Micronaut
  • Failure Handling Mechanisms in Microservices and Their Importance
  • How to Build a New API Quickly Using Spring Boot and Maven
  • Introduce a New API Quickly Using Spring Boot and Gradle

Trending

  • When Airflow Tasks Get Stuck in Queued: A Real-World Debugging Story
  • Designing AI Multi-Agent Systems in Java
  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 1
  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Health Check Response Format for HTTP APIs

Health Check Response Format for HTTP APIs

Continue a journey of getting more familiar with HTTP APIs and learn about a great initiative to standardize health checks across the industry.

By 
Nicolas Fränkel user avatar
Nicolas Fränkel
DZone Core CORE ·
Jun. 02, 23 · Analysis
Likes (6)
Comment
Save
Tweet
Share
5.5K Views

Join the DZone community and get the full member experience.

Join For Free

I'm continuing my journey of getting more familiar with HTTP APIs by reading related RFCs. This time, I read the Health Check Response Format for HTTP APIs at the suggestion of Stefano Fago. In this post, I'd like to summarize my reading.

Note that it's a draft. Moreover, it has been dormant for nearly two years and, thus, has been automatically expired. However, it's the closest to a specification on health checks and thus deserves some love.

Sample Data Visualization

Even though it's not a long read, it's a bit "dry." Fortunately, the specification offers a JSON sample. I copy-pasted it in PlantUML, and presto, it shows a visual representation of it:

Sample data visualization

Let's have a look at the proposed structure element by element.

The Root Object

At its simplest, the response is a JSON object with a mandatory status property:

JSON object with a mandatory status property

Values can be:

  • pass for healthy status: The value can also be ok (for NodeJS) and up (for Spring Boot) to account for existing health check libraries. The HTTP status code must be in the range from 2xx to 3xx.
  • warn for healthy status but with concerns with the same HTTP status range
  • fail to indicate unhealthy status: possible alternative values include error (NodeJS) and down (Spring Boot). The HTTP status code must be in the range from 4xx to 5xx.

One can add additional optional values:

Add optional values

  • version: Public version of the service
  • releaseId: Internal version of the service; for example, the version would be incremented for non-compatible change, while the releaseId could be the commit hash or a semantic version
  • serviceId: The unique identifier of the service
  • description: self-explanatory
  • notes: Array of non-structured notes
  • output: Plain error message in case of pass or warn.; the field should be left blank for pass

The links Objects

The links object consists of object pairs. Values are URIs, while keys can be URIs or common/registered ones: see RFC5988 for common values; e.g., self.

Link objects

The checks Objects

Keys of checks objects consist of two terms separated by a colon, component name, and measurement name. The latter can be either:

  • A pre-defined value: utilization, responseTime, connections, or uptime
  • A standard term from a well-known source; e.g., IANA, microformat.org, etc.
  • A URI

Values consist of one of the following keys:

  • componentId: unique id of this component
  • componentType:
    • A pre-defined value, component, datastore, or system
    • A standard term from a well-known source; e.g., IANA, microformat.org, etc.
    • A URI
  • observedValue: Any valid JSON value
  • observedUnit: Unit of measurement
  • status: As the parent object's status, but for this component, only
  • affectedEndpoints: If the component is not pass, lists all affected endpoints
  • time: Date-time in ISO8601 format of the observation
  • output: As the parent object's output, but for this component, only
  • links: See the previous section
  • Any other non-standard value

Checks objects

I tried implementing the above with Spring Boot using a custom HealthIndicator. Here's the best I could come up with:

Checks objects with Spring Boot using a custom HealthIndicator

The current structure of the JSON response needs to be (easily?) customizable. You'd need to create your endpoint. I hope the Spring Boot team provides the option to generate a compatible structure.

Conclusion

The Healthcheck IETF draft is a great initiative to standardize health checks across the industry. It would allow monitoring tools to rely on HTTP status and response body without ad-hoc configuration on each service.

Unfortunately, the draft is expired because of a lack of activity. I'd love to see it revived, though.

To Go Further:

  • "Spring Boot Actuator: Health"
API Data visualization Spring Boot Performance indicator

Published at DZone with permission of Nicolas Fränkel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Introduce a New API Quickly Using Micronaut
  • Failure Handling Mechanisms in Microservices and Their Importance
  • How to Build a New API Quickly Using Spring Boot and Maven
  • Introduce a New API Quickly Using Spring Boot and Gradle

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!