grafana

package
v0.0.0-...-9480115 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScaleDistributionTypeLinear ScaleDistributionType = "linear"
	StackingModeNone            StackingMode          = "none"
)
View Source
const (
	TargetFormatTimeSeries = "time_series"
	TargetFormatHeatmap    = "heatmap"
)
View Source
const (
	DatasourceTypePrometheus = "prometheus"
)
View Source
const (
	DrawStyle = "drawStyle"
)
View Source
const SchemaVersion = 37

Variables

View Source
var (
	DefaultGrid = &GridPos{
		H: 8,
		W: 12,
	}
	DefaultColorMod  = "palette-classic"
	DefaultDrawStyle = "line"
)

Functions

This section is empty.

Types

type Annotations

type Annotations struct {
	List []interface{} `json:"list,omitempty" yaml:"list"`
}

type Client

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

func NewClient

func NewClient(baseUrl string, token string) *Client

func (*Client) CreateLibraryPanel

func (c *Client) CreateLibraryPanel(panel *Panel, folderUID string) (*PanelLibraryResponse, error)

func (*Client) DeleteLibraryPanel

func (c *Client) DeleteLibraryPanel(uid string) (int64, error)

func (*Client) GetLibraryPanelByUID

func (c *Client) GetLibraryPanelByUID(uid string) (*PanelLibraryResponse, error)

func (*Client) SaveDashboard

func (c *Client) SaveDashboard(d *Dashboard) error

func (*Client) SaveLibraryPanel

func (c *Client) SaveLibraryPanel(panel *Panel, folderUID string) (*PanelLibraryResponse, error)

func (*Client) UpdateLibraryPanel

func (c *Client) UpdateLibraryPanel(panel *Panel, id int, version int, folderUID string) (*PanelLibraryResponse, error)

type Current

type Current struct {
	Tags  []interface{} `json:"tags,omitempty" yaml:"tags"`
	Text  string        `json:"text,omitempty" yaml:"text"`
	Value string        `json:"value,omitempty" yaml:"value"`
}

type Dashboard

type Dashboard struct {
	ID            int64         `json:"id,omitempty" yaml:"id"`
	UID           string        `json:"uid,omitempty" yaml:"uid"`
	Title         string        `json:"title,omitempty" yaml:"title"`
	Tags          []string      `json:"tags,omitempty" yaml:"tags"`
	Style         string        `json:"style,omitempty" yaml:"style"`
	Timezone      string        `json:"timezone,omitempty" yaml:"timezone"`
	Editable      bool          `json:"editable,omitempty" yaml:"editable"`
	GraphTooltip  int           `json:"graphTooltip,omitempty" yaml:"graphTooltip"`
	Panels        []*Panel      `json:"panels,omitempty" yaml:"panels"`
	Time          *Time         `json:"time,omitempty" yaml:"time"`
	Timepicker    *Timepicker   `json:"timepicker,omitempty" yaml:"timepicker"`
	Templating    *Templating   `json:"templating,omitempty" yaml:"templating"`
	Annotations   *Annotations  `json:"annotations,omitempty" yaml:"annotations"`
	Refresh       string        `json:"refresh,omitempty" yaml:"refresh"`
	SchemaVersion int           `json:"schemaVersion,omitempty" yaml:"schemaVersion"`
	Version       int           `json:"version,omitempty" yaml:"version"`
	Links         []interface{} `json:"links,omitempty" yaml:"links"`
}

func NewDashboard

func NewDashboard(title string) *Dashboard

func (*Dashboard) AddPanel

func (d *Dashboard) AddPanel(p *Panel) *Dashboard

type DashboardOptions

type DashboardOptions struct {
	Selected bool   `json:"selected,omitempty" yaml:"selected"`
	Text     string `json:"text,omitempty" yaml:"text"`
	Value    string `json:"value,omitempty" yaml:"value"`
}

type Datasource

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

func NewDatasource

func NewDatasource(dsType string, uid string) *Datasource

func (Datasource) NewTarget

func (d Datasource) NewTarget(expr, legend string) *Target

type DatasourceType

type DatasourceType string

type FieldConfig

type FieldConfig struct {
	Defaults  PanelDefaults `json:"defaults,omitempty" yaml:"defaults"`
	Overrides []any         `json:"overrides,omitempty" yaml:"overrides"`
}

type GetLibraryPanelsResponse

