sdk

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 51

README

Grafana SDK Go Report Card

SDK for Go language offers a library for interacting with Grafana server from Go applications. It realizes many of HTTP REST API calls for administration, client, organizations. Beside of them it allows creating of Grafana objects (dashboards, panels, datasources) locally and manipulating them for constructing dashboards programmatically. It would be helpful for massive operations on a large set of Grafana objects.

It was made foremost for autograf project but later separated from it and moved to this new repository because the library is useful per se.

Library design principles

  1. SDK offers client functionality so it covers Grafana REST API with its requests and responses as close as possible.
  2. SDK maps Grafana objects (dashboard, row, panel, datasource) to similar Go structures but not follows exactly all Grafana abstractions.
  3. It doesn't use any logger, instead API functions could return errors where it need.
  4. Prefere no external deps except Go stdlib.
  5. Cover SDK calls with unit tests.

See also

  • grafana-foundation-sdk: A set of tools, types and libraries for building and manipulating Grafana objects – built by Grafana Labs
  • grabana: User-friendly Go library for building Grafana dashboards
  • dark: (grafana) Dashboards As Resources in Kubernetes

Examples GoDoc

	board := sdk.NewBoard("Sample dashboard title")
	board.ID = 1
	board.Time.From = "now-30m"
	board.Time.To = "now"
	row1 := board.AddRow("Sample row title")
	row1.Add(sdk.NewGraph("Sample graph"))
	graph := sdk.NewGraph("Sample graph 2")
	target := sdk.Target{
		RefID:      "A",
		Datasource: "Sample Source 1",
		Expr:       "sample request 1"}
	graph.AddTarget(&target)
	row1.Add(graph)
	grafanaURL := "http://grafana.host"
	c := sdk.NewClient(grafanaURL, "grafana-api-key", sdk.DefaultHTTPClient)
	response, err := c.SetDashboard(context.TODO() ,*board, sdk.SetDashboardParams{
		Overwrite: false,
	})
	if err != nil {
		fmt.Printf("error on uploading dashboard %s", board.Title)
	} else {
		fmt.Printf("dashboard URL: %v", grafanaURL+*response.URL)
	}

The library includes several demo apps for showing API usage:

You need Grafana API key with admin rights for using these utilities.

Installation Build Status

Of course Go development environment should be set up first. Then:

go get github.com/anil-appface/sdk

Dependency packages have included into distro. govendor utility used for vendoring. The single dependency now is:

go get github.com/gosimple/slug

The "slugify" for URLs is a simple task but this package used in Grafana server so it used in the SDK for the compatibility reasons.

Status of REST API realization Coverage Status

Work on full API implementation still in progress. Currently implemented only create/update/delete operations for dashboards and datasources. State of support for misc API parts noted below.

API Status
Authorization API tokens and Basic Auth
Annotations partially
Dashboards partially
Datasources +
Alert notification channels +
Organization (current) partially
Organizations partially
Users partially
User (actual) partially
Snapshots partially
Frontend settings -
Admin partially

There is no exact roadmap. The integration tests are being run against the following Grafana versions:

With the following Go versions:

  • 1.14.x
  • 1.13.x
  • 1.12.x
  • 1.11.x

I still have interest to this library development but not always have time for it. So I gladly accept new contributions. Drop an issue or contact me.

Licence

Distributed under Apache v2.0. All rights belong to the SDK authors. There is no authors list yet, you can see the full list of the contributors in the git history. Official repository is https://github.com/anil-appface/sdk

Collection of Grafana tools in Golang

Documentation

Index

Constants

View Source
const (
	TemplatingHideNone = iota
	TemplatingHideLabel
	TemplatingHideVariable
)

Constants for templating

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

Each panel may be one of these types.

View Source
const MixedSource = "-- Mixed --"

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Name     string      `json:"name"`
	Interval string      `json:"interval"`
	Rules    []AlertRule `json:"rules"`
}

type AlertCondition

type AlertCondition struct {
	Type      string                 `json:"type,omitempty"`
	Evaluator AlertEvaluator         `json:"evaluator,omitempty"`
	Operator  AlertOperator          `json:"operator,omitempty"`
	Query     AlertConditionQueryRef `json:"query,omitempty"`
	Reducer   AlertReducer           `json:"reducer,omitempty"`
}

type AlertConditionQueryRef

type AlertConditionQueryRef struct {
	Params []string `json:"params,omitempty"`
}

type AlertDatasourceRef

type AlertDatasourceRef struct {
	UID  string `json:"uid"`
	Type string `json:"type"`
}

type AlertEvaluator

type AlertEvaluator struct {
	Params []float64 `json:"params,omitempty"`
	Type   string    `json:"type,omitempty"`
}

type AlertManager

type AlertManager struct {
	Config        AlertManagerConfig `json:"alertmanager_config"`
	TemplateFiles MessageTemplate    `json:"template_files"`
}

type AlertManagerConfig

type AlertManagerConfig struct {
	Receivers []ContactPoint       `json:"receivers"`
	Route     NotificationPolicies `json:"route"`
	Templates []string             `json:"templates"`
}

type AlertModel

type AlertModel struct {
	RefID        string             `json:"refId,omitempty"`
	QueryType    string             `json:"queryType,omitempty"`
	Type         string             `json:"type,omitempty"`
	Expr         string             `json:"expr,omitempty"`
	Format       string             `json:"format,omitempty"`
	LegendFormat string             `json:"legendFormat,omitempty"`
	Datasource   AlertDatasourceRef `json:"datasource"`
	Interval     string             `json:"interval,omitempty"`
	IntervalMs   int                `json:"intervalMs,omitempty"`
	Hide         *bool              `json:"hide,omitempty"`
	Conditions   []AlertCondition   `json:"conditions,omitempty"`

	// For Graphite
	Target string `json:"target,omitempty"`

	// For Stackdriver
	MetricQuery *StackdriverAlertQuery `json:"metricQuery,omitempty"`
}

type AlertObjectMatcher

type AlertObjectMatcher [3]string

type AlertOperator

type AlertOperator struct {
	Type string `json:"type,omitempty"`
}

type AlertQuery

type AlertQuery struct {
	RefID             string                  `json:"refId"`
	QueryType         string                  `json:"queryType"`
	RelativeTimeRange *AlertRelativeTimeRange `json:"relativeTimeRange,omitempty"`
	DatasourceUID     string                  `json:"datasourceUid"`
	Model             AlertModel              `json:"model"`
}

type AlertReducer

type AlertReducer struct {
	Params []string `json:"params,omitempty"`
	Type   string   `json:"type,omitempty"`
}

type AlertRelativeTimeRange

type AlertRelativeTimeRange struct {
	From int `json:"from"` // seconds
	To   int `json:"to"`   // seconds
}

type AlertRule

type AlertRule struct {
	For          string            `json:"for"`
	GrafanaAlert *GrafanaAlert     `json:"grafana_alert,omitempty"`
	Annotations  map[string]string `json:"annotations,omitempty"`
	Labels       map[string]string `json:"labels,omitempty"`
}

type AlertlistPanel

type AlertlistPanel struct {
	OnlyAlertsOnDashboard bool     `json:"onlyAlertsOnDashboard"`
	Show                  string   `json:"show"`
	SortOrder             int      `json:"sortOrder"`
	Limit                 int      `json:"limit"`
	StateFilter           []string `json:"stateFilter"`
	NameFilter            string   `json:"nameFilter,omitempty"`
	DashboardTags         []string `json:"dashboardTags,omitempty"`
}

type Annotation

type Annotation struct {
	Name        string         `json:"name"`
	Datasource  *DatasourceRef `json:"datasource"`
	ShowLine    bool           `json:"showLine"`
	IconColor   string         `json:"iconColor"`
	LineColor   string         `json:"lineColor"`
	IconSize    uint           `json:"iconSize"`
	Enable      bool           `json:"enable"`
	Query       string         `json:"query"`
	Expr        string         `json:"expr"`
	Step        string         `json:"step"`
	TextField   string         `json:"textField"`
	TextFormat  string         `json:"textFormat"`
	TitleFormat string         `json:"titleFormat"`
	TagsField   string         `json:"tagsField"`
	Tags        []string       `json:"tags"`
	TagKeys     string         `json:"tagKeys"`
	Type        string         `json:"type"`
}

type Axis

type Axis struct {
	Format   string       `json:"format"`
	LogBase  int          `json:"logBase"`
	Decimals int          `json:"decimals,omitempty"`
	Max      *FloatString `json:"max,omitempty"`
	Min      *FloatString `json:"min,omitempty"`
	Show     bool         `json:"show"`
	Label    string       `json:"label,omitempty"`
}

for a graph panel

type AzureLogAnalytics added in v1.0.1

type AzureLogAnalytics struct {
	DashboardTime bool     `json:"dashboardTime"`
	Query         string   `json:"query"`
	ResultFormat  string   `json:"resultFormat"`
	Resources     []string `json:"resources"`
	TimeColumn    string   `json:"timeColumn"`
}

type BarGaugePanel

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

type Board

type Board struct {
	ID              uint       `json:"id,omitempty"`
	UID             string     `json:"uid,omitempty"`
	Slug            string     `json:"slug"`
	Title           string     `json:"title"`
	OriginalTitle   string     `json:"originalTitle"`
	Tags            []string   `json:"tags"`
	Style           string     `json:"style"`
	Timezone        string     `json:"timezone"`
	Editable        bool       `json:"editable"`
	HideControls    bool       `json:"hideControls" graf:"hide-controls"`
	SharedCrosshair bool       `json:"sharedCrosshair" graf:"shared-crosshair"`
	Panels          []*Panel   `json:"panels"`
	Rows            []*Row     `json:"rows"`
	Templating      Templating `json:"templating"`
	Annotations     struct {
		List []Annotation `json:"list"`
	} `json:"annotations"`
	Refresh       *BoolString `json:"refresh,omitempty"`
	SchemaVersion uint        `json:"schemaVersion"`
	Version       uint        `json:"version"`
	Links         []Link      `json:"links"`
	Time          Time        `json:"time"`
	Timepicker    Timepicker  `json:"timepicker"`
	GraphTooltip  int         `json:"graphTooltip,omitempty"`
}

Board represents Grafana dashboard.

func NewBoard

func NewBoard(title string) *Board
func (b *Board) AddLink(link Link)

func (*Board) AddRow

func (b *Board) AddRow(title string) *Row

func (*Board) AddTags

func (b *Board) AddTags(tags ...string)

func (*Board) HasTag

func (b *Board) HasTag(tag string) bool

func (*Board) RemoveTags

func (b *Board) RemoveTags(tags ...string)

func (*Board) UpdateSlug

func (b *Board) UpdateSlug() string

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 BoolString

type BoolString struct {
	Flag  bool
	Value string
}

func (BoolString) MarshalJSON

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

func (*BoolString) UnmarshalJSON

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

type Column

type Column struct {
	TextType string `json:"text"`
	Value    string `json:"value"`
}

for a table

type ColumnStyle

type ColumnStyle struct {
	Alias           *string    `json:"alias"`
	DateFormat      *string    `json:"dateFormat,omitempty"`
	Pattern         string     `json:"pattern"`
	Type            string     `json:"type"`
	ColorMode       *string    `json:"colorMode,omitempty"`
	Colors          *[]string  `json:"colors,omitempty"`
	Decimals        *int       `json:"decimals,omitempty"`
	Thresholds      *[]string  `json:"thresholds,omitempty"`
	Unit            *string    `json:"unit,omitempty"`
	MappingType     int        `json:"mappingType,omitempty"`
	ValueMaps       []ValueMap `json:"valueMaps,omitempty"`
	Link            bool       `json:"link,omitempty"`
	LinkTooltip     *string    `json:"linkTooltip,omitempty"`
	LinkUrl         *string    `json:"linkUrl,omitempty"`
	LinkTargetBlank bool       `json:"linkTargetBlank,omitempty"`
}

for a table

type CommonPanel

