CodeNameRaven.MonitorComponents (raven_observer_display_sdk v0.2.0)

Copy Markdown

The standard component library for monitor panels.

Monitor authors may use these components to build custom renders that fit naturally into the Raven dashboard, or ignore them entirely and write whatever HEEx they want.

The default_render/1 function is the render implementation used by any monitor that does not override render/1.

Platform features available in renders

The following are supported platform features that integrations can opt into displaying. All data is available in the assigns passed to render/1.

Silence (@config.silenced_until)

When a monitor is silenced, @config.silenced_until holds a DateTime in the future. The platform automatically suppresses warning logs and shows a "SILENCED" badge on the card, but your render can also surface this state. Use silence_badge/1 to show a compact inline indicator:

<.silence_badge silenced_until={@config.silenced_until} />

Silence is managed from the card flip side — no integration code required.

Summary

Functions

Displays the monitor's last check time in a human-readable YYYY-MM-DD HH:MM:%S UTC format.

The default panel render used when a monitor does not provide its own.

Displays the monitor's last error message in a red monospace font, if present.

Server-rendered SVG latency chart for monitor panels.

Server-rendered SVG chart for any metric stored in sample.metrics.

Renders a collect result map as a compact key-value table.

A compact badge shown when the monitor's failure warnings are silenced.

A single metric stat block — label above, value below in monospace.

A status badge showing the monitor's current health.

A compact status chip with a coloured dot and label.

Functions

check_time(assigns)

Displays the monitor's last check time in a human-readable YYYY-MM-DD HH:MM:%S UTC format.

Shows "Not yet checked" when passed nil.

Attributes

  • checked_at (:any) - Defaults to nil.

default_render(assigns)

The default panel render used when a monitor does not provide its own.

Shows status, last check time, last error, and the collect result as a key-value table when one is available.

error_message(assigns)

Displays the monitor's last error message in a red monospace font, if present.

Shows nothing when nil. Hover for full message text on truncation.

Attributes

  • message (:string) - Defaults to nil.

line_chart(assigns)

Server-rendered SVG latency chart for monitor panels.

Thin wrapper around metric_chart/1 that plots the latency_ms metric. Reads from sample.metrics["latency_ms"] when present, falling back to sample.latency_ms for older samples that pre-date the JSONB column.

Attributes

  • id (:string) (required)
  • samples (:list) (required)
  • local_id (:any) (required)

metric_chart(assigns)

Server-rendered SVG chart for any metric stored in sample.metrics.

Reads sample.metrics[metric_name] (string key, as stored by JSONB) from each sample. For metric_name: "latency_ms" falls back to sample.latency_ms when the JSONB field is absent, so HTTP's latency chart keeps working against pre-JSONB samples.

Pass y_max to pin the y-axis ceiling (e.g. 1.0 for a 0–1 ratio chart). Renders a placeholder when fewer than 2 samples have non-nil values.

Attributes

  • id (:string) (required)
  • samples (:list) (required)
  • local_id (:any) (required)
  • metric_name (:string) (required)
  • y_max (:float) - Defaults to nil.

result_table(assigns)

Renders a collect result map as a compact key-value table.

Used by default_render/1 to show raw result data for integrations that have not defined a custom panel. Keys are displayed in insertion order.

Attributes

  • result (:map) (required)

silence_badge(assigns)

A compact badge shown when the monitor's failure warnings are silenced.

Renders nothing when silenced_until is nil or in the past, so it is safe to include unconditionally in any render:

<.silence_badge silenced_until={@config.silenced_until} />

The platform already shows a card-level "SILENCED" overlay automatically. Use this component when you want the silence state visible inside your integration's own content area — for example, next to the status badge.

Attributes

  • silenced_until (:any) - Defaults to nil.

stat(assigns)

A single metric stat block — label above, value below in monospace.

Use within a flex row to display a small set of key measurements side by side (e.g. status code and latency).

Attributes

  • label (:string) (required)
  • value (:string) (required)

status_badge(assigns)

A status badge showing the monitor's current health.

Renders a coloured badge with an indicator dot and label for :up (green), :degraded (yellow), :down (red), or :unknown (grey).

Attributes

  • status (:atom) (required) - Must be one of :up, :degraded, :down, or :unknown.

status_chip(assigns)

A compact status chip with a coloured dot and label.

Suitable for panel headers and inline status indicators. Uses badge styling matched to the status severity.

Attributes

  • status (:atom) (required) - Must be one of :up, :degraded, :down, or :unknown.