grafana

package
v0.0.0-...-6b42d85 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

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, sslCheck bool, gridLayout bool) 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, sslCheck bool, gridLayout bool) 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. Enriched data passed used by the Tex templating
	Rows           []Row
	Panels         []Panel
}

Dashboard represents a Grafana dashboard This is both used to unmarshal the dashbaord JSON into and then enriched (sanitize fields for TeX consumption and add VarialbeValues)

func NewDashboard

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

NewDashboard creates Dashboard from Grafana's internal JSON dashboard definition

type GridPos

type GridPos struct {
	H float64 `json:"h"`
	W float64 `json:"w"`
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Panel represents a Grafana dashboard panel position

type Panel

type Panel struct {
	Id      int
	Type    string
	Title   string
	GridPos GridPos
}

Panel represents a Grafana dashboard panel

func (Panel) Height

func (p Panel) Height() float64

func (Panel) Is

func (p Panel) Is(t PanelType) bool

func (Panel) IsPartialWidth

func (p Panel) IsPartialWidth() bool

func (Panel) IsSingleStat

func (p Panel) IsSingleStat() bool

func (Panel) Width

func (p Panel) Width() float64

type PanelType

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

type Row

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

Row represents a container for Panels

func (Row) IsVisible

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