type CommonPanel struct {
	Datasource *DatasourceRef `json:"datasource,omitempty"` // metrics
	Editable   bool           `json:"editable"`
	Error      bool           `json:"error"`
	GridPos    struct {
		H *int `json:"h,omitempty"`
		W *int `json:"w,omitempty"`
		X *int `json:"x,omitempty"`
		Y *int `json:"y,omitempty"`
	} `json:"gridPos,omitempty"`
	Height           interface{}      `json:"height,omitempty"` // general
	HideTimeOverride *bool            `json:"hideTimeOverride,omitempty"`
	ID               uint             `json:"id"`
	IsNew            bool             `json:"isNew"`
	Links            []Link           `json:"links,omitempty"`    // general
	MinSpan          *float32         `json:"minSpan,omitempty"`  // templating options
	OfType           panelType        `json:"-"`                  // it required for defining type of the panel
	Renderer         *string          `json:"renderer,omitempty"` // display styles
	Repeat           *string          `json:"repeat,omitempty"`   // templating options
	RepeatDirection  *RepeatDirection `json:"repeatDirection,omitempty"`

	// RepeatIteration *int64   `json:"repeatIteration,omitempty"`
	RepeatPanelID *uint `json:"repeatPanelId,omitempty"`
	ScopedVars    map[string]struct {
		Selected bool   `json:"selected"`
		Text     string `json:"text"`
		Value    string `json:"value"`
	} `json:"scopedVars,omitempty"`
	Span        float32 `json:"span"`                  // general
	Title       string  `json:"title"`                 // general
	Description *string `json:"description,omitempty"` // general
	Transparent bool    `json:"transparent"`
	Type        string  `json:"type"`
}

type ContactPoint

type ContactPoint struct {
	Name                    string             `json:"name"`
	GrafanaManagedReceivers []ContactPointType `json:"grafana_managed_receiver_configs,omitempty"`
}

type ContactPointType

type ContactPointType struct {
	UID                   string                 `json:"uid,omitempty"`
	Name                  string                 `json:"name"`
	Type                  string                 `json:"type"`
	DisableResolveMessage bool                   `json:"disableResolveMessage"`
	Settings              map[string]interface{} `json:"settings"`
	SecureSettings        map[string]interface{} `json:"secureSettings,omitempty"`
}

type Current

type Current struct {
	Tags  []*string          `json:"tags,omitempty"`
	Text  *StringSliceString `json:"text"`
	Value interface{}        `json:"value"` // TODO select more precise type
}

for templateVar

type CustomPanel

type CustomPanel map[string]interface{}

type DashlistPanel

type DashlistPanel struct {
	Mode     string   `json:"mode"`
	Query    string   `json:"query"`
	Tags     []string `json:"tags"`
	FolderID int      `json:"folderId"`
	Limit    int      `json:"limit"`
	Headings bool     `json:"headings"`
	Recent   bool     `json:"recent"`
	Search   bool     `json:"search"`
	Starred  bool     `json:"starred"`
}

type Datasource

type Datasource struct {
	ID                uint        `json:"id"`
	OrgID             uint        `json:"orgId"`
	Name              string      `json:"name"`
	Type              string      `json:"type"`
	Access            string      `json:"access"` // direct or proxy
	URL               string      `json:"url"`
	Password          *string     `json:"password,omitempty"`
	User              *string     `json:"user,omitempty"`
	Database          *string     `json:"database,omitempty"`
	BasicAuth         *bool       `json:"basicAuth,omitempty"`
	BasicAuthUser     *string     `json:"basicAuthUser,omitempty"`
	BasicAuthPassword *string     `json:"basicAuthPassword,omitempty"`
	WithCredentials   bool        `json:"withCredentials"`
	IsDefault         bool        `json:"isDefault"`
	JSONData          interface{} `json:"jsonData"`
	SecureJSONData    interface{} `json:"secureJsonData"`
}

Datasource as described in the doc http://docs.grafana.org/reference/http_api/#get-all-datasources

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 DatasourceType

type DatasourceType struct {
	Metrics  bool   `json:"metrics"`
	Module   string `json:"module"`
	Name     string `json:"name"`
	Partials struct {
		Query string `json:"query"`
	} `json:"datasource"`
	PluginType  string `json:"pluginType"`
	ServiceName string `json:"serviceName"`
	Type        string `json:"type"`
}

Datasource type as described in http://docs.grafana.org/reference/http_api/#available-data-source-types

type FieldConfig

type FieldConfig struct {
	Defaults  FieldConfigDefaults   `json:"defaults"`
	Overrides []FieldConfigOverride `json:"overrides"`
}

type FieldConfigColor

type FieldConfigColor struct {
	Mode       string `json:"mode"`
	FixedColor string `json:"fixedColor,omitempty"`
	SeriesBy   string `json:"seriesBy,omitempty"`
}

type FieldConfigCustom

type FieldConfigCustom struct {
	AxisLabel         string `json:"axisLabel,omitempty"`
	AxisPlacement     string `json:"axisPlacement"`
	AxisSoftMin       *int   `json:"axisSoftMin,omitempty"`
	AxisSoftMax       *int   `json:"axisSoftMax,omitempty"`
	BarAlignment      int    `json:"barAlignment"`
	DrawStyle         string `json:"drawStyle"`
	FillOpacity       int    `json:"fillOpacity"`
	GradientMode      string `json:"gradientMode"`
	LineInterpolation string `json:"lineInterpolation"`
	LineWidth         int    `json:"lineWidth"`
	PointSize         int    `json:"pointSize"`
	ShowPoints        string `json:"showPoints"`
	SpanNulls         bool   `json:"spanNulls"`
	HideFrom          struct {
		Legend  bool `json:"legend"`
		Tooltip bool `json:"tooltip"`
		Viz     bool `json:"viz"`
	} `json:"hideFrom"`
	LineStyle struct {
		Fill string `json:"fill"`
	} `json:"lineStyle"`
	ScaleDistribution struct {
		Type string `json:"type"`
		Log  int    `json:"log,omitempty"`
	} `json:"scaleDistribution"`
	Stacking struct {
		Group string `json:"group"`
		Mode  string `json:"mode"`
	} `json:"stacking"`
	ThresholdsStyle struct {
		Mode string `json:"mode"`
	} `json:"thresholdsStyle"`
}

type FieldConfigDefaults

type FieldConfigDefaults struct {
	Unit        string            `json:"unit"`
	NoValue     string            `json:"noValue,omitempty"`
	Decimals    *int              `json:"decimals,omitempty"`
	Min         *float64          `json:"min,omitempty"`
	Max         *float64          `json:"max,omitempty"`
	Color       FieldConfigColor  `json:"color"`
	Thresholds  Thresholds        `json:"thresholds"`
	Custom      FieldConfigCustom `json:"custom"`
	Links       []Link            `json:"links,omitempty"`
	DisplayName string            `json:"displayName,omitempty"`
}

