Skip to content

Dashboard🔗

Constructor🔗

Dashboard(title: str)

Methods🔗

build🔗

Builds the object.

def build() -> dashboard.Dashboard

annotation🔗

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/

def annotation(annotation: cogbuilder.Builder[dashboard.AnnotationQuery]) -> typing.Self

annotations🔗

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/

def annotations(annotations: list[cogbuilder.Builder[dashboard.AnnotationQuery]]) -> typing.Self

description🔗

Description of dashboard.

def description(description: str) -> typing.Self

editable🔗

Whether a dashboard is editable or not.

def editable() -> typing.Self

fiscal_year_start_month🔗

The month that the fiscal year starts on. 0 = January, 11 = December

def fiscal_year_start_month(fiscal_year_start_month: int) -> typing.Self

gnet_id🔗

ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal

def gnet_id(gnet_id: str) -> typing.Self

id_val🔗

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.

def id_val(id_val: int) -> typing.Self

Links with references to other dashboards or external websites.

def link(link: cogbuilder.Builder[dashboard.DashboardLink]) -> typing.Self

Links with references to other dashboards or external websites.

def links(links: list[cogbuilder.Builder[dashboard.DashboardLink]]) -> typing.Self

live_now🔗

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

def live_now(live_now: bool) -> typing.Self

preload🔗

When set to true, the dashboard will load all panels in the dashboard when it's loaded.

def preload(preload: bool) -> typing.Self

readonly🔗

Whether a dashboard is editable or not.

def readonly() -> typing.Self

refresh🔗

Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".

def refresh(refresh: str) -> typing.Self

revision🔗

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.

def revision(revision: int) -> typing.Self

snapshot🔗

Snapshot options. They are present only if the dashboard is a snapshot.

def snapshot(snapshot: cogbuilder.Builder[dashboard.Snapshot]) -> typing.Self

tags🔗

Tags associated with dashboard.

def tags(tags: list[str]) -> typing.Self

time🔗

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'}.

def time(from_val: str, to: str) -> typing.Self

timepicker🔗

Configuration of the time picker shown at the top of a dashboard.

def timepicker(timepicker: cogbuilder.Builder[dashboard.TimePickerConfig]) -> typing.Self

timezone🔗

Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".

def timezone(timezone: str) -> typing.Self

title🔗

Title of dashboard.

def title(title: str) -> typing.Self

tooltip🔗

Configuration of dashboard cursor sync behavior.

Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).

def tooltip(graph_tooltip: dashboard.DashboardCursorSync) -> typing.Self

uid🔗

Unique dashboard identifier that can be generated by anyone. string (8-40)

def uid(uid: str) -> typing.Self

variables🔗

Configured template variables

def variables(variables: list[cogbuilder.Builder[dashboard.VariableModel]]) -> typing.Self

version🔗

Version of the dashboard, incremented each time the dashboard is updated.

def version(version: int) -> typing.Self

week_start🔗

Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".

def week_start(week_start: str) -> typing.Self

with_panel🔗

def with_panel(panel: cogbuilder.Builder[dashboard.Panel]) -> typing.Self

with_row🔗

def with_row(row_panel: cogbuilder.Builder[dashboard.RowPanel]) -> typing.Self

with_variable🔗

Configured template variables

def with_variable(variable: cogbuilder.Builder[dashboard.VariableModel]) -> typing.Self

Examples🔗

Building a dashboard🔗

from grafana_foundation_sdk.builders.dashboard import Dashboard, Row
from grafana_foundation_sdk.builders.prometheus import Dataquery as PrometheusQuery
from grafana_foundation_sdk.builders.timeseries import Panel as Timeseries
from grafana_foundation_sdk.models.common import TimeZoneBrowser

def build_dashboard() -> Dashboard:
    return (
        Dashboard("[TEST] Node Exporter / Raspberry")
        .uid("test-dashboard-raspberry")
        .tags(["generated", "raspberrypi-node-integration"])

        .refresh("1m")
        .time("now-30m", "now")
        .timezone(TimeZoneBrowser)

        .with_row(Row("Overview"))
        .with_panel(
            Timeseries()
            .title("Network Received")
            .unit("bps")
            .min_val(0)
            .with_target(
                PrometheusQuery()
                .expr('rate(node_network_receive_bytes_total{job="integrations/raspberrypi-node", device!="lo"}[$__rate_interval]) * 8')
                .legend_format("{{ device }}")
            )
        )
    )

See also🔗