NAME

Punk::Observe::Dashboard - a panel is an OQL string with a title

SYNOPSIS

use Punk::Observe::Dashboard;

my $p = Punk::Observe::Dashboard::check_panel({
    title => 'Checkout latency',
    query => 'metric http.server.duration | p95 by http.route',
    viz   => 'line', position => 2, cols => 3,
});
die $p->{error} unless $p->{ok};

DESCRIPTION

A panel is a query string, a title, a visualisation hint and a position, stored in the metadata database rather than in a segment: it is edited, and segments are immutable.

Rendering reuses the same panels the explorer uses, so a chart on a dashboard and the same chart in the explorer are the same code and cannot disagree. A panel that is slow is slow in both places, which is the correct feedback.

The query is validated by the parser that will run it

Panel input is untrusted: it arrives from a form, renders into HTML, and its query is parsed. So the query is checked at save time by the same parser that executes it.

A panel validated by a different rule than the one that runs it is a panel that can be saved and cannot be shown, and the person who finds out is a reader at three in the morning rather than the author at the form.

Order is a number and layout is a column count

There is no drag-and-drop grid, and that is a deliberate subtraction. A drag grid is several hundred lines of JavaScript, a collision algorithm, a mobile story and a persistence format, in exchange for an arrangement most people set once. A form with a number in it does the same job, works on a phone, and is accessible without any work.

FUNCTIONS

check_panel

my $p = Punk::Observe::Dashboard::check_panel(\%spec);

Takes title, query, viz, position and cols. Returns:

{ ok, code, error, viz, position, cols }

error carries the parser's own message where the query is at fault, because "that query is wrong" is not a usable form error and the parser already knows exactly what is wrong and where.

viz is one of line, area, bar, stat or table. An unknown hint becomes table, which shows the data; falling back to nothing would hide it.

cols is clamped to 1..6 and position to zero or more. A title may contain markup - the template escapes it, and refusing every angle bracket would make p95 < 200ms unsayable - but not control characters, which have no legitimate use and reach places that are not HTML.

SEE ALSO

Punk::Observe, Punk::Observe::Query, Punk::Observe::Alert