grafana

package
v2.1.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	From boundary = iota
	To
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetDashboard(dashName string) (Dashboard, error)
	GetPanelPng(p Panel, dashName string, t TimeRange) (io.ReadCloser, error)
}

Client is a Grafana API client

func NewV4Client

func NewV4Client(grafanaURL string, apiToken string, variables url.Values) Client

NewV4Client creates a new Grafana 4 Client. If apiToken is the empty string, authorization headers will be omitted from requests. variables are Grafana template variable url values of the form var-{name}={value}, e.g. var-host=dev

func NewV5Client

func NewV5Client(grafanaURL string, apiToken string, variables url.Values) Client

NewV5Client creates a new Grafana 5 Client. If apiToken is the empty string, authorization headers will be omitted from requests. variables are Grafana template variable url values of the form var-{name}={value}, e.g. var-host=dev

type Dashboard

type Dashboard struct {
	Title          string
	Description    string
	VariableValues string //Not present in the Grafana JSON structure
	Rows           []Row
	Panels         []Panel
}

Dashboard represents a Grafana dashboard

func NewDashboard

func NewDashboard(dashJSON []byte, variables url.Values) Dashboard

NewDashboard creates Dashboard from Grafana's internal JSON dashboard definition

type Panel

type Panel struct {
	ID    int
	Type  string
	Title string
}

Panel represents a Grafana dashboard panel

func (Panel) Is

func (p Panel) Is(t PanelType) bool

func (Panel) IsSingleStat

func (p Panel) IsSingleStat() bool

func (Panel) IsText

func (p Panel) IsText() bool

type PanelType

type PanelType int
const (
	SingleStat PanelType = iota
	Text
	Graph
	Table
)

type Row added in v1.0.0

type Row struct {
	ID        int
	Showtitle bool
	Title     string
	Panels    []Panel
}

Row represents a container for Panels

func (Row) IsVisible added in v1.0.0

func (r Row) IsVisible() bool

type TimeRange

type TimeRange struct {
	From string
	To   string
}

func NewTimeRange

func NewTimeRange(from, to string) TimeRange

func (TimeRange) FromFormatted

func (tr TimeRange) FromFormatted() string

Formats Grafana 'From' time spec into absolute printable time

func (TimeRange) ToFormatted

func (tr TimeRange) ToFormatted() string

Formats Grafana 'To' time spec into absolute printable time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL