dashboard

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 24 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")
	ErrJavaScriptReturnedNoData = errors.New("javascript did not return any dashboard data")
	ErrDashboardHTTPError       = errors.New("dashboard 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 CSVData added in v1.6.3

type CSVData [][]string

CSVData represents type of the CSV data.

type Dashboard

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

Dashboard represents a Grafana dashboard resource.

func New

func New(logger log.Logger, conf *config.Config, httpClient *http.Client, chromeInstance chrome.Instance,
	pools worker.Pools, appURL, appVersion string, model *Model, authHeader http.Header,
) *Dashboard

New creates a new instance of the Dashboard struct.

func (*Dashboard) GetData added in v1.7.1

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

GetData fetches dashboard related data.

func (*Dashboard) PanelCSV added in v1.7.1

func (d *Dashboard) PanelCSV(_ context.Context, p Panel) (CSVData, error)

PanelCSV returns CSV data of a given panel.

func (*Dashboard) PanelPNG added in v1.7.1

func (d *Dashboard) PanelPNG(ctx context.Context, p Panel) (PanelImage, error)

PanelPNG returns encoded PNG image of a given panel.

type Data added in v1.7.1

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

Data represents dashboard data that will be included in the report.

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 Model added in v1.7.1

type Model struct {
	Meta struct {
		FolderUID   string `json:"folderUid"`
		FolderTitle string `json:"folderTitle"`
		FolderURL   string `json:"folderUrl"`
	} `json:"meta"`
	Dashboard struct {
		ID          int          `json:"id"`
		UID         string       `json:"uid"`
		Title       string       `json:"title"`
		Description string       `json:"description"`
		RowOrPanels []RowOrPanel `json:"panels"`
		Panels      []Panel
		Variables   url.Values
	} `json:"dashboard"`
}

Model represents a Grafana JSON dashboard.

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 PanelTable added in v1.7.1

type PanelTable struct {
	Title string
	Data  PanelTableData
}

type PanelTableData added in v1.7.1

type PanelTableData [][]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, layout string) string

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

func (TimeRange) ToFormatted

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