Create a dashboard builder
The starting point for every SDK dashboard is the DashboardBuilder. You create one with a title, then chain configuration methods to set properties like UID, tags, refresh interval, and time range.
To create your dashboard builder, complete the following steps:
Go
Open
main.goand add the following code:package main import ( "encoding/json" "log" "os" "github.com/grafana/grafana-foundation-sdk/go/cog" "github.com/grafana/grafana-foundation-sdk/go/common" "github.com/grafana/grafana-foundation-sdk/go/dashboard" ) func main() { builder := dashboard.NewDashboardBuilder("My SDK Dashboard"). Uid("my-sdk-dashboard"). Tags([]string{"generated", "foundation-sdk"}). Refresh("5m"). Time("now-1h", "now"). Timezone(common.TimeZoneBrowser) }
TypeScript
Open
index.tsand add the following code:import { DashboardBuilder } from '@grafana/grafana-foundation-sdk/dashboard'; const builder = new DashboardBuilder('My SDK Dashboard') .uid('my-sdk-dashboard') .tags(['generated', 'foundation-sdk']) .refresh('5m') .time({ from: 'now-1h', to: 'now' }) .timezone('browser');
What each method does
In the next milestone, you add panels with data queries to your dashboard.
page 4 of 8