grafana

package module
Version: v0.0.0-...-a63fc3c Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

README

go-grafana

grafana golang client library

Usage

// TODO

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidResponse is thrown when grafana responds with invalid or error response
	ErrInvalidResponse = errors.New("invalid response from Grafana")
	// ErrDoesNotExist is thrown when the resource does not exists
	ErrDoesNotExist = errors.New("the resource does not exist")
	// ErrInvalidArgument is thrown when invalid argument
	ErrInvalidArgument = errors.New("the argument passed is invalid")
	// ErrTimeoutError is thrown when the operation has timed out
	ErrTimeoutError = errors.New("the operation has timed out")
	// ErrConflict is thrown when the resource is conflicting (ie. app already exists)
	ErrConflict = errors.New("conflicting resource")
	// ErrAuthFailed is thrown when Authication Failed
	ErrAuthFailed = errors.New("Invalid API key")
	// ErrPreconditionFailed is thrown when Precondition Failed
	ErrPreconditionFailed = errors.New("Precondition failed")
)

Functions

func SetDebug

func SetDebug(debug bool)

func SetLogger

func SetLogger(logOutput io.Writer)

Types

type Config

type Config struct {
	URL   string
	Token string
}

func NewConfig

func NewConfig(url, token string) Config

type Dashboard

type Dashboard struct {
	Annotations struct {
		List []interface{} `json:"list"`
	} `json:"annotations"`
	Editable        bool        `json:"editable"`
	HideControls    bool        `json:"hideControls"`
	Id              int64       `json:"id"`
	Links           []Link      `json:"links"`
	OriginalTitle   string      `json:"originalTitle"`
	Refresh         interface{} `json:"refresh"`
	Rows            []Row       `json:"rows"`
	SchenmaVersion  int64       `json:"schemaVersion"`
	SharedCrosshair bool        `json:"shardCrosshair"`
	Style           string      `json:"style"`
	Tags            []string    `json:"tags"`
	Templating      struct {
		List []interface{} `jsno:"list"`
	} `json:"templating"`
	Time       Time       `json:"time"`
	Timepicker Timepicker `json:"timepicker"`
	Timezone   string     `json:"timezone"`
	Title      string     `json:"title"`
	Version    int64      `json:"version"`
}

func NewDefaultDashBoard

func NewDefaultDashBoard() *Dashboard

func (*Dashboard) AddRow

func (d *Dashboard) AddRow(row Row) *Dashboard

func (*Dashboard) AddTag

func (d *Dashboard) AddTag(tag string) *Dashboard

func (*Dashboard) SetRefresh

func (d *Dashboard) SetRefresh(refresh interface{}) *Dashboard

func (*Dashboard) SetStyle

func (d *Dashboard) SetStyle(style string) *Dashboard

func (*Dashboard) SetTime

func (d *Dashboard) SetTime(from, to string) *Dashboard

func (*Dashboard) SetTimezone

func (d *Dashboard) SetTimezone(timezone string) *Dashboard

func (*Dashboard) SetTitle

func (d *Dashboard) SetTitle(title string) *Dashboard

type GetDashboardResponse

type GetDashboardResponse struct {
	Dashboard Dashboard `json:"dashboard"`
	Meta      Meta      `json:"meta"`
}

type Grafana

type Grafana interface {
	// Dashboards
	CreateDashboard(dashboard *Dashboard, overwrite bool) error
	GetDashboard(slug string) (*Dashboard, error)
	DeleteDashboard(slug string) error
}

func NewGrafanaClient

func NewGrafanaClient(config Config) Grafana

type GraphPanel

