Dashboard🔗
Definition🔗
class Dashboard implements \JsonSerializable
{
/**
* Unique numeric identifier for the dashboard.
* `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
*/
public ?int $id;
/**
* Unique dashboard identifier that can be generated by anyone. string (8-40)
*/
public ?string $uid;
/**
* Title of dashboard.
*/
public ?string $title;
/**
* Description of dashboard.
*/
public ?string $description;
/**
* This property should only be used in dashboards defined by plugins. It is a quick check
* to see if the version has changed since the last time.
*/
public ?int $revision;
/**
* ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
*/
public ?string $gnetId;
/**
* Tags associated with dashboard.
* @var array<string>|null
*/
public ?array $tags;
/**
* Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
*/
public ?string $timezone;
/**
* Whether a dashboard is editable or not.
*/
public ?bool $editable;
/**
* Configuration of dashboard cursor sync behavior.
* Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
*/
public ?\Grafana\Foundation\Dashboard\DashboardCursorSync $graphTooltip;
/**
* Time range for dashboard.
* Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}.
*/
public ?\Grafana\Foundation\Dashboard\DashboardDashboardTime $time;
/**
* Configuration of the time picker shown at the top of a dashboard.
*/
public ?\Grafana\Foundation\Dashboard\TimePickerConfig $timepicker;
/**
* The month that the fiscal year starts on. 0 = January, 11 = December
*/
public ?int $fiscalYearStartMonth;
/**
* When set to true, the dashboard will redraw panels at an interval matching the pixel width.
* This will keep data "moving left" regardless of the query refresh rate. This setting helps
* avoid dashboards presenting stale live data
*/
public ?bool $liveNow;
/**
* Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
*/
public ?string $weekStart;
/**
* Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
*/
public ?string $refresh;
/**
* Version of the JSON schema, incremented each time a Grafana update brings
* changes to said schema.
*/
public int $schemaVersion;
/**
* Version of the dashboard, incremented each time the dashboard is updated.
*/
public ?int $version;
/**
* List of dashboard panels
* @var array<\Grafana\Foundation\Dashboard\Panel|\Grafana\Foundation\Dashboard\RowPanel>|null
*/
public ?array $panels;
/**
* Configured template variables
*/
public \Grafana\Foundation\Dashboard\DashboardDashboardTemplating $templating;
/**
* Contains the list of annotations that are associated with the dashboard.
* Annotations are used to overlay event markers and overlay event tags on graphs.
* Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
* See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
*/
public \Grafana\Foundation\Dashboard\AnnotationContainer $annotations;
/**
* Links with references to other dashboards or external websites.
* @var array<\Grafana\Foundation\Dashboard\DashboardLink>|null
*/
public ?array $links;
/**
* Snapshot options. They are present only if the dashboard is a snapshot.
*/
public ?\Grafana\Foundation\Dashboard\Snapshot $snapshot;
/**
* When set to true, the dashboard will load all panels in the dashboard when it's loaded.
*/
public ?bool $preload;
}
Methods🔗
fromArray🔗
Builds this object from an array.
This function is meant to be used with the return value of json_decode($json, true)
.
jsonSerialize🔗
Returns the data representing this object, preparing it for JSON serialization with json_encode()
.
Examples🔗
Encoding to JSON🔗
use Grafana\Foundation\Dashboard\Dashboard;
require_once __DIR__.'/vendor/autoload.php';
$dashboard = new Dashboard(
uid: 'sample-dashboard-uid',
title: 'Sample dashboard',
);
echo(json_encode($dashboard, JSON_PRETTY_PRINT).PHP_EOL);
Decoding from JSON🔗
use Grafana\Foundation\Dashboard\Dashboard;
require_once __DIR__.'/vendor/autoload.php';
$dashboardJSON = file_get_contents(__DIR__.'/dashboard.json');
$dashboard = Dashboard::fromArray(json_decode($dashboardJSON, true));
var_dump($dashboard);