Skip to main content
Version: Next

Dashboards

Dashboards are pages of panels that the dashboard's editor builds. The gateway stores them and runs the SQL a panel holds. Background in Dashboards.

Routes​

Method and pathRolePurpose
GET /api/v1/dashboardsviewerSummaries by name
GET /api/v1/dashboards/{id}viewerOne dashboard with its document
POST /api/v1/dashboardsengineerCreate one
PUT /api/v1/dashboards/{id}engineerSave, optionally from a known revision
DELETE /api/v1/dashboards/{id}engineerDelete, 204
POST /api/v1/dashboards/{id}/queryviewerRun the saved SQL of one panel
POST /api/v1/dashboards/query/previewengineerRun SQL that is not saved yet
GET /api/v1/dashboards/connectionsengineerThe database connections a query can use
GET /api/v1/dashboards/connections/{id}/schemaengineerThe tables and columns of one connection

The dashboard​

A summary is { id, name, description, panelCount, revision, createdAt, updatedAt }. panelCount counts panels, those folded into a row too, and not the rows. One dashboard adds createdBy and definition, the document as a JSON object.

POST /api/v1/dashboards
{ "name": "Pumps", "description": "", "definition": { "version": 1, "panels": [] } }

A missing definition is {"version":1,"panels":[]}. A name is 1 to 80 characters. The document is one JSON object of at most 1 MB with at most 300 panels, each with a text id of up to 64 characters that is unique in the dashboard. A row panel may hold its folded panels in its own panels. Each panel's queries may hold a SQL source, { "refId": "A", "source": { "kind": "sql", "connectionId", "sql", "format" } }; its text must pass the read-only check, or the save is a 400 that names the panel. A query that is still empty is a draft and is kept. Nothing else in the document is checked, and every field comes back as it was sent.

Revisions​

Every save adds one to revision. PUT takes an optional baseRevision, the revision the caller started from. If the dashboard has moved on, the save is refused:

{ "statusCode": 409, "message": "Someone else changed this dashboard (revision 5). Reload it and apply your change again.", "revision": 5 }

Leave baseRevision out to save over whatever is there. A PUT without definition renames the dashboard and keeps its panels.

Database queries​

POST /api/v1/dashboards/{id}/query takes { panelId, refId, from, to, intervalMs?, maxRows? } and runs the SQL stored in that panel of that saved dashboard, so a viewer cannot run SQL of their own. It is a 404 for a dashboard, panel or query that does not exist or is not SQL. POST /api/v1/dashboards/query/preview takes { connectionId, sql, from, to, intervalMs?, maxRows? }.

from and to are milliseconds since 1970 (the last hour if left out). intervalMs is the width of a step. maxRows is 5,000 unless asked, at most 20,000. The answer:

{ "columns": [{ "name": "at", "type": "time" }, { "name": "value", "type": "number" }], "rows": [[1763000000000, 1.5]], "rowCount": 1, "truncated": false, "elapsedMs": 4 }

type is time (milliseconds since 1970, UTC), number, boolean or string. A null stays null; a number JSON cannot hold is null. The query may use @from, @to (UTC timestamps) and @interval (whole seconds, at least 1). They are bound as parameters. It must be one SELECT or WITH ... SELECT; what the check refuses, the limits, and why the connection should sign in as a read-only user are under Database. A disabled connection is a 409 and a missing one a 404. A viewer whose panel cannot reach its database is told only that; an engineer is given what the driver said.

GET /api/v1/dashboards/connections lists { id, name, engine, engineLabel, state } for every saved connection, with no host, user or password. GET /api/v1/dashboards/connections/{id}/schema returns { tables: [{ schema, name, columns: [{ name, type }] }], truncated } for what the connection's user can see, at most 300 tables and 6,000 columns.