Documentation ¶
Overview ¶
Package grabana provides a developer-friendly way of creating Grafana dashboards.
Whether you prefer writing **code or YAML**, if you are looking for a way to version your dashboards configuration or automate tedious and error-prone creation of dashboards, this library is meant for you.
builder := dashboard.New( "Awesome dashboard", dashboard.VariableAsInterval( "interval", interval.Values([]string{"30s", "1m", "5m", "10m", "30m", "1h", "6h", "12h"}), ), dashboard.VariableAsQuery( "status", query.DataSource("prometheus-default"), query.Request("label_values(prometheus_http_requests_total, code)"), query.Sort(query.NumericalAsc), ), dashboard.Row( "Prometheus", row.WithGraph( "HTTP Rate", graph.WithPrometheusTarget( "rate(promhttp_metric_handler_requests_total[$interval])", prometheus.Legend("{{handler}} - {{ code }}"), ), ), row.WithTable( "Threads", table.WithPrometheusTarget("go_threads"), table.HideColumn("Time"), table.AsTimeSeriesAggregations([]table.Aggregation{ {Label: "AVG", Type: table.AVG}, {Label: "Current", Type: table.Current}, }), ), row.WithSingleStat( "Heap Allocations", singlestat.Unit("bytes"), singlestat.WithPrometheusTarget("go_memstats_heap_alloc_bytes"), ), ), dashboard.Row( "Some text, because it might be useful", row.WithText( "Some awesome html?", text.HTML("<b>lalalala</b>"), ), ), )
For a more information visit https://github.com/K-Phoen/grabana
Index ¶
- Variables
- type Client
- func (client *Client) CreateFolder(ctx context.Context, name string) (*Folder, error)
- func (client *Client) DeleteDashboard(ctx context.Context, uid string) error
- func (client *Client) FindOrCreateFolder(ctx context.Context, name string) (*Folder, error)
- func (client *Client) GetAlertChannelByName(ctx context.Context, name string) (*alert.Channel, error)
- func (client *Client) GetFolderByTitle(ctx context.Context, title string) (*Folder, error)
- func (client *Client) UpsertDashboard(ctx context.Context, folder *Folder, builder dashboard.Builder) (*Dashboard, error)
- type Dashboard
- type Folder
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrAlertChannelNotFound = errors.New("alert channel not found")
ErrAlertChannelNotFound is returned when the given alert notification channel can not be found.
var ErrFolderNotFound = errors.New("folder not found")
ErrFolderNotFound is returned when the given folder can not be found.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Grafana HTTP client.
func (*Client) CreateFolder ¶
CreateFolder creates a dashboard folder. See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/
func (*Client) DeleteDashboard ¶ added in v0.5.2
DeleteDashboard deletes a dashboard given its UID.
func (*Client) FindOrCreateFolder ¶ added in v0.5.3
FindOrCreateFolder returns the folder by its name or creates it if it doesn't exist.
func (*Client) GetAlertChannelByName ¶
func (client *Client) GetAlertChannelByName(ctx context.Context, name string) (*alert.Channel, error)
GetAlertChannelByName finds an alert notification channel, given its name.
func (*Client) GetFolderByTitle ¶
GetFolderByTitle finds a folder, given its title.
type Folder ¶
Folder represents a dashboard folder. See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/
type Option ¶ added in v0.8.0
type Option func(client *Client)
Option represents an option that can be used to configure a client.
func WithAPIToken ¶ added in v0.8.0
WithAPIToken sets up the client to use the given token to authenticate.
func WithBasicAuth ¶ added in v0.8.0
WithBasicAuth sets up the client to use the given credentials to authenticate.