Dashboard🔗
Definition🔗
class Dashboard:
# 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.
id_val: typing.Optional[int]
# Unique dashboard identifier that can be generated by anyone. string (8-40)
uid: typing.Optional[str]
# Title of dashboard.
title: typing.Optional[str]
# Description of dashboard.
description: typing.Optional[str]
# 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.
revision: typing.Optional[int]
# ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
gnet_id: typing.Optional[str]
# Tags associated with dashboard.
tags: typing.Optional[list[str]]
# Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
timezone: typing.Optional[str]
# Whether a dashboard is editable or not.
editable: typing.Optional[bool]
# Configuration of dashboard cursor sync behavior.
# Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
graph_tooltip: typing.Optional[dashboard.DashboardCursorSync]
# 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'}.
time: typing.Optional[dashboard.DashboardDashboardTime]
# Configuration of the time picker shown at the top of a dashboard.
timepicker: typing.Optional[dashboard.TimePickerConfig]
# The month that the fiscal year starts on. 0 = January, 11 = December
fiscal_year_start_month: typing.Optional[int]
# 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
live_now: typing.Optional[bool]
# Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
week_start: typing.Optional[str]
# Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
refresh: typing.Optional[str]
# Version of the JSON schema, incremented each time a Grafana update brings
# changes to said schema.
schema_version: int
# Version of the dashboard, incremented each time the dashboard is updated.
version: typing.Optional[int]
# List of dashboard panels
panels: typing.Optional[list[typing.Union[dashboard.Panel, dashboard.RowPanel]]]
# Configured template variables
templating: dashboard.DashboardDashboardTemplating
# 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/
annotations: dashboard.AnnotationContainer
# Links with references to other dashboards or external websites.
links: typing.Optional[list[dashboard.DashboardLink]]
# Snapshot options. They are present only if the dashboard is a snapshot.
snapshot: typing.Optional[dashboard.Snapshot]
# When set to true, the dashboard will load all panels in the dashboard when it's loaded.
preload: typing.Optional[bool]
Methods🔗
to_json🔗
Converts this object into a representation that can easily be encoded to JSON.
from_json🔗
Builds this object from a JSON-decoded dict.
Examples🔗
Marshalling to JSON🔗
from grafana_foundation_sdk.cog.encoder import JSONEncoder
from grafana_foundation_sdk.models.dashboard import Dashboard
if __name__ == '__main__':
dashboard = Dashboard()
encoder = JSONEncoder(sort_keys=True, indent=2)
print(encoder.encode(dashboard))
Unmarshalling from JSON🔗
import json
from grafana_foundation_sdk.cog.plugins import register_default_plugins
from grafana_foundation_sdk.models.dashboard import Dashboard as DashboardModel
if __name__ == '__main__':
# Required to correctly unmarshal panels and dataqueries
register_default_plugins()
with open("dashboard.json", "r") as f:
decoded_dashboard = DashboardModel.from_json(json.load(f))
print(decoded_dashboard)