title: Generic JSON API: status and response time of an endpoint
agents: json_api
catalog: app
license: GPLv2
distribution: https://github.com/otAAAh/checkmk-json-agent
description:
 This check works together with the {Generic JSON API} special agent and needs
 no field configuration at all: every endpoint in the rule gets one service
 reporting the {request} rather than the data in the response.

 While it succeeds, the service is {OK} and reports the HTTP status code, the
 response time and the response size; the URL (and, when a redirect moved the
 request, the final URL) are shown in the details. The response time is measured
 from sending the request until the whole response body has been read, and is
 exposed as a metric; it is only checked against levels once you configure them.

 For an {HTTPS} endpoint with certificate verification enabled, the TLS
 certificate's remaining validity is also reported, in days, as a metric with
 optional lower levels. It is read from the connection the agent already makes,
 so it costs no extra request and needs no second check against the same URL.
 When it cannot be read - plain HTTP, verification turned off, or a connection
 reused from the pool - nothing about the certificate is reported; that is
 {absent}, not {expired}, and never causes an alert.

 When the request fails outright - connection refused, a TLS error, a timeout,
 an HTTP status that the rule does not accept, or a response that is not JSON -
 the service is {CRIT} and reports the error. That state is configurable, so an
 endpoint that is allowed to be unavailable can be a mere {WARN}.

 When the endpoint has a cache TTL configured and its last response is still
 young enough, the agent serves that instead of making a request. The service
 then reports {from cache} with the body's age and records no response time,
 because no request was made; a failing request is never answered from an
 expired cache, so a real outage still shows up.

 Configure the levels for the response time, the levels for the certificate's
 remaining validity, and the state for an unreachable endpoint with the check
 parameters rule {Generic JSON API endpoint} (Setup >
 Service monitoring rules > Applications). The endpoint's connection settings -
 and its optional name - live in the {Generic JSON API} special agent rule.

 If you do not want these services, remove them the standard way with a
 "Disabled services" rule.

item:
 The name configured for the endpoint, or its URL when it has no name. The URL
 is used without its query string, so a credential passed as a query parameter
 stays out of the service description; the full URL is in the service details.

discovery:
 One service is created for each endpoint configured in the special agent rule.
