Network Working Group | I. Nadareishvili |
Internet-Draft | January 17, 2018 |
Intended status: Informational | |
Expires: July 21, 2018 |
Health Check Response Format for HTTP APIs
draft-inadarei-api-health-check-00
This document proposes a service health check response format for HTTP APIs.
RFC EDITOR: please remove this section before publication
The issues list for this draft can be found at https://github.com/inadarei/rfc-healthcheck/issues.
The most recent draft is at https://inadarei.github.io/rfc-healthcheck/.
Recent changes are listed at https://github.com/inadarei/rfc-healthcheck/commits/master.
See also the draft’s current status in the IETF datatracker, at https://datatracker.ietf.org/doc/draft-inadarei-api-health-check/.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 21, 2018.
Copyright (c) 2018 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
The vast majority of modern APIs driving data to web and mobile applications use HTTP [RFC7230] as their protocol. The health and uptime of these APIs determine availability of the applications themselves. In distributed systems built with a number of APIs, understanding the health status of the APIs and making corresponding decisions, for failover or circuit-breaking, are essential for providing highly available solutions.
There exists a wide variety of operational software that relies on the ability to read health check response of APIs. There is currently no standard for the health check output response, however, so most applications either rely on the basic level of information included in HTTP status codes [RFC7231] or use task-specific formats.
Usage of task-specific or application-specific rformats creates significant challenges, disallowing any meaningful interoprerability across different implementations and between different tooling.
Standardizing a format for health checks can provide any of a number of benefits, including:
This document defines a “health check” format using the JSON format [RFC8259] for APIs to use as a standard point for the health information they offer. Having a well-defined format for this purpose promotes good practice and tooling.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC2119].
An API Health Response Format (or, interchangeably, “health check response”) uses the format described in JSON [RFC8259] and has the media type “application/vnd.health+json”.
Its content consists of a single mandatory root field (“status”) and several optional fields:
For “pass” and “warn” statuses HTTP response code in the 2xx - 3xx range MUST be used. for “fail” status HTTP response code in the 4xx - 5xx range MUST be used. In case of the “warn” status, additional information SHOULD be provided, utilizing optional fields of the response.
For example:
GET /health HTTP/1.1 Host: example.org Accept: application/vnd.health+json HTTP/1.1 200 OK Content-Type: application/vnd.health+json Cache-Control: max-age=3600 Connection: close { "status": "pass", "version" : "1", "release_id" : "1.2.2", "uptime": "1209600.245", "connections" : 25, "notes": [""], "output": "", "details": [ { "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentName": "Cassandra", "componentType" : "datastore", "metricName" : "responseTime", "metricValue": 250, "metricUnit" : "milliseconds", "status": "pass", "time" : "2018-01-17T03:36:48Z", "output": "" }, { "componentId": "dfd6cf2b-1b6e-4412-a0b8-f6f7797a60d2", "componentName": "Cassandra", "type" : "datastore", "metricName" : "connections", "metricValue": 75, "status": "warn", "time" : "2018-01-17T03:36:48Z", "output": "" }, { "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227", "componentName": "cpu", "type" : "system", "metricName" : "utilization", "metricValue": 85, "metricUnit" : "percent", "status": "warn", "time" : "2018-01-17T03:36:48Z", "output": "" }, { "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227", "componentName": "cpu", "type" : "system", "metricName" : "utilization", "metricValue": 85, "metricUnit" : "percent", "status": "warn", "time" : "2018-01-17T03:36:48Z", "output": "" }, { "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227", "componentName": "memory", "type" : "system", "node" : 1, "metricName" : "utilization", "metricValue": 8.5, "metricUnit" : "gb", "status": "warn", "time" : "2018-01-17T03:36:48Z", "output": "" }, { "componentId": "6fd416e0-8920-410f-9c7b-c479000f7227", "componentName": "memory", "node" : 2, "type" : "system", "metricName" : "utilization", "metricValue": 5500, "metricUnit" : "mb", "status": "pass", "time" : "2018-01-17T03:36:48Z", "output": "" } ], "links": [ {"rel": "about", "uri": "http://api.example.com/about/authz"}, { "rel": "http://api.example.com/rel/thresholds", "uri": "http://api.example.com/about/authz/thresholds" } ], "serviceID": "f03e522f-1f44-4062-9b55-9587f91c9c41", "description": "health of authz service" }
Following fields MAY appear and rules SHOULD be used for the details objects of the reponse.
Clients need to exercise care when reporting health information. Malicious actors could use this information for orchestrating attacks. In some cases the health check endpoints may need to be authenticated and institute role-based access control.
TODO: application/vnd.health+json is being submitted for registration per [RFC6838]
[RFC2119] | Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997. |
[RFC3986] | Berners-Lee, T., Fielding, R. and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005. |
[RFC5988] | Nottingham, M., "Web Linking", RFC 5988, DOI 10.17487/RFC5988, October 2010. |
[RFC7234] | Fielding, R., Nottingham, M. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Caching", RFC 7234, DOI 10.17487/RFC7234, June 2014. |
[RFC8259] | Bray, T., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017. |
[RFC6838] | Freed, N., Klensin, J. and T. Hansen, "Media Type Specifications and Registration Procedures", BCP 13, RFC 6838, DOI 10.17487/RFC6838, January 2013. |
[RFC7230] | Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014. |
[RFC7231] | Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI 10.17487/RFC7231, June 2014. |
Thanks to Mike Amundsen, Erik Wilde, Justin Bachorik and Randall Randall for their suggestions and feedback. And to Mark Nottingham for blueprint for authoring RFCs easily.
When making an health check endpoint available, there are a few things to keep in mind:
Clients might use health check responses in a variety of ways.
Note that the health check response is a “living” document; links from the health check response MUST NOT be assumed to be valid beyond the freshness lifetime of the health check response, as per HTTP’s caching model [RFC7234].
As a result, clients ought to cache the health check response (as per [RFC7234]), to avoid fetching it before every interaction (which would otherwise be required).
Likewise, a client encountering a 404 (Not Found) on a link is encouraged to obtain a fresh copy of the health check response, to assure that it is up-to-date.