DashboardBuilder🔗
Constructor🔗
Methods🔗
Build🔗
Builds the object.
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/
func (builder *DashboardBuilder) Annotation(annotation cog.Builder[dashboard.AnnotationQuery]) *DashboardBuilder
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/
func (builder *DashboardBuilder) Annotations(annotations []cog.Builder[dashboard.AnnotationQuery]) *DashboardBuilder
Description🔗
Description of dashboard.
Editable🔗
Whether a dashboard is editable or not.
FiscalYearStartMonth🔗
The month that the fiscal year starts on. 0 = January, 11 = December
GnetId🔗
ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
Id🔗
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.
Link🔗
Links with references to other dashboards or external websites.
Links🔗
Links with references to other dashboards or external websites.
func (builder *DashboardBuilder) Links(links []cog.Builder[dashboard.DashboardLink]) *DashboardBuilder
LiveNow🔗
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
Preload🔗
When set to true, the dashboard will load all panels in the dashboard when it's loaded.
Readonly🔗
Whether a dashboard is editable or not.
Refresh🔗
Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
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.
Snapshot🔗
Snapshot options. They are present only if the dashboard is a snapshot.
func (builder *DashboardBuilder) Snapshot(snapshot cog.Builder[dashboard.Snapshot]) *DashboardBuilder
Tags🔗
Tags associated with dashboard.
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'}.
Timepicker🔗
Configuration of the time picker shown at the top of a dashboard.
func (builder *DashboardBuilder) Timepicker(timepicker cog.Builder[dashboard.TimePickerConfig]) *DashboardBuilder
Timezone🔗
Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
Title🔗
Title of dashboard.
Tooltip🔗
Configuration of dashboard cursor sync behavior.
Accepted values are 0 (sync turned off), 1 (shared crosshair), 2 (shared crosshair and tooltip).
func (builder *DashboardBuilder) Tooltip(graphTooltip dashboard.DashboardCursorSync) *DashboardBuilder
Uid🔗
Unique dashboard identifier that can be generated by anyone. string (8-40)
Variables🔗
Configured template variables
func (builder *DashboardBuilder) Variables(variables []cog.Builder[dashboard.VariableModel]) *DashboardBuilder
Version🔗
Version of the dashboard, incremented each time the dashboard is updated.
WeekStart🔗
Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
WithPanel🔗
WithRow🔗
func (builder *DashboardBuilder) WithRow(rowPanel cog.Builder[dashboard.RowPanel]) *DashboardBuilder
WithVariable🔗
Configured template variables
func (builder *DashboardBuilder) WithVariable(variable cog.Builder[dashboard.VariableModel]) *DashboardBuilder
Examples🔗
Building a dashboard🔗
package main
import (
"encoding/json"
"fmt"
"github.com/grafana/grafana-foundation-sdk/go/common"
"github.com/grafana/grafana-foundation-sdk/go/dashboard"
"github.com/grafana/grafana-foundation-sdk/go/prometheus"
"github.com/grafana/grafana-foundation-sdk/go/timeseries"
)
func main() {
builder := dashboard.NewDashboardBuilder("Sample dashboard").
Uid("generated-from-go").
Tags([]string{"generated", "from", "go"}).
Refresh("1m").
Time("now-30m", "now").
Timezone(common.TimeZoneBrowser).
WithRow(dashboard.NewRowBuilder("Overview")).
WithPanel(
timeseries.NewPanelBuilder().
Title("Network Received").
Unit("bps").
Min(0).
WithTarget(
prometheus.NewDataqueryBuilder().
Expr(`rate(node_network_receive_bytes_total{job="integrations/raspberrypi-node", device!="lo"}[$__rate_interval]) * 8`).
LegendFormat("{{ device }}"),
),
)
sampleDashboard, err := builder.Build()
if err != nil {
panic(err)
}
dashboardJson, err := json.MarshalIndent(sampleDashboard, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(dashboardJson))
}