type GetLibraryPanelsResponse struct {
	Result struct {
		TotalCount int           `json:"totalCount"`
		Elements   []interface{} `json:"elements"`
		Page       int           `json:"page"`
		PerPage    int           `json:"perPage"`
	} `json:"result"`
}

type GridPos

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

type LibraryPanel

type LibraryPanel struct {
	Name string `json:"name" yaml:"name"`
	Uid  string `json:"uid" yaml:"uid"`
}

type Panel

type Panel struct {
	ID          int       `json:"id,omitempty" yaml:"id"`
	UID         string    `json:"uid,omitempty" yaml:"uid"`
	Type        PanelType `json:"type,omitempty" yaml:"type"`
	Title       string    `json:"title,omitempty" yaml:"title"`
	Description string    `json:"description,omitempty" yaml:"description"`
	GridPos     *GridPos  `json:"gridPos,omitempty" yaml:"gridPos"`

	Repeat          string `json:"repeat,omitempty" yaml:"repeat"`
	RepeatDirection string `json:"repeatDirection,omitempty" yaml:"repeatDirection"`
	MaxPerRow       int    `json:"maxPerRow,omitempty" yaml:"maxPerRow"`

	Mode        string         `json:"mode,omitempty" yaml:"mode"`
	Content     string         `json:"content,omitempty" yaml:"content"`
	Targets     []*Target      `json:"targets,omitempty" yaml:"targets"`
	Options     map[string]any `json:"options,omitempty" yaml:"options"`
	FieldConfig FieldConfig    `json:"fieldConfig,omitempty" yaml:"fieldConfig"`
	Datasource  Datasource     `json:"datasource,omitempty" yaml:"datasource"`
}

func NewPanel

func NewPanel(panelType PanelType, title string) *Panel

func NewRowPanel

func NewRowPanel(title string) *Panel

func (*Panel) AddTarget

func (p *Panel) AddTarget(target *Target) *Panel

func (*Panel) SetSize

func (p *Panel) SetSize(h, w, x, y int)

type PanelColor

type PanelColor struct {
	Mode string `json:"mode" yaml:"mode"`
}

type PanelCustom

type PanelCustom map[string]any

func (PanelCustom) SetAxisCenteredZero

func (c PanelCustom) SetAxisCenteredZero(val bool) PanelCustom

func (PanelCustom) SetAxisColorMode

func (c PanelCustom) SetAxisColorMode(val string) PanelCustom

func (PanelCustom) SetAxisPlacement

func (c PanelCustom) SetAxisPlacement(val string) PanelCustom

func (PanelCustom) SetBarAlignment

func (c PanelCustom) SetBarAlignment(val int) PanelCustom

func (PanelCustom) SetDrawStyle

func (c PanelCustom) SetDrawStyle(val string) PanelCustom

func (PanelCustom) SetFillOpacity

func (c PanelCustom) SetFillOpacity(val int) PanelCustom

func (PanelCustom) SetGradientMode

func (c PanelCustom) SetGradientMode(val string) PanelCustom

func (PanelCustom) SetLineInterpolation

func (c PanelCustom) SetLineInterpolation(val string) PanelCustom

func (PanelCustom) SetLineWidth

func (c PanelCustom) SetLineWidth(val int) PanelCustom

func (PanelCustom) SetPointSize

func (c PanelCustom) SetPointSize(val int) PanelCustom

func (PanelCustom) SetScaleDistribution

func (c PanelCustom) SetScaleDistribution(val ScaleDistributionType) PanelCustom

func (PanelCustom) SetShowPoints

func (c PanelCustom) SetShowPoints(val string) PanelCustom

func (PanelCustom) SetSpanNulls

func (c PanelCustom) SetSpanNulls(val bool) PanelCustom

func (PanelCustom) SetStacking

func (c PanelCustom) SetStacking(val StackingMode) PanelCustom

type PanelDefaults

type PanelDefaults struct {
	Color  PanelColor  `json:"color,omitempty" yaml:"color"`
	Custom PanelCustom `json:"custom,omitempty" yaml:"custom"`
	Unit   string      `json:"unit,omitempty" yaml:"unit"`
}

type PanelLegend

type PanelLegend struct {
	Calcs       []string `json:"calcs,omitempty" yaml:"calcs"`
	DisplayMode string   `json:"displayMode,omitempty" yaml:"displayMode"`
	Placement   string   `json:"placement,omitempty" yaml:"placement"`
	ShowLegend  bool     `json:"showLegend,omitempty" yaml:"showLegend"`
}