type FieldConfigOverride

type FieldConfigOverride struct {
	Matcher struct {
		ID      string `json:"id"`
		Options string `json:"options"`
	} `json:"matcher"`
	Properties []FieldConfigOverrideProperty `json:"properties"`
}

type FieldConfigOverrideProperty

type FieldConfigOverrideProperty struct {
	ID    string      `json:"id"`
	Value interface{} `json:"value"`
}

type FloatString

type FloatString struct {
	Value float64
	Valid bool
}

FloatString represents special type for json values that could be strings or ints: 100 or "100"

func NewFloatString

func NewFloatString(i float64) *FloatString

func (*FloatString) MarshalJSON

func (v *FloatString) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshalling for FloatString type

func (*FloatString) UnmarshalJSON

func (v *FloatString) UnmarshalJSON(raw []byte) error

UnmarshalJSON implements custom unmarshalling for FloatString type

type GCMPromQLQuery

type GCMPromQLQuery struct {
	ProjectName string `json:"projectName,omitempty"`
	Expr        string `json:"expr,omitempty"`
	Step        string `json:"step,omitempty"`
}

type GCMSLOQuery

type GCMSLOQuery struct {
	ProjectName      string   `json:"projectName,omitempty"`
	AlignmentPeriod  string   `json:"alignmentPeriod,omitempty"`
	PerSeriesAligner string   `json:"perSeriesAligner,omitempty"`
	AliasBy          string   `json:"aliasBy,omitempty"`
	SelectorName     string   `json:"selectorName,omitempty"`
	ServiceID        string   `json:"serviceId,omitempty"`
	ServiceName      string   `json:"serviceName,omitempty"`
	SLOID            string   `json:"sloId,omitempty"`
	SLOName          string   `json:"sloName,omitempty"`
	LookbackPeriod   string   `json:"lookbackPeriod,omitempty"`
	Goal             *float64 `json:"goal,omitempty"`
}

type GCMTimeSeriesList

type GCMTimeSeriesList struct {
	ProjectName                 string   `json:"projectName"`
	CrossSeriesReducer          string   `json:"crossSeriesReducer,omitempty"`
	AlignmentPeriod             string   `json:"alignmentPeriod,omitempty"`
	PerSeriesAligner            string   `json:"perSeriesAligner,omitempty"`
	GroupBys                    []string `json:"groupBys,omitempty"`
	Filters                     []string `json:"filters,omitempty"`
	View                        string   `json:"view,omitempty"`
	Title                       string   `json:"title,omitempty"`
	Text                        string   `json:"text,omitempty"`
	SecondaryCrossSeriesReducer string   `json:"secondaryCrossSeriesReducer,omitempty"`
	SecondaryAlignmentPeriod    string   `json:"secondaryAlignmentPeriod,omitempty"`
	SecondaryPerSeriesAligner   string   `json:"secondaryPerSeriesAligner,omitempty"`
	SecondaryGroupBys           []string `json:"secondaryGroupBys,omitempty"`
	Preprocessor                string   `json:"preprocessor,omitempty"`
}

type GCMTimeSeriesQuery

type GCMTimeSeriesQuery struct {
	ProjectName string `json:"projectName,omitempty"`
	Query       string `json:"query,omitempty"`
	GraphPeriod string `json:"graphPeriod,omitempty"`
}

type Gauge

type Gauge struct {
	MaxValue         float32 `json:"maxValue"`
	MinValue         float32 `json:"minValue"`
	Show             bool    `json:"show"`
	ThresholdLabels  bool    `json:"thresholdLabels"`
	ThresholdMarkers bool    `json:"thresholdMarkers"`
}

for a stat

type GaugePanel

type GaugePanel struct {
	Targets     []Target    `json:"targets,omitempty"`
	Options     StatOptions `json:"options"`
	FieldConfig FieldConfig `json:"fieldConfig"`
}

type GrafanaAlert

type GrafanaAlert struct {
	Title               string       `json:"title"`
	Condition           string       `json:"condition"`
	NoDataState         string       `json:"no_data_state"`
	ExecutionErrorState string       `json:"exec_err_state,omitempty"`
	Data                []AlertQuery `json:"data"`
}

type GraphPanel

type GraphPanel struct {
	AliasColors interface{} `json:"aliasColors"` // XXX
	Bars        bool        `json:"bars"`
	DashLength  *uint       `json:"dashLength,omitempty"`
	Dashes      *bool       `json:"dashes,omitempty"`
	Decimals    *int        `json:"decimals,omitempty"`
	Fill        int         `json:"fill"`

	Legend          Legend           `json:"legend,omitempty"`
	LeftYAxisLabel  *string          `json:"leftYAxisLabel,omitempty"`
	Lines           bool             `json:"lines"`
	Linewidth       uint             `json:"linewidth"`
	NullPointMode   string           `json:"nullPointMode"`
	Percentage      bool             `json:"percentage"`
	Pointradius     float32          `json:"pointradius"`
	Points          bool             `json:"points"`
	RightYAxisLabel *string          `json:"rightYAxisLabel,omitempty"`
	SeriesOverrides []SeriesOverride `json:"seriesOverrides,omitempty"`
	SpaceLength     *uint            `json:"spaceLength,omitempty"`
	Stack           bool             `json:"stack"`
	SteppedLine     bool             `json:"steppedLine"`
	Targets         []Target         `json:"targets,omitempty"`
	Thresholds      []Threshold      `json:"thresholds,omitempty"`
	TimeFrom        *string          `json:"timeFrom,omitempty"`
	TimeShift       *string          `json:"timeShift,omitempty"`
	Tooltip         Tooltip          `json:"tooltip"`
	XAxis           bool             `json:"x-axis,omitempty"`
	YAxis           bool             `json:"y-axis,omitempty"`
	YFormats        []string         `json:"y_formats,omitempty"`
	Xaxis           Axis             `json:"xaxis"` // was added in Grafana 4.x?
	Yaxes           []Axis           `json:"yaxes"` // was added in Grafana 4.x?
	FieldConfig     *FieldConfig     `json:"fieldConfig,omitempty"`
}

type HeatmapPanel

