Help us shape the future of Go! Take the 2026 Go Developer Survey

dashspec

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dashspec is forge's renderer-neutral dashboard vocabulary (forge.dashboards/v1) and its validator: the types a dashboard file is written in, and ParseDashboard, which judges one with every problem located by line, column and path.

forge generates dashboards in this vocabulary (deploy/observability/), a release bundle carries them, and the Reliant control plane saves and promotes them. Every one of those reads the same rules from here, so a dashboard forge writes is one every reader accepts, and a new panel kind reaches all of them with one forge pin bump instead of one hand-kept copy per reader.

Fields are OpenTelemetry names keyed by signal (see CheckField); nothing here names a ClickHouse column, a HyperDX field or a chart library.

Index

Constants

View Source
const (
	PostgresDrawAuto   = "auto"
	PostgresDrawLine   = "line"
	PostgresDrawNumber = "number"
	PostgresDrawTable  = "table"
	PostgresDrawBar    = "bar"
)

The ways a PostgresQuery's result is drawn.

View Source
const (
	// PostgresParamFrom is $1, the start of the dashboard's time range,
	// inclusive: a timestamptz.
	PostgresParamFrom = 1
	// PostgresParamTo is $2, the end of the range, exclusive: a timestamptz.
	PostgresParamTo = 2
	// PostgresParamStep is $3, a bucket width in seconds suited to the range,
	// for a time series: an int4.
	PostgresParamStep = 3
	// PostgresParamCount is how many parameters there are.
	PostgresParamCount = 3
)

The parameters a PostgresQuery's statement may use, as their positions: $1, $2 and $3. The values come from the dashboard's scope and are bound, never spliced. A statement need not reference any of them; one that references $2 must reference $1 too (Postgres cannot type a skipped one), and none may reference $4.

SELECT date_trunc('hour', created_at) AS t, count(*) AS signups
FROM users
WHERE created_at >= $1 AND created_at < $2
GROUP BY t ORDER BY t
View Source
const (
	// MaxPostgresDatabaseLen is the longest Database name.
	MaxPostgresDatabaseLen = 63
	// MaxPostgresColumnLen is the longest result column name (Postgres' own
	// identifier limit).
	MaxPostgresColumnLen = 63
)

Bounds of a PostgresQuery.

View Source
const (
	// MaxLimit is the most rows a panel may keep.
	MaxLimit = 200
	// DefaultBarLimit is how many bar groups a bar panel with no Limit draws.
	DefaultBarLimit = 10
)

Row limits of a table or bar panel (Panel.Limit).

View Source
const (
	DefaultFunnelWindow = "1h"
	DefaultFunnelBy     = FunnelBySession
)

Funnel defaults, applied where a panel leaves a field empty.

View Source
const (
	FieldService = "service.name"
	FieldEnv     = "deployment.environment.name"
)

Semantic field names. A field is one of:

service.name, deployment.environment.name        (every signal)
span.name, span.kind, span.status,
span.status_message, span.duration               (traces)
span.attr.<key>                                  (traces)
log.severity, log.body, log.attr.<key>           (logs)
metric.attr.<key>                                (metrics)
resource.attr.<key>                              (every signal)

span.kind is "server" or "client"; span.status and log.severity compare against "error". span.duration is milliseconds.

View Source
const (
	// SQLParamFrom is the start of the dashboard's time range, inclusive:
	// {from:DateTime64(9)}.
	SQLParamFrom = "from"
	// SQLParamTo is the end of the dashboard's time range, exclusive:
	// {to:DateTime64(9)}.
	SQLParamTo = "to"
	// SQLParamStep is a bucket width in seconds suited to the range, for a
	// time series: {step:UInt32}.
	SQLParamStep = "step"
	// SQLParamEnvIDs are the reliant.env.id values in scope; empty means every
	// environment: {env_ids:Array(String)}.
	SQLParamEnvIDs = "env_ids"
	// SQLParamEnvs are the deployment.environment.name values in scope, in the
	// order of SQLParamEnvIDs: {envs:Array(String)}.
	SQLParamEnvs = "envs"
	// SQLParamServices are the service.name values in scope; empty means
	// every service: {services:Array(String)}.
	SQLParamServices = "services"
)