type PanelLibraryResponse

type PanelLibraryResponse struct {
	Result struct {
		Id          int    `json:"id"`
		OrgId       int    `json:"orgId"`
		FolderId    int    `json:"folderId"`
		FolderUid   string `json:"folderUid"`
		Uid         string `json:"uid"`
		Name        string `json:"name"`
		Kind        int    `json:"kind"`
		Type        string `json:"type"`
		Description string `json:"description"`
		Model       any    `json:"model"`
		Version     int    `json:"version"`
		Meta        struct {
			FolderName          string    `json:"folderName"`
			FolderUid           string    `json:"folderUid"`
			ConnectedDashboards int       `json:"connectedDashboards"`
			Created             time.Time `json:"created"`
			Updated             time.Time `json:"updated"`
			CreatedBy           struct {
				Id        int    `json:"id"`
				Name      string `json:"name"`
				AvatarUrl string `json:"avatarUrl"`
			} `json:"createdBy"`
			UpdatedBy struct {
				Id        int    `json:"id"`
				Name      string `json:"name"`
				AvatarUrl string `json:"avatarUrl"`
			} `json:"updatedBy"`
		} `json:"meta"`
	} `json:"result"`
}

type PanelOptions

type PanelOptions struct {
	Legend  PanelLegend  `json:"legend,omitempty" yaml:"legend"`
	Tooltip PanelTooltip `json:"tooltip,omitempty" yaml:"tooltip"`
}

type PanelTooltip

type PanelTooltip struct {
	Mode string `json:"mode,omitempty" yaml:"mode"`
	Sort string `json:"sort,omitempty" yaml:"sort"`
}

type PanelType

type PanelType string
const (
	PanelTypeRow        PanelType = "row"
	PanelTypeBarchart   PanelType = "barchart"
	PanelTypeTimeseries PanelType = "timeseries"
)

type Panels

