minisdk

package
v0.0.0-...-5d73d95 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package minisdk contains a minified version of the model found in github.com/grafana-tools/sdk. Most of the model parts were stripped of to reduce the unmarshaling issues caused by model evolution, as our objective is to just find the queries contained in the dashboards.

This model could now be probably simplified, but it's left in a form compatible with the original model, so it would be easier to switch back if that's ever fixed.

Index

Constants

View Source
const (
	CustomType panelType = iota
	DashlistType
	GraphType
	TableType
	TextType
	PluginlistType
	AlertlistType
	SinglestatType
	StatType
	RowType
	BarGaugeType
	HeatmapType
	TimeseriesType
	GaugeType
)

Each panel may be one of these types.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertlistPanel

type AlertlistPanel struct{}

type Annotation

type Annotation struct {
	Name       string         `json:"name"`
	Datasource *DatasourceRef `json:"datasource"`
	Query      string         `json:"query"`
	Expr       string         `json:"expr"`
	Type       string         `json:"type"`
}

type BarGaugePanel

type BarGaugePanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type Board

type Board struct {
	ID          uint       `json:"id,omitempty"`
	UID         string     `json:"uid,omitempty"`
	Slug        string     `json:"slug"`
	Title       string     `json:"title"`
	Tags        []string   `json:"tags"`
	Panels      []*Panel   `json:"panels"`
	Rows        []*Row     `json:"rows"`
	Templating  Templating `json:"templating"`
	Annotations struct {
		List []Annotation `json:"list"`
	} `json:"annotations"`
}

Board represents Grafana dashboard.

type BoolInt

type BoolInt struct {
	Flag  bool
	Value *int64
}

func (BoolInt) MarshalJSON

func (s BoolInt) MarshalJSON() ([]byte, error)

func (*BoolInt) UnmarshalJSON

func (s *BoolInt) UnmarshalJSON(raw []byte) error

type CommonPanel

type CommonPanel struct {
	Datasource *DatasourceRef `json:"datasource,omitempty"` // metrics
	ID         uint           `json:"id"`
	OfType     panelType      `json:"-"`     // it required for defining type of the panel
	Title      string         `json:"title"` // general
	Type       string         `json:"type"`
}

type CustomPanel

type CustomPanel map[string]interface{}

type DashlistPanel

type DashlistPanel struct{}

type DatasourceRef

type DatasourceRef struct {
	// Type describes the type of the datasource, like "prometheus", "graphite", etc.
	// Datasources of the same type should support same queries.
	// If Type is empty in an unmarshaled DatasourceRef, check the LegacyName field.
	Type string `json:"type"`
	// UID is the uid of the specific datasource this references to.
	UID string `json:"UID"`
	// LegacyName is the old way of referencing a datasource by its name, replaced in Grafana v8.4.3 by Type and UID referencing.
	// If datasource is encoded as a string, then it's unmarshaled into this LegacyName field (Type and UID will be empty).
	// If LegacyName is not empty, then this DatasourceRef will be marshaled as a string, ignoring the values of Type and UID.
	LegacyName string `json:"-"`
}

DatasourceRef is used to reference a datasource from panels, queries, etc.

func (DatasourceRef) MarshalJSON

func (ref DatasourceRef) MarshalJSON() ([]byte, error)

func (*DatasourceRef) UnmarshalJSON

func (ref *DatasourceRef) UnmarshalJSON(data []byte) error

type GaugePanel

type GaugePanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type GraphPanel

type GraphPanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type HeatmapPanel

type HeatmapPanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type Panel

type Panel struct {
	CommonPanel
	// Should be initialized only one type of panels.
	// OfType field defines which of types below will be used.
	*GraphPanel
	*TablePanel
	*TextPanel
	*SinglestatPanel
	*StatPanel
	*DashlistPanel
	*PluginlistPanel
	*RowPanel
	*AlertlistPanel
	*BarGaugePanel
	*HeatmapPanel
	*TimeseriesPanel
	*GaugePanel
	*CustomPanel
}

Panel represents panels of different types defined in Grafana.

func (*Panel) GetTargets

func (p *Panel) GetTargets() *[]Target

GetTargets is iterate over all panel targets. It just returns nil if no targets defined for panel of concrete type.

func (*Panel) UnmarshalJSON

func (p *Panel) UnmarshalJSON(b []byte) (err error)

type PluginlistPanel

type PluginlistPanel struct{}

type Row

type Row struct {
	Panels []Panel `json:"panels"`
}

Row represents single row of Grafana dashboard.

type RowPanel

type RowPanel struct {
	Panels []Panel `json:"panels"`
}

type SinglestatPanel

type SinglestatPanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type StatPanel

type StatPanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type TablePanel

type TablePanel struct {
	Targets []Target `json:"targets,omitempty"`
}

type Target

type Target struct {
	Datasource *DatasourceRef `json:"datasource,omitempty"`
	Expr       string         `json:"expr,omitempty"`
}

for an any panel

type TemplateVar

type TemplateVar struct {
	Name       string         `json:"name"`
	Type       string         `json:"type"`
	Datasource *DatasourceRef `json:"datasource"`
	Refresh    BoolInt        `json:"refresh"`
	Query      interface{}    `json:"query"`
}

type Templating

type Templating struct {
	List []TemplateVar `json:"list"`
}

type TextPanel

type TextPanel struct{}

type TimeseriesPanel

type TimeseriesPanel struct {
	Targets []Target `json:"targets,omitempty"`
}

Jump to

Keyboard shortcuts

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