Dowser.Elasticsearch.HealthReport (Dowser.Elasticsearch v0.4.1)

View Source

The Elasticsearch health report API — the endpoint tagged health_report in the Elasticsearch OpenAPI specification.

Built on Dowser.Client. The endpoint requires no attribute: the feature to report on is the :feature option, and the signature is opts-only.

This is the cluster health report — a list of indicators (master_is_stable, shards_availability, disk, …), each with its own green/unknown/yellow/red status, an explanation of that status, the impacts of a non-green one and, where Elasticsearch can tell, the diagnosis and the steps to fix it. The cluster's own status is the worst indicator's. For the older, terser status — GET /_cluster/health — see the cluster APIs, and for it as one text row, Dowser.Elasticsearch.Cat.health/1.

All options are forwarded to Dowser.Client.request/4, e.g. :context, :params (query-string parameters), :format, :keys and :http_opts (including :headers).

On a 2xx response the function returns {:ok, body} with the decoded response body. A non-2xx response returns {:error, %Dowser.Elasticsearch.Error{}}; a transport, encoding or decoding failure returns {:error, exception} from Dowser.Client. The bang variant returns the body directly or raises the error exception.

Summary

Types

One indicator name (a one-element list is accepted too).

Functions

Returns the health report of the cluster — GET /_health_report (Health API).

Like health_report/1, but returns the body directly or raises the error exception.

Types

body()

@type body() :: term()

feature()

@type feature() :: String.t() | atom() | [String.t() | atom()]

One indicator name (a one-element list is accepted too).

result()

@type result() :: {:ok, body()} | {:error, Exception.t()}

Functions

health_report(opts \\ [])

@spec health_report(keyword()) :: result()

Returns the health report of the cluster — GET /_health_report (Health API).

{:ok, report} = Dowser.Elasticsearch.HealthReport.health_report()
report["status"]
#=> "green"
Map.keys(report["indicators"])
#=> ["master_is_stable", "repository_integrity", "disk", "shards_availability", ...]

Options

  • :feature — restrict the report to one indicator, as named by a full report ("disk", "master_is_stable", …); absent for all of them. Elasticsearch resolves the path segment as a single indicator name and answers a comma-joined list with a 404, so a list of several is refused here: {:error, %ArgumentError{}} — raised by health_report!/1 — rather than a request the cluster rejects. Call the function once per indicator instead. A one-element list is accepted.
  • :params — the endpoint's query parameters: timeout, verbose (true by default; false drops the details) and size (the maximum number of affected resources reported, 1000 by default).

health_report!(opts \\ [])

@spec health_report!(keyword()) :: body()

Like health_report/1, but returns the body directly or raises the error exception.