The query parameters a KindSQL panel's statement may use. They are ClickHouse's native parameters, written {name:Type} in the statement and bound by the server from the dashboard's scope: nothing a viewer picks is ever spliced into the SQL. A statement need not use any of them, and may use each any number of times.

SELECT toStartOfInterval(Timestamp, toIntervalSecond({step:UInt32})) AS t,
       count() AS requests
FROM otel_traces
WHERE Timestamp >= {from:DateTime64(9)} AND Timestamp < {to:DateTime64(9)}
  AND (empty({services:Array(String)}) OR has({services:Array(String)}, ServiceName))
GROUP BY t ORDER BY t
View Source
const GridColumns = 24

GridColumns is the width of a dashboard's grid: a panel's Width is in columns out of it.

View Source
const MaxDefaultRange = 30 * 24 * time.Hour

MaxDefaultRange bounds Dashboard.DefaultRange: the longest range a dashboard's panels may be read over.

View Source
const MaxFormulaLen = 256

MaxFormulaLen bounds a panel's Formula.

View Source
const MaxMarkdownBytes = 10_000

MaxMarkdownBytes bounds a KindText panel's Markdown.

View Source
const MaxReplaces = 32

MaxReplaces bounds Dashboard.Replaces.

View Source
const MaxSQLBytes = alerting.MaxExprBytes

MaxSQLBytes bounds a KindSQL panel's statement: an alert rule's expr bound, because the two run under the same guard.

View Source
const MaxTags = 8

MaxTags bounds Dashboard.Tags.

View Source
const MaxTopN = 50

MaxTopN bounds Display.TopN.

View Source
const SpecVersion = "forge.dashboards/v1"

SpecVersion identifies the serialized shape of Spec. Bump it on a breaking change so a consumer can refuse a spec it does not understand.

Variables

Groups lists every group in display order.

Functions

func CheckField

func CheckField(sig Signal, field string) error

CheckField reports whether field is a semantic field on signal (the vocabulary documented on FieldService). Every renderer maps exactly these fields, so a field CheckField accepts is one each can draw.

func CheckPostgresSQL added in v1.0.7

func CheckPostgresSQL(sql string) error

CheckPostgresSQL reports whether sql is a statement a KindPostgres panel may carry: at most dbquery.MaxSQLBytes, one read-only statement by the dbquery guard, referencing no parameter past PostgresParamCount. Like CheckSQL it is the first line of defence, not the containment: the reader runs the statement through dbquery.Run as a role confined to what the viewer may read.

func CheckSQL

func CheckSQL(sql string) error

CheckSQL reports whether sql is a statement a KindSQL panel may carry: non-empty, at most MaxSQLBytes, and exactly one read-only SELECT by the alert rule guard (alerting.ValidateExpr), which refuses writes, DDL, SETTINGS, FORMAT, the system database and the table functions that read outside the owner's data.

It is the first line of defence, not the containment: a reader must run the statement as a read-only database user confined to the viewer's own data, under a timeout and a row cap, exactly as it runs an alert rule.

func IsConsoleKind

func IsConsoleKind(k PanelKind) bool

IsConsoleKind reports whether k is drawn only by the Reliant console, so the HyperDX renderer has nothing to emit for it.

func LooksLikeHyperDXDashboard

func LooksLikeHyperDXDashboard(raw []byte) bool

LooksLikeHyperDXDashboard reports whether raw is a HyperDX v2 dashboard.

func LooksLikeSpecDashboard

func LooksLikeSpecDashboard(raw []byte) bool

LooksLikeSpecDashboard reports whether raw is a spec-form dashboard rather than a HyperDX one: it has a "panels" array and no "tiles".

func ParseSpan added in v1.0.6

func ParseSpan(s string) (time.Duration, error)

ParseSpan reads a duration as the spec writes it: a number and a unit of s, m, h or d ("90m", "7d"). It is the form of Dashboard.DefaultRange and Panel.MinStep, and is refused when longer than MaxDefaultRange.

func SeriesRef

func SeriesRef(i int) string

SeriesRef is the name a Formula gives Series[i]: A for the first, B for the second, up to J for the tenth.