type Panels struct {
	Datasource struct {
		Type string `json:"type"`
		Uid  string `json:"uid"`
	} `json:"datasource"`
	Description string `json:"description"`
	FieldConfig struct {
		Defaults struct {
			Color struct {
				Mode string `json:"mode"`
			} `json:"color"`
			Custom struct {
				AxisCenteredZero bool   `json:"axisCenteredZero"`
				AxisColorMode    string `json:"axisColorMode"`
				AxisLabel        string `json:"axisLabel"`
				AxisPlacement    string `json:"axisPlacement"`
				BarAlignment     int    `json:"barAlignment"`
				DrawStyle        string `json:"DrawStyle"`
				FillOpacity      int    `json:"fillOpacity"`
				GradientMode     string `json:"gradientMode"`
				HideFrom         struct {
					Legend  bool `json:"legend"`
					Tooltip bool `json:"tooltip"`
					Viz     bool `json:"viz"`
				} `json:"hideFrom"`
				LineInterpolation string `json:"lineInterpolation"`
				LineWidth         int    `json:"lineWidth"`
				PointSize         int    `json:"pointSize"`
				ScaleDistribution struct {
					Type string `json:"type"`
				} `json:"scaleDistribution"`
				ShowPoints string `json:"showPoints"`
				SpanNulls  bool   `json:"spanNulls"`
				Stacking   struct {
					Group string `json:"group"`
					Mode  string `json:"mode"`
				} `json:"stacking"`
				ThresholdsStyle struct {
					Mode string `json:"mode"`
				} `json:"thresholdsStyle"`
			} `json:"custom"`
			Mappings   []interface{} `json:"mappings"`
			Thresholds struct {
				Mode  string `json:"mode"`
				Steps []struct {
					Color string `json:"color"`
					Value *int   `json:"value"`
				} `json:"steps"`
			} `json:"thresholds"`
		} `json:"defaults"`
		Overrides []interface{} `json:"overrides"`
	} `json:"fieldConfig"`
	GridPos struct {
		H int `json:"h"`
		W int `json:"w"`
		X int `json:"x"`
		Y int `json:"y"`
	} `json:"gridPos"`
	Id           int `json:"id"`
	LibraryPanel struct {
		Name string `json:"name"`
		Uid  string `json:"uid"`
	} `json:"libraryPanel"`
	Options struct {
		Legend struct {
			Calcs       []interface{} `json:"calcs"`
			DisplayMode string        `json:"displayMode"`
			Placement   string        `json:"placement"`
			ShowLegend  bool          `json:"showLegend"`
		} `json:"legend"`
		Tooltip struct {
			Mode string `json:"mode"`
			Sort string `json:"sort"`
		} `json:"tooltip"`
	} `json:"options"`
	Targets []struct {
		Datasource struct {
			Type string `json:"type"`
			Uid  string `json:"uid"`
		} `json:"datasource"`
		EditorMode   string `json:"editorMode"`
		Expr         string `json:"expr"`
		LegendFormat string `json:"legendFormat"`
		Range        bool   `json:"range"`
		RefId        string `json:"refId"`
	} `json:"targets"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type SaveDashboardRequest

type SaveDashboardRequest struct {
	Dashboard *Dashboard `json:"dashboard,omitempty" yaml:"dashboard"`
	FolderId  int        `json:"folderId,omitempty" yaml:"folderId"`
	Message   string     `json:"message,omitempty" yaml:"message"`
	Overwrite bool       `json:"overwrite,omitempty" yaml:"overwrite"`
}

type SaveDashboardResponse

type SaveDashboardResponse struct {
	Id      int    `json:"id" yaml:"id"`
	Slug    string `json:"slug" yaml:"slug"`
	Status  string `json:"status" yaml:"status"`
	Uid     string `json:"uid" yaml:"uid"`
	Url     string `json:"url" yaml:"url"`
	Version int    `json:"version" yaml:"version"`
}

type SaveLibraryPanelRequest

type SaveLibraryPanelRequest struct {
	Uid       string `json:"uid,omitempty"`
	FolderUid string `json:"folderUid,omitempty"`
	Name      string `json:"name,omitempty"`
	Model     any    `json:"model,omitempty"`
	Kind      int    `json:"kind,omitempty"`
	Version   int    `json:"version,omitempty"`
}

type ScaleDistributionType

type ScaleDistributionType string

type StackingMode

type StackingMode string

type Target

type Target struct {
	Datasource   Datasource   `json:"datasource" yaml:"datasource"`
	EditorMode   string       `json:"editorMode" yaml:"editorMode"`
	Expr         string       `json:"expr" yaml:"expr"`
	LegendFormat string       `json:"legendFormat" yaml:"legendFormat"`
	Format       TargetFormat `json:"format,omitempty" yaml:"format"`
	Range        bool         `json:"range" yaml:"range"`
	RefId        string       `json:"refId" yaml:"refId"`
}

type TargetFormat

type TargetFormat string

type Templating

type Templating struct {
	Enable bool       `json:"enable,omitempty" yaml:"enable"`
	List   []Variable `json:"list,omitempty" yaml:"list"`
}

type Time

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

type Timepicker

type Timepicker struct {
	TimeOptions      []interface{} `json:"time_options,omitempty" yaml:"time_options"`
	RefreshIntervals []string      `json:"refresh_intervals,omitempty" yaml:"refresh_intervals"`
	Collapse         bool          `json:"collapse,omitempty" yaml:"collapse"`
	Enable           bool          `json:"enable,omitempty" yaml:"enable"`
	Notice           bool          `json:"notice,omitempty" yaml:"notice"`
	Now              bool          `json:"now,omitempty" yaml:"now"`
	Status           string        `json:"status,omitempty" yaml:"status"`
	Type             string        `json:"type,omitempty" yaml:"type"`
}

type UnitType

type UnitType string
const (
	UnitTypeShort   UnitType = "short"
	UnitTypeBytes   UnitType = "bytes"
	UnitTypeSeconds UnitType = "s"
)

type Variable

type Variable struct {
	AllFormat   string             `json:"allFormat,omitempty" yaml:"allFormat"`
	Current     Current            `json:"current,omitempty" yaml:"current"`
	Datasource  interface{}        `json:"datasource,omitempty" yaml:"datasource"`
	IncludeAll  bool               `json:"includeAll,omitempty" yaml:"includeAll"`
	Name        string             `json:"name,omitempty" yaml:"name"`
	Options     []DashboardOptions `json:"options,omitempty" yaml:"options"`
	Query       string             `json:"query,omitempty" yaml:"query"`
	Refresh     bool               `json:"refresh,omitempty" yaml:"refresh"`
	Type        string             `json:"type,omitempty" yaml:"type"`
	Multi       bool               `json:"multi,omitempty" yaml:"multi"`
	MultiFormat string             `json:"multiFormat,omitempty" yaml:"multiFormat"`
	Regex       string             `json:"regex,omitempty" yaml:"regex"`
}

Jump to

Keyboard shortcuts

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