plugin

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	From boundary = iota
	To
)
View Source
const PLUGIN_NAME = "mahendrapaipuri-dashboardreporter-app"

Variables

This section is empty.

Functions

func NewApp

NewApp creates a new example *App instance.

Types

type App

type App struct {
	backend.CallResourceHandler
	// contains filtered or unexported fields
}

App is the backend plugin which can respond to api queries.

func (*App) CheckHealth

CheckHealth handles health checks sent from Grafana to the plugin.

func (*App) Dispose

func (a *App) Dispose()

Dispose here tells plugin SDK that plugin wants to clean up resources when a new instance created.

type Config

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

Plugin config settings

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 NewDashboard

func NewDashboard(dashJSON []byte, queryParams url.Values, dashboardMode string) Dashboard

NewDashboard creates Dashboard from Grafana's internal JSON dashboard definition

type GrafanaClient

type GrafanaClient interface {
	GetDashboard(dashUID string) (Dashboard, error)
	GetPanelPNG(p Panel, dashUID string, t TimeRange) (io.ReadCloser, error)
}

Client is a Grafana API client

func NewGrafanaClient

func NewGrafanaClient(
	client *http.Client,
	grafanaAppURL string,
	secrets *Secrets,
	queryParams url.Values,
	layout string,
	dashboardMode string,
) GrafanaClient

NewClient creates a new Grafana Client. Cookies and Authorization headers, if found, will be forwarded in the requests queryParams are Grafana template variable url values of the form var-{name}={value}, e.g. var-host=dev

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     `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

Get panel height

func (Panel) Is

func (p Panel) Is(t PanelType) bool

If panel is of type

func (Panel) IsPartialWidth

func (p Panel) IsPartialWidth() bool

If panel has width less than total allowable width

func (Panel) IsSingleStat

func (p Panel) IsSingleStat() bool

Is panel single stat?

func (Panel) Width

func (p Panel) Width() float64

Get panel width

type PanelType

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

type Report

type Report interface {
	Generate() ([]byte, error)
	Title() string
	Clean()
}

Report groups functions related to genrating the report. After reading and closing the pdf returned by Generate(), call Clean() to delete the pdf file as well the temporary build files

func NewReport

func NewReport(logger log.Logger, client GrafanaClient, config *ReportConfig) (Report, error)

New creates a new Report.

type ReportConfig

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

Report config

func (ReportConfig) From

func (c ReportConfig) From() string

Get from time string

func (ReportConfig) IsGridLayout

func (c ReportConfig) IsGridLayout() bool

Is layout grid?

func (ReportConfig) IsLandscapeOrientation

func (c ReportConfig) IsLandscapeOrientation() bool

Is orientation landscape?

func (c ReportConfig) Logo() string

Get logo

func (ReportConfig) To

func (c ReportConfig) To() string

Get to time string

type RowOrPanel added in v1.0.0

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

Row represents a container for Panels

type Secrets added in v1.3.0

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

Plugin secret settings

type TimeRange

type TimeRange struct {
	From string
	To   string
}

func NewTimeRange

func NewTimeRange(from, to string) TimeRange

Make new TimeRange struct

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