type HeatmapPanel struct {
	Cards struct {
		CardPadding *float64 `json:"cardPadding"`
		CardRound   *float64 `json:"cardRound"`
	} `json:"cards"`
	Color struct {
		CardColor   string   `json:"cardColor"`
		ColorScale  string   `json:"colorScale"`
		ColorScheme string   `json:"colorScheme"`
		Exponent    float64  `json:"exponent"`
		Min         *float64 `json:"min,omitempty"`
		Max         *float64 `json:"max,omitempty"`
		Mode        string   `json:"mode"`
	} `json:"color"`
	DataFormat      string `json:"dataFormat"`
	HideZeroBuckets bool   `json:"hideZeroBuckets"`
	HighlightCards  bool   `json:"highlightCards"`
	Legend          struct {
		Show bool `json:"show"`
	} `json:"legend"`
	ReverseYBuckets bool     `json:"reverseYBuckets"`
	Targets         []Target `json:"targets,omitempty"`
	Tooltip         struct {
		Show          bool `json:"show"`
		ShowHistogram bool `json:"showHistogram"`
	} `json:"tooltip"`
	TooltipDecimals int `json:"tooltipDecimals"`
	XAxis           struct {
		Show bool `json:"show"`
	} `json:"xAxis"`
	XBucketNumber *float64 `json:"xBucketNumber"`
	XBucketSize   *string  `json:"xBucketSize"`
	YAxis         struct {
		Decimals    *int     `json:"decimals"`
		Format      string   `json:"format"`
		LogBase     int      `json:"logBase"`
		Show        bool     `json:"show"`
		Max         *string  `json:"max"`
		Min         *string  `json:"min"`
		SplitFactor *float64 `json:"splitFactor"`
	} `json:"yAxis"`
	YBucketBound  string   `json:"yBucketBound"`
	YBucketNumber *float64 `json:"yBucketNumber"`
	YBucketSize   *float64 `json:"yBucketSize"`
}

type Height

type Height string

Height of rows maybe passed as number (ex 200) or as string (ex "200px") or empty string

func (*Height) UnmarshalJSON

func (h *Height) UnmarshalJSON(raw []byte) error

type IntString

type IntString struct {
	Value int64
	Valid bool
}

IntString represents special type for json values that could be strings or ints: 100 or "100"

func NewIntString

func NewIntString(i int64) *IntString

func (*IntString) MarshalJSON

func (v *IntString) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshalling for IntString type

func (*IntString) UnmarshalJSON

func (v *IntString) UnmarshalJSON(raw []byte) error

UnmarshalJSON implements custom unmarshalling for IntString type

type Legend

type Legend struct {
	AlignAsTable bool  `json:"alignAsTable"`
	Avg          bool  `json:"avg"`
	Current      bool  `json:"current"`
	HideEmpty    bool  `json:"hideEmpty"`
	HideZero     bool  `json:"hideZero"`
	Max          bool  `json:"max"`
	Min          bool  `json:"min"`
	RightSide    bool  `json:"rightSide"`
	Show         bool  `json:"show"`
	SideWidth    *uint `json:"sideWidth,omitempty"`
	Total        bool  `json:"total"`
	Values       bool  `json:"values"`
}

for a graph panel

type Link struct {
	Title       string   `json:"title"`
	Type        string   `json:"type"`
	AsDropdown  *bool    `json:"asDropdown,omitempty"`
	DashURI     *string  `json:"dashUri,omitempty"`
	Dashboard   *string  `json:"dashboard,omitempty"`
	Icon        *string  `json:"icon,omitempty"`
	IncludeVars bool     `json:"includeVars"`
	KeepTime    *bool    `json:"keepTime,omitempty"`
	Params      *string  `json:"params,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	TargetBlank *bool    `json:"targetBlank,omitempty"`
	Tooltip     *string  `json:"tooltip,omitempty"`
	URL         *string  `json:"url,omitempty"`
}

Link represents link to another dashboard or external weblink

type LogsOptions

type LogsOptions struct {
	DedupStrategy      string `json:"dedupStrategy"`
	WrapLogMessage     bool   `json:"wrapLogMessage"`
	ShowTime           bool   `json:"showTime"`
	ShowLabels         bool   `json:"showLabels"`
	ShowCommonLabels   bool   `json:"showCommonLabels"`
	PrettifyLogMessage bool   `json:"prettifyLogMessage"`
	SortOrder          string `json:"sortOrder"`
	EnableLogDetails   bool   `json:"enableLogDetails"`
}

type LogsPanel

type LogsPanel struct {
	Targets []Target    `json:"targets,omitempty"`
	Options LogsOptions `json:"options,omitempty"`
}

type MapType

type MapType struct {
	Name  *string `json:"name,omitempty"`
	Value *int    `json:"value,omitempty"`
}

type MessageTemplate

type MessageTemplate map[string]string

Map of template name → template

type NotificationPolicies

type NotificationPolicies struct {
	// Default alert receiver
	Receiver string `json:"receiver"`

	// Default group bys
	GroupBy []string `json:"group_by,omitempty"`

	// Default timing settings
	GroupInterval  string `json:"group_interval,omitempty"`
	GroupWait      string `json:"group_wait,omitempty"`
	RepeatInterval string `json:"repeat_interval,omitempty"`

	// Routing policies
	Routes []NotificationRoutingPolicy `json:"routes,omitempty"`
}

type NotificationRoutingPolicy

type NotificationRoutingPolicy struct {
	// Alert receiver
	Receiver string `json:"receiver"`
	// Default timing settings overrides
	GroupInterval  string `json:"group_interval,omitempty"`
	GroupWait      string `json:"group_wait,omitempty"`
	RepeatInterval string `json:"repeat_interval,omitempty"`

	ObjectMatchers []AlertObjectMatcher `json:"object_matchers"`
}

type Option

type Option struct {
	Text     string `json:"text"`
	Value    string `json:"value"`
	Selected bool   `json:"selected"`
}

for templateVar

type Options

type Options struct {
	Orientation   string        `json:"orientation"`
	TextMode      string        `json:"textMode"`
	ColorMode     string        `json:"colorMode"`
	GraphMode     string        `json:"graphMode"`
	JustifyMode   string        `json:"justifyMode"`
	DisplayMode   string        `json:"displayMode"`
	Content       string        `json:"content"`
	Mode          string        `json:"mode"`
	ReduceOptions ReduceOptions `json:"reduceOptions"`
	Text          *TextOptions  `json:"text,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
	*LogsPanel
	*GaugePanel
	*CustomPanel
}

Panel represents panels of different types defined in Grafana.

func NewAlertlist

func NewAlertlist(title string) *Panel

func NewCustom

func NewCustom(title string) *Panel

NewCustom initializes panel with a stat panel.

func NewDashlist

func NewDashlist(title string) *Panel

NewDashlist initializes panel with a dashlist panel.

func NewGauge

func NewGauge(title string) *Panel

NewGauge initializes a new panel as a Gauge panel.

func NewGraph

func NewGraph(title string) *Panel

NewGraph initializes panel with a graph panel.

func NewHeatmap

func NewHeatmap(title string) *Panel

func NewLogs

func NewLogs(title string) *Panel

NewLogs initializes a new panel as a Logs panel.

func NewPluginlist

func NewPluginlist(title string) *Panel

NewPluginlist initializes panel with a stat panel.

func NewSinglestat

func NewSinglestat(title string) *Panel

NewSinglestat initializes panel with a singlestat panel.

func NewStat

func NewStat(title string) *Panel

NewStat initializes panel with a stat panel.

func NewTable

func NewTable(title string) *Panel

NewTable initializes panel with a table panel.

func NewText

func NewText(title string) *Panel

NewText initializes panel with a text panel.

func NewTimeseries

func NewTimeseries(title string) *Panel

NewTimeseries initializes panel with a timeseries panel.

func (*Panel) AddTarget

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

AddTarget adds a new target as defined in the argument but with refId letter incremented. Value of refID from the argument will be used only if no target with such value already exists.

func (*Panel) GetTargets

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

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

func (*Panel) MarshalJSON

func (p *Panel) MarshalJSON() ([]byte, error)

func (*Panel) RepeatDatasourcesForEachTarget

func (p *Panel) RepeatDatasourcesForEachTarget(dsNames ...string)

MapDatasources on all existing targets for the panel.

func (*Panel) RepeatTargetsForDatasources

func (p *Panel) RepeatTargetsForDatasources(dsNames ...string)

RepeatTargetsForDatasources repeats all existing targets for a panel for all provided in the argument datasources. Existing datasources of targets are ignored.

func (*Panel) ResetTargets

func (p *Panel) ResetTargets()

ResetTargets delete all targets defined for a panel.

func (*Panel) SetTarget

func (p *Panel) SetTarget(t *Target)

SetTarget updates a target if target with such refId exists or creates a new one.

func (*Panel) UnmarshalJSON

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

type PluginlistPanel

type PluginlistPanel struct {
	Limit int `json:"limit,omitempty"`
}

type RangeMap

type RangeMap struct {
	From *string `json:"from,omitempty"`
	Text *string `json:"text,omitempty"`
	To   *string `json:"to,omitempty"`
}

type ReduceOptions

type ReduceOptions struct {
	Values bool     `json:"values"`
	Fields string   `json:"fields"`
	Calcs  []string `json:"calcs"`
}

type RepeatDirection

type RepeatDirection string
const (
	RepeatDirectionVertical   RepeatDirection = "v"
	RepeatDirectionHorizontal RepeatDirection = "h"
)

type Row

type Row struct {
	Title     string  `json:"title"`
	ShowTitle bool    `json:"showTitle"`
	Collapse  bool    `json:"collapse"`
	Editable  bool    `json:"editable"`
	Height    Height  `json:"height"`
	Panels    []Panel `json:"panels"`
	Repeat    *string `json:"repeat"`
}

Row represents single row of Grafana dashboard.

func (*Row) Add

func (r *Row) Add(panel *Panel)

func (*Row) AddCustom

func (r *Row) AddCustom(data *CustomPanel)

func (*Row) AddDashlist

func (r *Row) AddDashlist(data *DashlistPanel)

func (*Row) AddGraph

func (r *Row) AddGraph(data *GraphPanel)

func (*Row) AddSinglestat

func (r *Row) AddSinglestat(data *SinglestatPanel)

func (*Row) AddStat

func (r *Row) AddStat(data *StatPanel)

func (*Row) AddTable

func (r *Row) AddTable(data *TablePanel)

func (*Row) AddText

func (r *Row) AddText(data *TextPanel)

type RowPanel

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

type SeriesOverride

type SeriesOverride struct {
	Alias         string      `json:"alias"`
	Bars          *bool       `json:"bars,omitempty"`
	Color         *string     `json:"color,omitempty"`
	Dashes        *bool       `json:"dashes,omitempty"`
	Fill          *int        `json:"fill,omitempty"`
	FillBelowTo   *string     `json:"fillBelowTo,omitempty"`
	Legend        *bool       `json:"legend,omitempty"`
	Lines         *bool       `json:"lines,omitempty"`
	LineWidth     *int        `json:"linewidth,omitempty"`
	Stack         *BoolString `json:"stack,omitempty"`
	Transform     *string     `json:"transform,omitempty"`
	YAxis         *int        `json:"yaxis,omitempty"`
	ZIndex        *int        `json:"zindex,omitempty"`
	NullPointMode *string     `json:"nullPointMode,omitempty"`
}

for a graph panel

type SinglestatPanel

type SinglestatPanel struct {
	Colors          []string    `json:"colors"`
	ColorValue      bool        `json:"colorValue"`
	ColorBackground bool        `json:"colorBackground"`
	Decimals        int         `json:"decimals"`
	Format          string      `json:"format"`
	Gauge           Gauge       `json:"gauge,omitempty"`
	MappingType     *uint       `json:"mappingType,omitempty"`
	MappingTypes    []*MapType  `json:"mappingTypes,omitempty"`
	MaxDataPoints   *IntString  `json:"maxDataPoints,omitempty"`
	NullPointMode   string      `json:"nullPointMode"`
	Postfix         *string     `json:"postfix,omitempty"`
	PostfixFontSize *string     `json:"postfixFontSize,omitempty"`
	Prefix          *string     `json:"prefix,omitempty"`
	PrefixFontSize  *string     `json:"prefixFontSize,omitempty"`
	RangeMaps       []*RangeMap `json:"rangeMaps,omitempty"`
	SparkLine       SparkLine   `json:"sparkline,omitempty"`
	Targets         []Target    `json:"targets,omitempty"`
	Thresholds      string      `json:"thresholds"`
	ValueFontSize   string      `json:"valueFontSize"`
	ValueMaps       []ValueMap  `json:"valueMaps"`
	ValueName       string      `json:"valueName"`
}

type Sort

type Sort struct {
	Col  int  `json:"col"`
	Desc bool `json:"desc"`
}

for a graph panel

type SparkLine

type SparkLine struct {
	FillColor *string  `json:"fillColor,omitempty"`
	Full      bool     `json:"full,omitempty"`
	LineColor *string  `json:"lineColor,omitempty"`
	Show      bool     `json:"show,omitempty"`
	YMin      *float64 `json:"ymin,omitempty"`
	YMax      *float64 `json:"ymax,omitempty"`
}

for a stat

type StackdriverAlertQuery

type StackdriverAlertQuery struct {
	ProjectName        string                    `json:"projectName,omitempty"`
	AlignOptions       []StackdriverAlignOptions `json:"alignOptions,omitempty"`
	AliasBy            string                    `json:"aliasBy,omitempty"`
	MetricType         string                    `json:"metricType,omitempty"`
	MetricKind         string                    `json:"metricKind,omitempty"`
	Filters            []string                  `json:"filters,omitempty"`
	AlignmentPeriod    string                    `json:"alignmentPeriod,omitempty"`
	CrossSeriesReducer string                    `json:"crossSeriesReducer,omitempty"`
	PerSeriesAligner   string                    `json:"perSeriesAligner,omitempty"`
	ValueType          string                    `json:"valueType,omitempty"`
	Preprocessor       string                    `json:"preprocessor,omitempty"`
	GroupBys           []string                  `json:"groupBys,omitempty"`
}

type StackdriverAlignOption

type StackdriverAlignOption struct {
	Label       string   `json:"label"`
	MetricKinds []string `json:"metricKinds"`
	Text        string   `json:"text"`
	Value       string   `json:"value"`
	ValueTypes  []string `json:"valueTypes"`
}

StackdriverAlignOption defines a single alignment option shown in Grafana during query configuration.

type StackdriverAlignOptions

type StackdriverAlignOptions struct {
	Expanded bool                     `json:"expanded"`
	Label    string                   `json:"label"`
	Options  []StackdriverAlignOption `json:"options"`
}

StackdriverAlignOptions defines the list of alignment options shown in Grafana during query configuration.

type StatOptions

type StatOptions struct {
	Orientation   string        `json:"orientation"`
	TextMode      string        `json:"textMode"`
	ColorMode     string        `json:"colorMode"`
	GraphMode     string        `json:"graphMode"`
	JustifyMode   string        `json:"justifyMode"`
	ReduceOptions ReduceOptions `json:"reduceOptions"`
	Text          *TextOptions  `json:"text,omitempty"`
}

type StatPanel

type StatPanel struct {
	Targets     []Target    `json:"targets,omitempty"`
	Options     StatOptions `json:"options"`
	FieldConfig FieldConfig `json:"fieldConfig"`
}

type StringSliceString

type StringSliceString struct {
	Value []string
	Valid bool
}

StringSliceString represents special type for json values that could be strings or slice of strings: "something" or ["something"].

func (*StringSliceString) MarshalJSON

func (v *StringSliceString) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshalling for StringSliceString type.

func (*StringSliceString) UnmarshalJSON

func (v *StringSliceString) UnmarshalJSON(raw []byte) error

UnmarshalJSON implements custom unmarshalling for StringSliceString type.

type TablePanel

type TablePanel struct {
	Columns   []Column      `json:"columns"`
	Sort      *Sort         `json:"sort,omitempty"`
	Styles    []ColumnStyle `json:"styles"`
	Transform string        `json:"transform"`
	Targets   []Target      `json:"targets,omitempty"`
	Scroll    bool          `json:"scroll"` // from grafana 3.x
}

type Target

type Target struct {
	RefID      string         `json:"refId"`
	Datasource *DatasourceRef `json:"datasource,omitempty"`
	Hide       bool           `json:"hide,omitempty"`

	// For PostgreSQL
	Table        string `json:"table,omitempty"`
	TimeColumn   string `json:"timeColumn,omitempty"`
	MetricColumn string `json:"metricColumn,omitempty"`
	RawSql       string `json:"rawSql,omitempty"`
	Select       [][]struct {
		Params []string `json:"params,omitempty"`
		Type   string   `json:"type,omitempty"`
	} `json:"select,omitempty"`
	Where []struct {
		Type     string   `json:"type,omitempty"`
		Name     string   `json:"name,omitempty"`
		Params   []string `json:"params,omitempty"`
		Datatype string   `json:"datatype,omitempty"`
	} `json:"where,omitempty"`
	Group []struct {
		Type   string   `json:"type,omitempty"`
		Params []string `json:"params,omitempty"`
	} `json:"group,omitempty"`

	// For Prometheus
	Expr           string `json:"expr,omitempty"`
	IntervalFactor int    `json:"intervalFactor,omitempty"`
	Interval       string `json:"interval,omitempty"`
	Step           int    `json:"step,omitempty"`
	LegendFormat   string `json:"legendFormat,omitempty"`
	Instant        bool   `json:"instant,omitempty"`
	Format         string `json:"format,omitempty"`

	// For InfluxDB
	Measurement string `json:"measurement,omitempty"`

	// For Elasticsearch
	DsType  *string `json:"dsType,omitempty"`
	Metrics []struct {
		ID    string `json:"id"`
		Field string `json:"field"`
		Type  string `json:"type"`
	} `json:"metrics,omitempty"`
	Query      string `json:"query,omitempty"`
	Alias      string `json:"alias,omitempty"`
	RawQuery   bool   `json:"rawQuery,omitempty"`
	TimeField  string `json:"timeField,omitempty"`
	BucketAggs []struct {
		ID       string `json:"id"`
		Field    string `json:"field"`
		Type     string `json:"type"`
		Settings struct {
			Interval    string      `json:"interval,omitempty"`
			MinDocCount interface{} `json:"min_doc_count"`
			Order       string      `json:"order,omitempty"`
			OrderBy     string      `json:"orderBy,omitempty"`
			Size        string      `json:"size,omitempty"`
		} `json:"settings"`
	} `json:"bucketAggs,omitempty"`

	// For AzureLogAnalytics
	AzureLogAnalytics AzureLogAnalytics `json:"azureLogAnalytics"`

	// For Graphite
	Target string `json:"target,omitempty"`

	// For CloudWatch
	Namespace  string            `json:"namespace,omitempty"`
	MetricName string            `json:"metricName,omitempty"`
	Statistics []string          `json:"statistics,omitempty"`
	Dimensions map[string]string `json:"dimensions,omitempty"`
	Period     string            `json:"period,omitempty"`
	Region     string            `json:"region,omitempty"`

	// For the Stackdriver data source. Find out more information at
	// https:/grafana.com/docs/grafana/v6.0/features/datasources/stackdriver/
	ProjectName        string                    `json:"projectName,omitempty"`
	AlignOptions       []StackdriverAlignOptions `json:"alignOptions,omitempty"`
	AliasBy            string                    `json:"aliasBy,omitempty"`
	MetricType         string                    `json:"metricType,omitempty"`
	MetricKind         string                    `json:"metricKind,omitempty"`
	Filters            []string                  `json:"filters,omitempty"`
	AlignmentPeriod    string                    `json:"alignmentPeriod,omitempty"`
	CrossSeriesReducer string                    `json:"crossSeriesReducer,omitempty"`
	PerSeriesAligner   string                    `json:"perSeriesAligner,omitempty"`
	ValueType          string                    `json:"valueType,omitempty"`
	Preprocessor       string                    `json:"preprocessor,omitempty"`
	GroupBys           []string                  `json:"groupBys,omitempty"`
	Tags               []struct {
		Key      string `json:"key,omitempty"`
		Operator string `json:"operator,omitempty"`
		Value    string `json:"value,omitempty"`
	} `json:"tags,omitempty"`

	// Supports the updated query format for Google Cloud Monitoring (GCM) data sources.
	QueryType       string              `json:"queryType,omitempty"`
	TimeSeriesList  *GCMTimeSeriesList  `json:"timeSeriesList,omitempty"`
	TimeSeriesQuery *GCMTimeSeriesQuery `json:"timeSeriesQuery,omitempty"`
	PromQLQuery     *GCMPromQLQuery     `json:"promQLQuery,omitempty"`
	SLOQuery        *GCMSLOQuery        `json:"sloQuery,omitempty"`
}

for an any panel

type TemplateVar

type TemplateVar struct {
	Name        string         `json:"name"`
	Type        string         `json:"type"`
	Auto        bool           `json:"auto,omitempty"`
	AutoCount   *int           `json:"auto_count,omitempty"`
	Datasource  *DatasourceRef `json:"datasource"`
	Refresh     BoolInt        `json:"refresh"`
	Options     []Option       `json:"options"`
	IncludeAll  bool           `json:"includeAll"`
	AllFormat   string         `json:"allFormat"`
	AllValue    string         `json:"allValue"`
	Multi       bool           `json:"multi"`
	MultiFormat string         `json:"multiFormat"`
	Query       interface{}    `json:"query"`
	Regex       string         `json:"regex"`
	Current     Current        `json:"current"`
	Label       string         `json:"label"`
	Hide        uint8          `json:"hide"`
	Sort        int            `json:"sort"`
}

type Templating

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

type TextOptions

type TextOptions struct {
	ValueSize int `json:"valueSize,omitempty"`
	TitleSize int `json:"titleSize,omitempty"`
}

type TextPanel

type TextPanel struct {
	Content     string        `json:"content"`
	Mode        string        `json:"mode"`
	PageSize    uint          `json:"pageSize"`
	Scroll      bool          `json:"scroll"`
	ShowHeader  bool          `json:"showHeader"`
	Sort        Sort          `json:"sort"`
	Styles      []ColumnStyle `json:"styles"`
	FieldConfig FieldConfig   `json:"fieldConfig"`
	Options     struct {
		Content string `json:"content"`
		Mode    string `json:"mode"`
	} `json:"options"`
}

type Threshold

type Threshold struct {
	// the alert threshold value, we do not omitempty, since 0 is a valid
	// threshold
	Value float32 `json:"value"`
	// critical, warning, ok, custom
	ColorMode string `json:"colorMode,omitempty"`
	// gt or lt
	Op   string `json:"op,omitempty"`
	Fill bool   `json:"fill"`
	Line bool   `json:"line"`
	// hexadecimal color (e.g. #629e51, only when ColorMode is "custom")
	FillColor string `json:"fillColor,omitempty"`
	// hexadecimal color (e.g. #629e51, only when ColorMode is "custom")
	LineColor string `json:"lineColor,omitempty"`
	// left or right
	Yaxis string `json:"yaxis,omitempty"`
}

type ThresholdStep

type ThresholdStep struct {
	Color string   `json:"color"`
	Value *float64 `json:"value"`
}

type Thresholds

type Thresholds struct {
	Mode  string          `json:"mode"`
	Steps []ThresholdStep `json:"steps"`
}

type Time

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

type Timepicker

type Timepicker struct {
	Now              *bool    `json:"now,omitempty"`
	RefreshIntervals []string `json:"refresh_intervals"`
	TimeOptions      []string `json:"time_options"`
}

type TimeseriesLegendOptions

type TimeseriesLegendOptions struct {
	Calcs       []string `json:"calcs"`
	Show        *bool    `json:"showLegend,omitempty"`
	DisplayMode string   `json:"displayMode"`
	Placement   string   `json:"placement"`
}

type TimeseriesOptions

type TimeseriesOptions struct {
	Legend  TimeseriesLegendOptions  `json:"legend,omitempty"`
	Tooltip TimeseriesTooltipOptions `json:"tooltip,omitempty"`
}

type TimeseriesPanel

type TimeseriesPanel struct {
	Targets     []Target          `json:"targets,omitempty"`
	Options     TimeseriesOptions `json:"options"`
	FieldConfig FieldConfig       `json:"fieldConfig"`
}

type TimeseriesTooltipOptions

type TimeseriesTooltipOptions struct {
	Mode string `json:"mode"`
}

type Tooltip

type Tooltip struct {
	Shared       bool   `json:"shared"`
	ValueType    string `json:"value_type"`
	MsResolution bool   `json:"msResolution,omitempty"` // was added in Grafana 3.x
	Sort         int    `json:"sort,omitempty"`
}

type ValueMap

type ValueMap struct {
	Op       string `json:"op"`
	TextType string `json:"text"`
	Value    string `json:"value"`
}

for a stat

Jump to

Keyboard shortcuts

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