type GraphPanel struct {
	AliasColors     interface{}   `json:"aliasColors,omitempty"`
	Bars            bool          `json:"bars"`
	Datasource      string        `json:"datasource,omitempty"`
	Editable        bool          `json:"editable"`
	Error           bool          `json:"error"`
	Fill            int64         `json:"fill"`
	Grid            interface{}   `json:"grid,omitempty"`
	Id              int64         `json:"id"`
	LeftYAxisLabel  string        `json:"leftYAxisLabel"`
	Legend          Legend        `json:"legend,omitempty"`
	Lines           bool          `json:"lines"`
	Linewidth       int64         `json:"linewidth"`
	Links           []interface{} `json:"links,omitempty"`
	MinSpan         interface{}   `json:"minSpan,omitempty"`
	NullPointMode   string        `json:"nullPointMode"`
	Percentage      bool          `json:"percentage"`
	Pointradius     int64         `json:"pointradius"`
	Points          bool          `json:"points"`
	Renderer        string        `json:"renderer"`
	RightYAxisLabel string        `json:"rightYAxisLabel"`
	SeriesOverrides []interface{} `json:"seriesOverrides,omitempty"`
	Span            interface{}   `json:"span,omitempty"`
	Stack           bool          `json:"stack"`
	SteppedLine     bool          `json:"steppedLine"`
	Targets         []Target      `json:"targets"`
	TimeFrom        interface{}   `json:"timeFrom,omitempty"`
	TimeShift       interface{}   `json:"timeShift,omitempty"`
	Title           string        `json:"title"`
	Tooltip         struct {
		Shared    bool   `json:"shared"`
		ValueType string `json:"value_type"`
	} `json:"tooltip"`
	Transparent bool     `json:"transparent"`
	Type        string   `json:"type"`
	XAxis       bool     `json:"x-axis"`
	YAxis       bool     `json:"y-axis"`
	YFormats    []string `json:"y_formats"`
}

func NewGraphPanel

func NewGraphPanel(title string) GraphPanel

func (*GraphPanel) AddTarget

func (p *GraphPanel) AddTarget(target Target) *GraphPanel

func (*GraphPanel) SetDatasource

func (p *GraphPanel) SetDatasource(ds string) *GraphPanel

func (*GraphPanel) SetLeftYFormat

func (p *GraphPanel) SetLeftYFormat(format string) *GraphPanel

func (*GraphPanel) SetRightYFormat

func (p *GraphPanel) SetRightYFormat(format string) *GraphPanel

func (*GraphPanel) SetSpanWidth

func (p *GraphPanel) SetSpanWidth(width int) *GraphPanel

func (*GraphPanel) SetStack

func (p *GraphPanel) SetStack(check bool) *GraphPanel

type Legend

type Legend struct {
	Avg     bool `json:"avg"`
	Current bool `json:"current"`
	Max     bool `json:"max"`
	Min     bool `json:"min"`
	Show    bool `json:"show"`
	Total   bool `json:"total"`
	Values  bool `json:"values"`
}

func (*Legend) DisableAvg

func (l *Legend) DisableAvg() *Legend

func (*Legend) DisableCurrent

func (l *Legend) DisableCurrent() *Legend

func (*Legend) DisableLegend

func (l *Legend) DisableLegend() *Legend

func (*Legend) DisableMax

func (l *Legend) DisableMax() *Legend

func (*Legend) DisableMin

func (l *Legend) DisableMin() *Legend

func (*Legend) DisableTotal

func (l *Legend) DisableTotal() *Legend

func (*Legend) EnableAvg

func (l *Legend) EnableAvg() *Legend

func (*Legend) EnableCurrent

func (l *Legend) EnableCurrent() *Legend

func (*Legend) EnableLegend

func (l *Legend) EnableLegend() *Legend

func (*Legend) EnableMax

func (l *Legend) EnableMax() *Legend

func (*Legend) EnableMin

func (l *Legend) EnableMin() *Legend

func (*Legend) EnableTotal

func (l *Legend) EnableTotal() *Legend
type Link struct {
	Icon string   `json:"icon"`
	Tags []string `json:"tags"`
	Type string   `json:"type"`
}
func NewLink(tag string) Link

type Meta

type Meta struct {
	Type    string `json:"type"`
	CanSave bool   `json:"canSave"`
	CanEdit bool   `json:"canEdit"`
	CanStar bool   `json:"canStar"`
	Slug    string `json:"slug"`
	Expires string `json:"expires"`
	Created string `json:"Created"`
}

type PostDashboardRequest

type PostDashboardRequest struct {
	Dashboard Dashboard `json:"dashboard"`
	Overwrite bool      `json:"overwrite"`
}

type PostDashboardResponse

type PostDashboardResponse struct {
	Slug    string `json:"slug,omitmepty"`
	Status  string `json:"status"`
	Version int64  `json:"version,omitempty"`
	// contains filtered or unexported fields
}

type Row

type Row struct {
	Collapse  bool          `json:"collapse"`
	Editable  bool          `json:"editable"`
	Height    string        `json:"height"`
	Panels    []interface{} `json:"panels"`
	ShowTitle bool          `json:"showTitle"`
	Title     string        `json:"title"`
}

func NewDefaultRow

func NewDefaultRow(title string) Row

func (*Row) AddPanel

func (r *Row) AddPanel(p interface{}) *Row

func (*Row) SetHeight

func (r *Row) SetHeight(h string) *Row

func (*Row) SetTitle

func (r *Row) SetTitle(title string) *Row

type SingleStatPanel

type SingleStatPanel struct {
	CacheTimeout    interface{}   `json:"cacheTimeout,omitempty"`
	ColorBackground bool          `json:"colorBackground,omitempty"`
	ColorValue      bool          `json:"colorValue,omitempty"`
	Colors          []string      `json:"colors,omitempty"`
	Datasource      string        `json:"datasource,omitempty"`
	Editable        bool          `json:"editable"`
	Error           bool          `json:"error"`
	Decimals        int           `json:"decimals"`
	Format          string        `json:"format"`
	ID              int           `json:"id"`
	Interval        interface{}   `json:"interval,omitempty"`
	IsNew           bool          `json:"isNew,omitempty"`
	Links           []interface{} `json:"links,omitempty"`
	MaxDataPoints   int           `json:"maxDataPoints"`
	NullPointMode   string        `json:"nullPointMode"`
	NullText        string        `json:"nullText,omitempty"`
	Postfix         string        `json:"postfix"`
	PostfixFontSize string        `json:"postfixFontSize"`
	Prefix          string        `json:"prefix"`
	PrefixFontSize  string        `json:"prefixFontSize"`
	Span            int           `json:"span"`
	Sparkline       struct {
		FillColor string `json:"fillColor"`
		Full      bool   `json:"full"`
		LineColor string `json:"lineColor"`
		Show      bool   `json:"show"`
	} `json:"sparkline"`
	Targets       []Target   `json:"targets"`
	Thresholds    string     `json:"thresholds"`
	Title         string     `json:"title"`
	Type          string     `json:"type"`
	ValueFontSize string     `json:"valueFontSize"`
	ValueMaps     []ValueMap `json:"valueMaps"`
	ValueName     string     `json:"valueName"`
}

func NewSingleStatPanel

func NewSingleStatPanel(title string) SingleStatPanel

func (*SingleStatPanel) AddTarget

func (p *SingleStatPanel) AddTarget(target Target) *SingleStatPanel

func (*SingleStatPanel) SetDatasource

func (p *SingleStatPanel) SetDatasource(ds string) *SingleStatPanel

func (*SingleStatPanel) SetDecimals

func (p *SingleStatPanel) SetDecimals(decimal int) *SingleStatPanel

func (*SingleStatPanel) SetFormat

func (p *SingleStatPanel) SetFormat(format string) *SingleStatPanel

func (*SingleStatPanel) SetSpanWidth

func (p *SingleStatPanel) SetSpanWidth(width int) *SingleStatPanel

type Target

type Target struct {
	Expr           string `json:"expr"`
	Interval       int    `json:"interval"`
	IntervalFactor int32  `json:"intervalFactor"`
	LegendFormat   string `json:"legendFormat"`
	Metric         string `json:"metric"`
	RefId          string `json:"refId"`
}

func NewTarget

func NewTarget(expr, legendFormat, metric, refID string) Target

type Time

type Time struct {
	From string `json:"from"`
	To   string `json:"to"`
}

func NewTime

func NewTime(from, to string) Time

type Timepicker

type Timepicker struct {
	Now              bool     `json:"now"`
	RefreshIntervals []string `json:"refresh_intervals"`
	TimeOptions      []string `json:"time_options"`
}

func NewDefaultTimepicker

func NewDefaultTimepicker() Timepicker

type ValueMap

type ValueMap struct {
	Op    string `json:"op"`
	Text  string `json:"text"`
	Value string `json:"value"`
}

func NewDefaultValueMap

func NewDefaultValueMap() ValueMap

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL