Botica.Dashboard (Botica v2.2.0)

Copy Markdown View Source

Minimal HTTP dashboard for botica check results.

Serves a tiny plain-HTML page (no external deps) with the last state of every check, plus a Prometheus /metrics endpoint reusing Botica.Report.

The dashboard is a zero-dependency :gen_tcp listener so it works in any OTP release without adding a web framework.

Usage

The dashboard is not started by default (botica is a library, not a service). Start it explicitly:

Botica.Dashboard.start_link(port: 8080, provider: fn -> results end)

The :provider fun returns the list of check results to display; it defaults to the last scheduler history or an empty list.

Routes

  • GET / — HTML status page
  • GET /health — 200 OK / 503 with ok|degraded|fail body
  • GET /metrics — Prometheus text format via Botica.Report

Summary

Functions

Returns a specification to start this module under a supervisor.

Current listen port (useful in tests to learn the ephemeral port).

Starts the dashboard HTTP server.

Stops the dashboard.

Types

result_provider()

@type result_provider() :: (-> [map()])

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

port(name \\ __MODULE__)

@spec port(atom() | pid()) :: :inet.port_number()

Current listen port (useful in tests to learn the ephemeral port).

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the dashboard HTTP server.

Options

  • :port — listen port (default 8080)
  • :provider — zero-arity fun returning [result_map] (default: empty)
  • :interface — bind address (default {127, 0, 0, 1})
  • :name — registered name (default __MODULE__; pass a unique name to run several dashboards in the same VM, e.g. in tests)

stop(name \\ __MODULE__)

@spec stop(atom() | pid()) :: :ok

Stops the dashboard.

Pass :name when the dashboard was started with a custom name.