grafana

package
v0.0.0-...-d5751c4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a Grafana API client.

func New

func New(options *Options) (*Client, error)

func (*Client) Dashboard

func (c *Client) Dashboard(ctx context.Context, opts entity.DashboardOpts) (*Dashboard, error)

Dashboard get and create Dashboard struct from Grafana internal JSON dashboard definition

func (*Client) Request

func (c *Client) Request(ctx context.Context, requestMethod, requestPath string, requestPayload any, responseStruct any) error

type Dashboard

type Dashboard struct {
	FolderID int64          `json:"folderId"`
	Meta     DashboardMeta  `json:"meta"` // read-only
	Model    DashboardModel `json:"dashboard"`
}

Dashboard represents a Grafana dashboard.

type DashboardMeta

type DashboardMeta struct {
	IsStarred bool   `json:"isStarred"`
	Slug      string `json:"slug"`
	Folder    int64  `json:"folderId"`
	FolderUID string `json:"folderUid"`
	URL       string `json:"url"`
}

type DashboardModel

type DashboardModel struct {
	Uid      string  `json:"uid"`
	Title    string  `json:"title"`
	Time     Time    `json:"time"`
	Timezone string  `json:"timezone"`
	Panels   []Panel `json:"panels"`
}

type Datasource

type Datasource struct {
	Type string `json:"type"`
	Uid  string `json:"uid"`
}

type GridPos

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

type Options

type Options struct {
	URL                *url.URL
	InsecureSkipVerify bool

	RetryNum         int
	RetryTimeout     time.Duration
	RetryStatusCodes []string

	APIToken             string
	BasicAuthCredentials string
}

type Panel

type Panel struct {
	Id         int            `json:"id"`
	Title      string         `json:"title"`
	Type       string         `json:"type"`
	GridPos    GridPos        `json:"gridPos"`
	Datasource Datasource     `json:"datasource"`
	Targets    []PanelTargets `json:"targets"`
}

func (Panel) Height

func (p Panel) Height() int

func (Panel) Is

func (p Panel) Is(t PanelType) bool

func (Panel) IsTable

func (p Panel) IsTable() bool

func (Panel) Width

func (p Panel) Width() int

func (Panel) X

func (p Panel) X() int

func (Panel) Y

func (p Panel) Y() int

type PanelTargets

type PanelTargets struct {
	Datasource Datasource `json:"datasource"`
	QueryType  string     `json:"queryType"`
	RefId      string     `json:"refId"`
}

type PanelType

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

type RowPanels

type RowPanels struct {
	Id        int     `json:"id"`
	Title     string  `json:"title"`
	Type      string  `json:"type"`
	Collapsed bool    `json:"collapsed"`
	GridPos   GridPos `json:"gridPos"`
	Panels    []Panel `json:"panels"`
}

RowPanels represents a container for Panels

type Time

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

Jump to

Keyboard shortcuts

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