Types

type Agg

type Agg string

Agg is an aggregate function.

const (
	AggCount         Agg = "count"
	AggCountDistinct Agg = "count_distinct"
	AggSum           Agg = "sum"
	AggAvg           Agg = "avg"
	AggMax           Agg = "max"
	AggQuantile      Agg = "quantile"
	AggLast          Agg = "last"
	// AggRate, AggIncrease and AggMin are metrics-only. A rate is per second,
	// an increase is per bucket, and both are time-weighted per series; on a
	// monotonic sum, AggSum still means the increase.
	AggRate     Agg = "rate"
	AggIncrease Agg = "increase"
	AggMin      Agg = "min"
)

The aggregate functions a series can apply.

type Annotation

type Annotation struct {
	Source AnnotationSource `json:"source"`
	Label  string           `json:"label,omitempty"`
}

Annotation is a marker series drawn over every KindLine panel of a dashboard. HyperDX has no such concept, so RenderHyperDX ignores it.

type AnnotationSource

type AnnotationSource string

AnnotationSource names where a dashboard's time-series markers come from.

const (
	// AnnotationReleases marks every promotion of a release into the
	// environment on the dashboard's time-series panels.
	AnnotationReleases AnnotationSource = "releases"
)

The annotation sources. The spec only DECLARES a source; the renderer draws it from data it owns (the Reliant console reads the release ledger).

type Dashboard

type Dashboard struct {
	// Scope is empty for ScopeProject.
	Scope       Scope     `json:"scope,omitempty"`
	Sections    []Section `json:"sections,omitempty"`
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	// Group is the list section (see Group); Tags are free-form labels
	// (lowercase letters, digits, '.', '_' and '-', at most MaxTags).
	Group Group    `json:"group,omitempty"`
	Tags  []string `json:"tags,omitempty"`
	// Replaces lists the ids of dashboards this one supersedes (a renamed
	// generated dashboard, or several consolidated into one). A reader that
	// keeps per-dashboard state (stars, copies) moves it from a replaced id
	// to this one. It never changes what the dashboard draws.
	Replaces    []string     `json:"replaces,omitempty"`
	Filters     []Filter     `json:"filters,omitempty"`
	Annotations []Annotation `json:"annotations,omitempty"`
	// DefaultRange is the time range the dashboard opens on when the viewer
	// picked none: a number and a unit of s, m, h or d ("24h", "7d"), at most
	// MaxDefaultRange. A dashboard whose panels bucket by day declares "7d";
	// without it a renderer opens on its own default (an hour, in the console).
	// A renderer with fixed presets rounds up to the nearest one.
	DefaultRange string  `json:"defaultRange,omitempty"`
	Panels       []Panel `json:"panels"`
}

Dashboard is an ordered list of panels under a shared set of filters.

func ParseDashboard

func ParseDashboard(name string, raw []byte) (Dashboard, error)

ParseDashboard decodes and validates one dashboard file: a single Dashboard object in the renderer-neutral spec vocabulary (the objects of the spec's dashboards). name is only used in errors.

Every problem found is reported, each with the line and column of the offending value (or, for an unknown field, of its key). Validation covers what the renderers and the console's query engine would otherwise discover one request at a time: field names that exist on the panel's signal, the operator set, series limits, a quantile's range, a metric series naming its metric and type, and unique ids.

type Display added in v1.0.14

type Display struct {
	// Style is one of DisplayStyles(kind). Empty is the kind's default.
	Style DisplayStyle `json:"style,omitempty"`
	// Stack stacks the series, so the top edge is their total and each band
	// or bar segment is one series' share: a line or sql panel drawn as area
	// or bars, or a bar panel drawn as bars. Only additive values (counts,
	// sums, rates) add up to a meaningful whole; the author decides.
	Stack bool `json:"stack,omitempty"`
	// Horizontal lays a bar panel's bars along the y axis, which suits long
	// group names.
	Horizontal bool `json:"horizontal,omitempty"`
	// Min and Max are a gauge's scale. Min defaults to 0; Max is required
	// unless the panel's unit is percent, whose scale is 0 to 1.
	Min *float64 `json:"min,omitempty"`
	Max *float64 `json:"max,omitempty"`
	// TopN is how many series a line panel (or slices a pie or donut) draws
	// before folding the rest into one "Other": summed where the values add
	// up, left out where they do not. The full list stays a click away. Zero
	// is the reader's own default; at most MaxTopN.
	TopN int `json:"topN,omitempty"`
}

Display says how a panel's data is drawn when its kind can draw it more than one way. Every field is optional and changes the picture only, never the query. Renderers that cannot honour a field ignore it (HyperDX ignores all of them).

type DisplayStyle added in v1.0.14

type DisplayStyle string

DisplayStyle is one way to draw a panel's data, where its kind has more than one. The query a panel runs is decided by its kind alone; a style only changes the picture, so a reader that does not know a style draws the kind's default instead and is still right about the numbers.

const (
	// StyleLine (default), StyleArea and StyleBars draw a line panel's time
	// series, or a sql panel's, as lines, filled areas or one bar per bucket.
	StyleLine DisplayStyle = "line"
	StyleArea DisplayStyle = "area"
	StyleBars DisplayStyle = "bars"
	// StyleBar (default), StylePie and StyleDonut draw a bar panel's groups as
	// bars or as the slices of a whole. A pie reads Series[0] alone.
	StyleBar   DisplayStyle = "bar"
	StylePie   DisplayStyle = "pie"
	StyleDonut DisplayStyle = "donut"
	// StyleStat (default) and StyleGauge draw a number panel's values as
	// figures or as dials between Display.Min and Display.Max.
	StyleStat  DisplayStyle = "stat"
	StyleGauge DisplayStyle = "gauge"
	// StyleFunnel draws a sql panel's rows as funnel steps, in the order the
	// statement returns them: the first text column names the step, the first
	// numeric column counts it, and the reader works out the conversion and
	// drop-off between steps. It is how a funnel the funnel kind cannot
	// express (one stitched across identities, say) is still drawn as one.
	StyleFunnel DisplayStyle = "funnel"
)

The display styles, by the kinds that take them. The first of each kind is its default.

func DisplayStyles added in v1.0.14

func DisplayStyles(k PanelKind) []DisplayStyle

DisplayStyles returns the styles kind k takes, its default first; nil for a kind that is drawn one way only and takes no Display.

type Filter

type Filter struct {
	// PanelIDs restricts this filter to declared panels. Empty preserves the
	// dashboard-wide default. RPC filters must not blank runtime/billing panels.
	PanelIDs []string `json:"panelIds,omitempty"`
	ID       string   `json:"id"`
	Label    string   `json:"label"`
	Field    string   `json:"field"`
	// Signal is the telemetry the dropdown reads its values from. Empty is
	// Traces, which every dashboard but the metrics ones draws.
	Signal Signal `json:"signal,omitempty"`
}

Filter is a dashboard-level dropdown that narrows every panel.

type Formula

type Formula struct {
	// contains filtered or unexported fields
}

Formula is a parsed Panel.Formula: arithmetic over a panel's series values. Every reader evaluates it with Eval, so a formula means the same thing in each.

func ParseFormula

func ParseFormula(expr string, series int) (*Formula, error)

ParseFormula parses expr against a panel with series series.

The grammar is the four operators over series references and numbers:

expr    = term { ("+" | "-") term }
term    = unary { ("*" | "/") unary }
unary   = "-" unary | primary
primary = number | ref | "(" expr ")"

A ref is one capital letter naming a series by position (SeriesRef); a number is decimal, with an optional fraction and exponent. A formula must reference at least one series, and at most MaxFormulaLen bytes long.

func (*Formula) Eval

func (f *Formula) Eval(vals []float64) float64

Eval computes the formula with vals[i] as Series[i]'s value. Division by zero yields 0, as a ratio of a zero denominator does, and so does any other result that is not a finite number: a reader draws it as zero rather than as a gap or an error.

func (*Formula) EvalNullable added in v1.0.0

func (f *Formula) EvalNullable(vals []float64, present []bool) (float64, bool)

EvalNullable computes the formula where a series' value may be absent: present[i] says whether vals[i] exists. Absence propagates (an expression with an absent operand is absent), a division by zero is absent, and so is any non-finite result. A reader draws an absent result as a gap, which is what a gauge ratio wants where Eval's 0 would be a lie.

func (*Formula) Refs

func (f *Formula) Refs() []int

Refs are the indexes of the series the formula reads, ascending.

func (*Formula) String

func (f *Formula) String() string

String is the formula's canonical spelling: single spaces around binary operators and only the parentheses its precedence needs.

type Funnel

type Funnel struct {
	// Steps are product event names (the names passed to track()), in order.
	Steps []string `json:"steps"`
	// Window is how long a journey may take from its first step to its last:
	// a number and a unit of s, m, h or d ("1h", "7d"). Empty is "1h".
	Window string `json:"window,omitempty"`
	// By is the journey's identity. Empty is FunnelBySession.
	By FunnelBy `json:"by,omitempty"`
}

Funnel is the definition a KindFunnel panel draws: the ordered event names a journey passes through, within Window, counted per session or per user.

type FunnelBy

type FunnelBy string

FunnelBy is what a funnel counts: how events are tied into one journey.

const (
	FunnelBySession FunnelBy = "session"
	FunnelByUser    FunnelBy = "user"
)

The funnel journeys.

type Group added in v1.0.9

type Group string

Group is the list section a dashboard belongs to. It is presentation data only: it never affects identity, scope or a query.

const (
	GroupOverview Group = "overview"
	GroupServices Group = "services"
	GroupJobs     Group = "jobs"
	GroupProduct  Group = "product"
	GroupPlatform Group = "platform"
	GroupReleases Group = "releases"
	GroupCustom   Group = "custom"
)

The groups. A dashboard that declares none, or one a reader does not know, is GroupCustom.

func GroupOf added in v1.0.9

func GroupOf(d Dashboard) Group

GroupOf is the group d is listed under: its own, else GroupCustom.

type Op

type Op string

Op is a predicate operator.

const (
	OpEq     Op = "eq"
	OpNeq    Op = "neq"
	OpIn     Op = "in"
	OpNotIn  Op = "not_in"
	OpPrefix Op = "prefix"
	OpMatch  Op = "match" // RE2
	OpExists Op = "exists"
	OpGTE    Op = "gte"
)

The predicate operators.

type Panel

type Panel struct {
	// Section is an optional declared dashboard section, for temporary viewer
	// toggles. Empty retains the unsectioned layout.
	Section     string    `json:"section,omitempty"`
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	Kind        PanelKind `json:"kind"`
	// Signal is required on every kind but KindSQL, whose statement names its
	// own tables.
	Signal Signal   `json:"signal,omitempty"`
	Series []Series `json:"series,omitempty"`
	// Ratio makes a two-series line panel plot Series[0]/Series[1]
	// (an error rate is failed requests over all requests).
	Ratio bool `json:"ratio,omitempty"`
	// Formula makes a line or number panel plot one arithmetic expression
	// over its series instead of the series themselves: "A / B * 100", where
	// A is Series[0], B is Series[1], and so on (see ParseFormula). It is the
	// general form of Ratio, which a panel uses instead of, not with, it.
	Formula string `json:"formula,omitempty"`
	// Limit keeps the top Limit rows of a table or bar panel, largest
	// Series[0] first. Zero is DefaultBarLimit for a bar and the reader's own
	// row cap for a table; at most MaxLimit.
	Limit int `json:"limit,omitempty"`
	// SQL is a KindSQL panel's statement: one read-only SELECT over the
	// telemetry tables, which may use the SQLParam* query parameters. Only
	// that kind takes it.
	SQL string `json:"sql,omitempty"`
	// MinStep is the narrowest bucket a KindSQL panel's statement produces,
	// in the same form as DefaultRange ("1d"): set it when the statement
	// groups by a fixed bucket (toDate, toStartOfWeek) rather than by the
	// {step} parameter. A range shorter than two buckets can draw only one
	// point, so a renderer widens such a panel's range to hold two, and says
	// so. Only a sql panel takes it.
	MinStep string `json:"minStep,omitempty"`
	// Where narrows every series of the panel.
	Where   []Predicate `json:"where,omitempty"`
	GroupBy []string    `json:"groupBy,omitempty"`
	// Columns are the fields a KindSearch panel shows.
	Columns []string `json:"columns,omitempty"`
	// Funnel is what a KindFunnel panel draws; only that kind takes it.
	Funnel *Funnel `json:"funnel,omitempty"`
	// Postgres is the query a KindPostgres panel draws; only that kind takes
	// it, and it takes no Signal, Series or SQL.
	Postgres *PostgresQuery `json:"postgres,omitempty"`
	// HasError narrows a KindSessions panel to sessions that hit an error;
	// only that kind takes it.
	HasError bool `json:"hasError,omitempty"`
	// Markdown is a KindText panel's content (CommonMark with GFM tables and
	// links, at most MaxMarkdownBytes); only that kind takes it.
	Markdown string `json:"markdown,omitempty"`
	// Display picks how a line, bar, number or sql panel is drawn (see
	// Display); nil draws the kind's default.
	Display *Display `json:"display,omitempty"`
	Unit    Unit     `json:"unit,omitempty"`
	// Width is in grid columns out of 24; Height in rows. Zero takes the
	// default for the kind.
	Width  int `json:"width,omitempty"`
	Height int `json:"height,omitempty"`
}

Panel is one tile.

type PanelKind

type PanelKind string

PanelKind is how a panel is drawn.

const (
	// KindNumber is one headline value over the selected time range.
	KindNumber PanelKind = "number"
	// KindLine is a time series; with GroupBy, one line per group.
	KindLine PanelKind = "line"
	// KindTable is one row per GroupBy value, one column per Series.
	KindTable PanelKind = "table"
	// KindSearch is a log or span search (no aggregate): the rows themselves.
	KindSearch PanelKind = "search"
	// KindBar is a top-N bar chart: one bar group per GroupBy value, one bar
	// per Series within it, the Limit groups with the largest Series[0] first.
	KindBar PanelKind = "bar"
	// KindHeatmap is the distribution of one numeric field over time: time
	// buckets across, value buckets up, each cell coloured by how many events
	// fell in it (a latency heatmap is span.duration). It takes exactly one
	// series, a count with the bucketed value in Field.
	KindHeatmap PanelKind = "heatmap"
	// KindSQL is drawn from a read-only ClickHouse SELECT the panel carries in
	// SQL instead of from series. The reader runs it with the same guard and
	// limits as an alert rule's expr (see CheckSQL and the SQLParam*
	// parameters).
	KindSQL PanelKind = "sql"

	// KindIssues is the grouped-errors list: new and regressed issues first,
	// then the most frequent. Served by RumService ListIssues.
	KindIssues PanelKind = "issues"
	// KindSessions is a list of browser sessions, with replay links. Served by
	// RumService ListSessions; HasError narrows it to sessions with an error.
	KindSessions PanelKind = "sessions"
	// KindFunnel is a product-event funnel over Panel.Funnel. Served from the
	// product_events table with ClickHouse windowFunnel.
	KindFunnel PanelKind = "funnel"
	// KindPostgres is drawn from a read-only SELECT the panel carries in
	// Postgres, run live against one of the project's databases (see
	// PostgresQuery). The console runs it; HyperDX cannot.
	KindPostgres PanelKind = "postgres"
	// KindText is prose, not data: the Markdown in Panel.Markdown, drawn with
	// no query (a heading over a row of panels, a runbook link, what a
	// dashboard is for). It takes no signal, series or group-by.
	KindText PanelKind = "text"
)

type PostgresQuery added in v1.0.7

type PostgresQuery struct {
	// Database names the database to run against: the same name as `forge db
	// query` takes (a DNS-label-like identifier of at most 63 bytes).
	Database string `json:"database"`
	// SQL is one SELECT, WITH, TABLE or VALUES statement that may use the
	// PostgresParam* parameters. Nothing a viewer picks is spliced into it.
	SQL string `json:"sql"`
	// Draw is how the result is drawn: PostgresDrawAuto (or empty), line,
	// number, table or bar. Auto draws a line when Time names a column, a
	// number for one row and one value, a table otherwise.
	Draw string `json:"draw,omitempty"`
	// Time names the result column holding each row's timestamp. A line
	// requires it.
	Time string `json:"time,omitempty"`
	// Values names the numeric result columns to plot. Empty means every
	// column that is not Time or in Group. A number takes at most one.
	Values []string `json:"values,omitempty"`
	// Group names the result columns that split rows into separate series.
	Group []string `json:"group,omitempty"`
}

PostgresQuery is what a KindPostgres panel draws: one read-only statement run live against a named database, and how its result set becomes a chart. The statement runs under dbquery.Run (read only, read committed, short statement and lock timeouts), so a dashboard never blocks other queries.

type Predicate

type Predicate struct {
	Field  string   `json:"field"`
	Op     Op       `json:"op"`
	Value  string   `json:"value,omitempty"`
	Values []string `json:"values,omitempty"`
}

Predicate is one condition. Values are literals; Field is a semantic field.

type Problem

type Problem struct {
	// Line and Col are 1-based; zero when the position is unknown.
	Line, Col int
	// Path is where in the document: panels[2].series[0].agg.
	Path    string
	Message string
}

Problem is one thing wrong with a dashboard file, located in it.

func ProblemsOf

func ProblemsOf(err error) []Problem

ProblemsOf returns the problems a ParseDashboard error carries, or nil for an error that is not one.

type Scope added in v1.0.6

type Scope string

Scope says which telemetry a dashboard's panels read. It is one enum: the default and the two wider reads.

const (
	// ScopeProject is the default (the empty value): panels read the
	// environments the viewer has selected within the route's project, and the
	// reader narrows every query to them.
	ScopeProject Scope = "project"
	// ScopeOrg reads across every project of the organization: all of the
	// org's environments, still narrowed to the environments the viewer
	// selected. The reader names no project, and a console lists the
	// environments as project/env.
	ScopeOrg Scope = "org"
	// ScopePlatform marks a dashboard whose signals are platform or
	// infrastructure telemetry that belongs to no environment (a database, a
	// message bus, a collector, a GitOps controller). That telemetry carries
	// no reliant.env.id, so an environment filter would match nothing. A
	// reader drops only that environment predicate: who may read, and from
	// which organization's data, is still the reader's decision.
	ScopePlatform Scope = "platform"
)

The dashboard scopes.

type Section added in v1.0.0

type Section struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

Section is a named, ordered group of panels. It changes presentation only; filtering remains explicit through Filter.PanelIDs.

type Series

type Series struct {
	Label string `json:"label"`
	Agg   Agg    `json:"agg"`
	// Quantile is the level for AggQuantile, e.g. 0.95.
	Quantile float64 `json:"quantile,omitempty"`
	// Field is the aggregated value: a semantic field for traces and logs
	// (span.duration, span.attr.lcp), the metric NAME for metrics. Empty for
	// AggCount.
	Field string `json:"field,omitempty"`
	// MetricType is "sum", "gauge", "histogram", "exp_histogram" or "summary"
	// (metrics only).
	MetricType string `json:"metricType,omitempty"`
	// Where narrows this series alone (e.g. only the failed requests).
	Where []Predicate `json:"where,omitempty"`
	// Thresholds grade the series' values good / needs improvement / poor.
	Thresholds *Thresholds `json:"thresholds,omitempty"`
}

Series is one aggregate shown by a panel.

type Signal

type Signal string

Signal is the telemetry table a panel reads.

const (
	Traces  Signal = "traces"
	Metrics Signal = "metrics"
	Logs    Signal = "logs"
)

The signals a panel can read.

type Thresholds

type Thresholds struct {
	Good float64 `json:"good"`
	Poor float64 `json:"poor"`
}

Thresholds colour a series' values the way Core Web Vitals do: at or below Good is good, above Poor is poor, between is "needs improvement". Renderers that cannot colour ignore it.

type Unit

type Unit string

Unit is how a panel's values are formatted.

const (
	UnitNone    Unit = ""
	UnitCount   Unit = "count"
	UnitMillis  Unit = "ms"
	UnitBytes   Unit = "bytes"
	UnitPercent Unit = "percent" // values are fractions in [0,1]
	UnitSeconds Unit = "s"
)

The units a panel's values are formatted in.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL