dashboard

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	From boundary = iota
	To
)

Variables

View Source
var (
	ErrNoPanels        = errors.New("no panels found in browser data")
	ErrNoDashboardData = errors.New("no dashboard data found")
)

Functions

This section is empty.

Types

type CSVData added in v1.6.3

type CSVData [][]string

CSVData represents type of the CSV data.

type Dashboard

type Dashboard struct {
	Title          string       `json:"title"`
	Description    string       `json:"description"`
	VariableValues string       // Not present in the Grafana JSON structure. Enriched data passed used by the Tex templating
	RowOrPanels    []RowOrPanel `json:"panels"`
	Panels         []Panel
}

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

func New

func New(log log.Logger, config config.Config, dashJSON []byte, dashData []interface{}, queryParams url.Values) (Dashboard, error)

New creates Dashboard from Grafana's internal JSON dashboard model fetched from Grafana API and browser.

type GridPos

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

GridPos represents a Grafana dashboard panel position.

type Panel

type Panel struct {
	ID           string  `json:"-"`
	Type         string  `json:"type"`
	Title        string  `json:"title"`
	GridPos      GridPos `json:"gridPos"`
	EncodedImage PanelImage
	CSVData      CSVData
}

Panel represents a Grafana dashboard panel.

func (Panel) Height

func (p Panel) Height() float64

Height returns the height of the panel.

func (Panel) Is

func (p Panel) Is(t PanelType) bool

Is returns true if panel is of type t.

func (Panel) IsPartialWidth

func (p Panel) IsPartialWidth() bool

IsPartialWidth If panel has width less than total allowable width.

func (Panel) IsSingleStat

func (p Panel) IsSingleStat() bool

IsSingleStat returns true if panel is of type SingleStat.

func (*Panel) UnmarshalJSON added in v1.7.0

func (p *Panel) UnmarshalJSON(b []byte) error

func (Panel) Width

func (p Panel) Width() float64

Width returns the width of the panel.

type PanelID added in v1.7.0

type PanelID string

func (*PanelID) UnmarshalJSON added in v1.7.0

func (i *PanelID) UnmarshalJSON(b []byte) error

type PanelImage

type PanelImage struct {
	Image    string
	MimeType string
}

func (PanelImage) String

func (p PanelImage) String() string

type PanelType

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

type RowOrPanel

type RowOrPanel struct {
	Panel
	Collapsed bool    `json:"collapsed"`
	Panels    []Panel `json:"panels"`
}

RowOrPanel represents a container for Panels.

type TimeRange

type TimeRange struct {
	From string
	To   string
}

func NewTimeRange

func NewTimeRange(from, to string) TimeRange

NewTimeRange creates a new TimeRange struct.

func (TimeRange) FromFormatted

func (tr TimeRange) FromFormatted(loc *time.Location) string

Formats Grafana 'From' time spec into absolute printable time.

func (TimeRange) ToFormatted

func (tr TimeRange) ToFormatted(loc *time.Location) 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