dashboard

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJavaScriptReturnedNoPanels = errors.New("javascript returned no panels")
	ErrDashboardHTTPError         = errors.New("dashboard request does not return 200 OK")
	ErrImageRendererHTTPError     = errors.New("imager renderer request does not return 200 OK")
	ErrEmptyBlobURL               = errors.New("empty blob URL")
	ErrEmptyCSVData               = errors.New("empty csv data")
)

Functions

This section is empty.

Types

type APIDashboardData

type APIDashboardData 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"`
}

type APIData

type APIData struct {
	Dashboard APIDashboardData `json:"dashboard"`
}

type BrowserData

type BrowserData struct {
	TimeRange TimeRange
	PanelData []BrowserPanelData
}

type BrowserPanelData

type BrowserPanelData struct {
	ID        int    `json:"id"`
	Width     string `json:"width"`
	Height    string `json:"height"`
	Title     string `json:"title"`
	Type      string `json:"type"`
	Transform string `json:"transform"`
}

type Dashboard

type Dashboard struct {
	// contains filtered or unexported fields
}

func New

func New(logger log.Logger, conf config.Config, httpClient *http.Client, chromeInstance chrome.Instance,
	pools worker.Pools, grafanaBaseURL string, uid string, values url.Values, saToken string,
) *Dashboard

New creates a new instance of the Dashboard struct.

func (*Dashboard) FetchPNG

func (d *Dashboard) FetchPNG(ctx context.Context, panel Panel) (PanelImage, error)

func (*Dashboard) FetchTable

func (d *Dashboard) FetchTable(ctx context.Context, panel Panel) (PanelTable, error)

func (*Dashboard) GetData

func (d *Dashboard) GetData(ctx context.Context, expandRows bool) (Data, error)

type Data

type Data struct {
	Title     string
	TimeRange TimeRange
	Panels    []Panel
}

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      int     `json:"id"`
	Type    string  `json:"type"`
	Title   string  `json:"title"`
	GridPos GridPos `json:"gridPos"`
}

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) Width

func (p Panel) Width() float64

Width returns the width of the panel.

type PanelImage

type PanelImage struct {
	Panel
	Image    string
	MimeType string
}

func (PanelImage) String

func (p PanelImage) String() string

type PanelTable

type PanelTable struct {
	Title string
	Data  PanelTableData
}

type PanelTableData

type PanelTableData [][]string

type PanelType

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

func (PanelType) String

func (p PanelType) String() string

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     int64 `json:"from"`
	To       int64 `json:"to"`
	FromTime time.Time
	ToTime   time.Time
}

Jump to

Keyboard shortcuts

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