gografana

package module
v0.0.0-...-217014a Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

gografana


总体设计思路

目前市面上针对Grafana v5.x Golang版本的API并不多,而且都不好用。我们的需求是要通过client动态创建dashboard和panels。在第一个版本中测试通过,我基本上实现了这个思路,可以支持如下功能:

  • 列举所有存在的Dashboard
  • 根据FolderId来获取所有Dashboard列表
  • 增加对数据源的管理
  • 根据UID获取指定Dashboard的详细信息
  • 查看指定Dashboard是否存在
  • 根据UID删除指定Dashboard
  • 增加对Folder的全量获取接口 本次更新新增
  • 增加对两种Grafana访问方式的支持(Basic Auth/API Key) 本次更新新增
  • 在Panel级别新增对Alert的数据结构支持 本次更新新增
  • 在Panel级别为Legend增加更多字段支持 本次更新新增

考虑到Grafana多版本间的API参数变化,这次代码的设计在理论上是可以支持多个Grafana版本的,主要设计点在于获取Grafana的Client是通过version来获取的,如下code:

//在新的API设计中,这里需要传入一个Authenticator接口实例用于告知client走哪种鉴权方式
auth := gografana.NewBasicAuthenticator("YOUR-USRENAME", "YOUR-PASSWORD")
client, err := gografana.GetClientByVersion("5.x", "http://x.x.x.x:3000", auth)
if err != nil {
  panic(err)
}

这看起来很妙,不是吗?通过传递远程Grafana服务期端的版本,就可以从内部生成出对应的client实例来,从而也就解决了多版本参数不兼容的问题。如下代码,是经过测试的,用于通过client来生成动态Dashboard以及Panels:

//在新的API设计中,这里需要传入一个Authenticator接口实例用于告知client走哪种鉴权方式
auth := gografana.NewBasicAuthenticator("YOUR-USRENAME", "YOUR-PASSWORD")
client, err := gografana.GetClientByVersion("5.x", "http://x.x.x.x:3000", auth)
if err != nil {
  panic(err)
}
title := fmt.Sprintf("DY_%s", time.Now())
existed, _, err := client.IsBoardExists(title)
if err != nil {
  panic(err)
}
if existed {
  fmt.Printf("Dashboard: %s has been existed.\n", title)
  os.Exit(0)
}
fmt.Printf("Start creating new dashboard: %s\n", title)
board, err := client.NewDashboard(&gografana.Board{
  Title:    title,
  Editable: true,
  Rows: []*gografana.Row{
    {Panels: []gografana.Panel_5_0{
      {Datasource: "Kubernetes Prod Cluster",
        DashLength:      10,
        Pointradius:     5,
        Linewidth:       1,
        SeriesOverrides: []interface{}{},
        Type:            "graph",
        Title:           "Traefik CPU Usage",
        Targets: []struct {
          Expr           string `json:"expr"`
          Format         string `json:"format"`
          Instant        bool   `json:"instant"`
          IntervalFactor int    `json:"intervalFactor"`
          LegendFormat   string `json:"legendFormat"`
          RefID          string `json:"refId"`
        }{
          {
            Expr:         "avg(sum(irate(container_cpu_usage_seconds_total{pod_name=~\"^traefik-ingress.*\"}[1h])) by (pod_name)*100) by (pod_name)",
            Format:       "time_series",
            LegendFormat: "{{pod_name}}",
            Instant:      false,
          },
        }},
    }},
  },
}, 0, false)
if err != nil {
  panic(err)
}
fmt.Printf("%#v\n", board)
fmt.Println("--- RETRIEVE IT AGAIN ---")
b, err := client.GetDashboardDetails(board.UID)
if err != nil {
  panic(err)
}
fmt.Printf("%#v\n", b)
fmt.Println("--- RETRIEVE IT END ---")
ok, err := client.DeleteDashboard(board.UID)
if err != nil {
  panic(err)
}
fmt.Printf("Dashboard deletion result: %t\n", ok)

目前先实现到这个级别,如果大家有别的需求也请随时给我提ISSUE。但是需要特别提出的一点是,目前我还没有保证这里面用到的数据结构是否跟官方的字段一个不落下的保持一致,也请各位使用时自己注意。

Grafana版本兼容性支持

已测试版本 是否兼容
5.1.3 ✔️
5.4.5 ✔️
6.4.5 ✔️
6.5.3 ✔️
6.6.2 ✔️

由于在Grafana v6.6版本上测试目前已经支持的API也是能够正常工作的,在初始化Grafana Client时可以版本传递为"5.x"即可。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Role string `json:"role"`
}

type Annotations

type Annotations struct {
	List []struct {
		BuiltIn    int    `json:"builtIn"`
		Datasource string `json:"datasource"`
		Enable     bool   `json:"enable"`
		Hide       bool   `json:"hide"`
		IconColor  string `json:"iconColor"`
		Name       string `json:"name"`
		Type       string `json:"type"`
	} `json:"list"`
}

type Authenticator

type Authenticator interface {
	SetAuthentication(req *http.Request)
}

func NewAPIKeyAuthenticator

func NewAPIKeyAuthenticator(apiKey string) Authenticator

func NewBasicAuthenticator

func NewBasicAuthenticator(user string, pass string) Authenticator

type Board

type Board struct {
	ID                   uint          `json:"id,omitempty"`
	UID                  string        `json:"uid"`
	Title                string        `json:"title"`
	Tags                 []string      `json:"tags"`
	Editable             bool          `json:"editable"`
	HideControls         bool          `json:"hideControls"`
	Style                string        `json:"style"`
	Timezone             string        `json:"timezone"`
	Version              uint          `json:"version"`
	IsStarred            bool          `json:"isStarred"`
	FolderId             uint          `json:"folderId"`
	FolderUid            string        `json:"folderUid"`
	FolderTitle          string        `json:"folderTitle"`
	FolderUrl            string        `json:"folderUrl"`
	Url                  string        `json:"url,omitempty"` //TODO: ??
	Rows                 []*Row        `json:"rows"`
	Annotations          Annotations   `json:"annotations"`
	Description          string        `json:"description"`
	FiscalYearStartMonth int           `json:"fiscalYearStartMonth"`
	GnetID               int           `json:"gnetId"`
	GraphTooltip         int           `json:"graphTooltip"`
	Iteration            int64         `json:"iteration"`
	Links                []interface{} `json:"links"`
	LiveNow              bool          `json:"liveNow"`
	Panels               []*Panel      `json:"panels"`
	Refresh              string        `json:"refresh"`
	SchemaVersion        int           `json:"schemaVersion"`
	Templating           Templating    `json:"templating"`
	WeekStart            string        `json:"weekStart"`
}

Board represents Grafana dashboard.

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

type CreateDashboardRequest

type CreateDashboardRequest struct {
	Board Board `json:"dashboard"`
	//The id of the folder to save the dashboard in.
	FolderId uint `json:"folderId"`
	//Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
	Overwrite bool `json:"overwrite,omitempty"`
	//Set a commit message for the version history.
	Message string `json:"message"`
}

type CreateDashboardResponse

type CreateDashboardResponse struct {
	ID      uint   `json:"id,omitempty"`
	UID     string `json:"uid"`
	Url     string `json:"url"`
	Status  string `json:"status"`
	Version uint   `json:"version"`
	Message string `json:"message,omitempty"`
}

Status Codes: --------------- 200 – Created 400 – Errors (invalid json, missing or invalid fields, etc) 401 – Unauthorized 403 – Access denied 412 – Precondition failed The 412 status code is used for explaing that you cannot create the dashboard and why. There can be different reasons for this: The dashboard has been changed by someone else, status=version-mismatch A dashboard with the same name in the folder already exists, status=name-exists A dashboard with the same uid already exists, status=name-exists The dashboard belongs to plugin <plugin title>, status=plugin-dashboard

type CreateDataSourceResponse

type CreateDataSourceResponse struct {
	DataSource *DataSource `json:"datasource"`
	ID         int         `json:"id"`
	Message    string      `json:"message"`
	Name       string      `json:"name"`
}

type CreateFolderRequest

type CreateFolderRequest struct {
	UID   string `json:"uid"`
	Title string `json:"title"`
}

type CreateFolderResponse

type CreateFolderResponse struct {
	ID        int       `json:"id"`
	UID       string    `json:"uid"`
	Title     string    `json:"title"`
	URL       string    `json:"url"`
	HasAcl    bool      `json:"hasAcl"`
	CanSave   bool      `json:"canSave"`
	CanEdit   bool      `json:"canEdit"`
	CanAdmin  bool      `json:"canAdmin"`
	CreatedBy string    `json:"createdBy"`
	Created   time.Time `json:"created"`
	UpdatedBy string    `json:"updatedBy"`
	Updated   time.Time `json:"updated"`
	Version   int       `json:"version"`
}

type CreateNotificationChannelResponse

type CreateNotificationChannelResponse struct {
	ID           int    `json:"id"`
	UID          string `json:"uid"`
	Name         string `json:"name"`
	Type         string `json:"type"`
	IsDefault    bool   `json:"isDefault"`
	SendReminder bool   `json:"sendReminder"`
	Settings     struct {
		Addresses string `json:"addresses"`
	} `json:"settings"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

type Custom

type Custom struct {
}

type DataSource

type DataSource struct {
	ID          int                    `json:"id"`
	OrgID       int                    `json:"orgId"`
	Name        string                 `json:"name"`
	Type        string                 `json:"type"`
	TypeLogoURL string                 `json:"typeLogoUrl"`
	Access      string                 `json:"access"`
	URL         string                 `json:"url"`
	Password    string                 `json:"password"`
	User        string                 `json:"user"`
	Database    string                 `json:"database"`
	BasicAuth   bool                   `json:"basicAuth"`
	IsDefault   bool                   `json:"isDefault"`
	JSONData    map[string]interface{} `json:"jsonData"`
	ReadOnly    bool                   `json:"readOnly"`
}

type Defaults

type Defaults struct {
	Custom Custom `json:"custom"`
}

type ErrNoSpecifiedVerClient

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

type FieldConfig

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

type Folder

type Folder struct {
	ID        int       `json:"id"`
	UID       string    `json:"uid"`
	Title     string    `json:"title"`
	URL       string    `json:"url"`
	HasACL    bool      `json:"hasAcl"`
	CanSave   bool      `json:"canSave"`
	CanEdit   bool      `json:"canEdit"`
	CanAdmin  bool      `json:"canAdmin"`
	CreatedBy string    `json:"createdBy"`
	Created   time.Time `json:"created"`
	UpdatedBy string    `json:"updatedBy"`
	Updated   time.Time `json:"updated"`
	Version   int       `json:"version"`
}

type GetDashboardByUIdResponse

type GetDashboardByUIdResponse struct {
	Meta struct {
		Type        string    `json:"type"`
		CanSave     bool      `json:"canSave"`
		CanEdit     bool      `json:"canEdit"`
		CanAdmin    bool      `json:"canAdmin"`
		CanStar     bool      `json:"canStar"`
		Slug        string    `json:"slug"`
		URL         string    `json:"url"`
		Expires     time.Time `json:"expires"`
		Created     time.Time `json:"created"`
		Updated     time.Time `json:"updated"`
		UpdatedBy   string    `json:"updatedBy"`
		CreatedBy   string    `json:"createdBy"`
		Version     int       `json:"version"`
		HasAcl      bool      `json:"hasAcl"`
		IsFolder    bool      `json:"isFolder"`
		FolderID    int       `json:"folderId"`
		FolderTitle string    `json:"folderTitle"`
		FolderURL   string    `json:"folderUrl"`
	} `json:"meta"`
	Dashboard Board `json:"dashboard"`
}

type GrafanaClient_5_0

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

func (*GrafanaClient_5_0) CreateAPIKey

func (gc *GrafanaClient_5_0) CreateAPIKey(name string, role string, secondsToLive int) (string, error)

func (*GrafanaClient_5_0) CreateDashSource

func (gc *GrafanaClient_5_0) CreateDashSource(ds *DataSource) error

func (*GrafanaClient_5_0) CreateNotificationChannel

func (gc *GrafanaClient_5_0) CreateNotificationChannel(nc *NotificationChannel) error

func (*GrafanaClient_5_0) DeleteAPIKey

func (gc *GrafanaClient_5_0) DeleteAPIKey(id int) (bool, error)

func (*GrafanaClient_5_0) DeleteDashSource

func (gc *GrafanaClient_5_0) DeleteDashSource(id int) error

func (*GrafanaClient_5_0) DeleteDashboard

func (gc *GrafanaClient_5_0) DeleteDashboard(uid string) (bool, error)

Status Codes: ------------------- 200 – Deleted 401 – Unauthorized 403 – Access denied 404 – Not found

func (*GrafanaClient_5_0) EnsureFolderExists

func (gc *GrafanaClient_5_0) EnsureFolderExists(folderId int, uid, title string) (int, bool, error)

func (*GrafanaClient_5_0) FindAllAPIKeys

func (gc *GrafanaClient_5_0) FindAllAPIKeys() ([]APIKey, error)

func (*GrafanaClient_5_0) GetAllDashboards

func (gc *GrafanaClient_5_0) GetAllDashboards() ([]Board, error)

func (*GrafanaClient_5_0) GetAllDataSources

func (gc *GrafanaClient_5_0) GetAllDataSources() ([]*DataSource, error)

func (*GrafanaClient_5_0) GetAllFolders

func (gc *GrafanaClient_5_0) GetAllFolders() ([]Folder, error)

func (*GrafanaClient_5_0) GetAllNotificationChannels

func (gc *GrafanaClient_5_0) GetAllNotificationChannels() ([]NotificationChannel, error)

func (*GrafanaClient_5_0) GetDashSourceById

func (gc *GrafanaClient_5_0) GetDashSourceById(id int) (*DataSource, error)

func (*GrafanaClient_5_0) GetDashboardDetails

func (gc *GrafanaClient_5_0) GetDashboardDetails(uid string) (*Board, error)

Status Codes: ------------------- 200 – Found 401 – Unauthorized 403 – Access denied 404 – Not found

func (*GrafanaClient_5_0) GetDashboardsByFolderId

func (gc *GrafanaClient_5_0) GetDashboardsByFolderId(folderId int) ([]Board, error)

func (*GrafanaClient_5_0) GetDashboardsByTitleAndFolderId

func (gc *GrafanaClient_5_0) GetDashboardsByTitleAndFolderId(title string, folderId int) ([]Board, error)

func (*GrafanaClient_5_0) IsBoardExists

func (gc *GrafanaClient_5_0) IsBoardExists(title string) (bool, *Board, error)

func (*GrafanaClient_5_0) NewDashboard

func (gc *GrafanaClient_5_0) NewDashboard(board *Board, folderId uint, overwrite bool) (*Board, error)

type GrafanaClienter

type GrafanaClienter interface {
	GetAllDashboards() ([]Board, error)
	GetAllFolders() ([]Folder, error)
	GetDashboardsByTitleAndFolderId(title string, folderId int) ([]Board, error)
	GetDashboardsByFolderId(folderId int) ([]Board, error)
	IsBoardExists(title string) (bool, *Board, error)
	NewDashboard(board *Board, folderId uint, overwrite bool) (*Board, error)
	DeleteDashboard(uid string) (bool, error)
	GetDashboardDetails(uid string) (*Board, error)
	EnsureFolderExists(folderId int, uid, title string) (int, bool, error)
	CreateAPIKey(name string, role string, secondsToLive int) (string, error)
	FindAllAPIKeys() ([]APIKey, error)
	DeleteAPIKey(id int) (bool, error)
	//DATA SOURCE
	GetAllDataSources() ([]*DataSource, error)
	GetDashSourceById(id int) (*DataSource, error)
	DeleteDashSource(id int) error
	CreateDashSource(ds *DataSource) error
	//NOTIFICATIONS
	GetAllNotificationChannels() ([]NotificationChannel, error)
	CreateNotificationChannel(nc *NotificationChannel) error
}

func GetClientByVersion

func GetClientByVersion(version, apiAddress string, auth Authenticator) (GrafanaClienter, error)

根据Grafana的版本号来获取指定的Client

func GetClientByVersionWithProxy

func GetClientByVersionWithProxy(version, apiAddress, httpProxy string, auth Authenticator) (GrafanaClienter, error)

根据Grafana的版本号来获取指定的Client,并设置 http proxy

type NewDashboardError

type NewDashboardError struct {
	Err    error
	Status string
}

func (NewDashboardError) Error

func (e NewDashboardError) Error() string

type NotificationChannel

type NotificationChannel struct {
	ID                    int       `json:"id"`
	Name                  string    `json:"name"`
	Type                  string    `json:"type"`
	IsDefault             bool      `json:"isDefault"`
	SendReminder          bool      `json:"sendReminder"`
	DisableResolveMessage bool      `json:"disableResolveMessage"`
	Frequency             string    `json:"frequency"`
	Created               time.Time `json:"created"`
	Updated               time.Time `json:"updated"`
	Settings              struct {
		Addresses   string `json:"addresses"`
		AutoResolve bool   `json:"autoResolve"`
		HTTPMethod  string `json:"httpMethod"`
		UploadImage bool   `json:"uploadImage"`
	} `json:"settings"`
}

type Panel

type Panel struct {
	CacheTimeout    interface{}  `json:"cacheTimeout,omitempty"`
	ColorBackground bool         `json:"colorBackground,omitempty"`
	ColorValue      bool         `json:"colorValue,omitempty"`
	Colors          []string     `json:"colors,omitempty"`
	Datasource      interface{}  `json:"datasource"`
	Editable        bool         `json:"editable"`
	Error           bool         `json:"error"`
	FieldConfig     *FieldConfig `json:"fieldConfig,omitempty"`
	Format          string       `json:"format,omitempty"`
	Gauge           struct {
		MaxValue         int  `json:"maxValue"`
		MinValue         int  `json:"minValue"`
		Show             bool `json:"show"`
		ThresholdLabels  bool `json:"thresholdLabels"`
		ThresholdMarkers bool `json:"thresholdMarkers"`
	} `json:"gauge,omitempty"`
	GridPos struct {
		H int `json:"h"`
		W int `json:"w"`
		X int `json:"x"`
		Y int `json:"y"`
	} `json:"gridPos"`
	Height       string        `json:"height,omitempty"`
	ID           int           `json:"id"`
	Interval     interface{}   `json:"interval,omitempty"`
	IsNew        bool          `json:"isNew"`
	Links        []interface{} `json:"links"`
	MappingType  int           `json:"mappingType,omitempty"`
	MappingTypes []struct {
		Name  string `json:"name"`
		Value int    `json:"value"`
	} `json:"mappingTypes,omitempty"`
	MaxDataPoints   int         `json:"maxDataPoints,omitempty"`
	NullPointMode   string      `json:"nullPointMode"`
	NullText        interface{} `json:"nullText,omitempty"`
	Postfix         string      `json:"postfix,omitempty"`
	PostfixFontSize string      `json:"postfixFontSize,omitempty"`
	Prefix          string      `json:"prefix,omitempty"`
	PrefixFontSize  string      `json:"prefixFontSize,omitempty"`
	RangeMaps       []struct {
		From string `json:"from"`
		Text string `json:"text"`
		To   string `json:"to"`
	} `json:"rangeMaps,omitempty"`
	Sparkline struct {
		FillColor string `json:"fillColor"`
		Full      bool   `json:"full"`
		LineColor string `json:"lineColor"`
		Show      bool   `json:"show"`
	} `json:"sparkline,omitempty"`
	TableColumn string `json:"tableColumn,omitempty"`
	Targets     []struct {
		Expr           string `json:"expr"`
		IntervalFactor int    `json:"intervalFactor"`
		LegendFormat   string `json:"legendFormat"`
		Metric         string `json:"metric"`
		RefID          string `json:"refId"`
		Step           int    `json:"step"`
	} `json:"targets"`
	Thresholds    interface{} `json:"thresholds"`
	Title         string      `json:"title"`
	Transparent   bool        `json:"transparent,omitempty"`
	Type          string      `json:"type"`
	ValueFontSize string      `json:"valueFontSize,omitempty"`
	ValueMaps     []struct {
		Op    string `json:"op"`
		Text  string `json:"text"`
		Value string `json:"value"`
	} `json:"valueMaps,omitempty"`
	ValueName   string `json:"valueName,omitempty"`
	AliasColors struct {
	} `json:"aliasColors,omitempty"`
	Bars         bool `json:"bars,omitempty"`
	DashLength   int  `json:"dashLength,omitempty"`
	Dashes       bool `json:"dashes,omitempty"`
	Decimals     int  `json:"decimals,omitempty"`
	Fill         int  `json:"fill,omitempty"`
	FillGradient int  `json:"fillGradient,omitempty"`
	Grid         struct {
	} `json:"grid,omitempty"`
	HiddenSeries bool `json:"hiddenSeries,omitempty"`
	Legend       struct {
		AlignAsTable bool `json:"alignAsTable"`
		Avg          bool `json:"avg"`
		Current      bool `json:"current"`
		Max          bool `json:"max"`
		Min          bool `json:"min"`
		RightSide    bool `json:"rightSide"`
		Show         bool `json:"show"`
		Total        bool `json:"total"`
		Values       bool `json:"values"`
	} `json:"legend,omitempty"`
	Lines     bool `json:"lines,omitempty"`
	Linewidth int  `json:"linewidth,omitempty"`
	Options   struct {
		DataLinks []interface{} `json:"dataLinks"`
	} `json:"options,omitempty"`
	Percentage      bool          `json:"percentage,omitempty"`
	Pointradius     int           `json:"pointradius,omitempty"`
	Points          bool          `json:"points,omitempty"`
	Renderer        string        `json:"renderer,omitempty"`
	SeriesOverrides []interface{} `json:"seriesOverrides,omitempty"`
	SpaceLength     int           `json:"spaceLength,omitempty"`
	Stack           bool          `json:"stack,omitempty"`
	SteppedLine     bool          `json:"steppedLine,omitempty"`
	TimeFrom        interface{}   `json:"timeFrom,omitempty"`
	TimeRegions     []interface{} `json:"timeRegions,omitempty"`
	TimeShift       interface{}   `json:"timeShift,omitempty"`
	Tooltip         struct {
		MsResolution bool   `json:"msResolution"`
		Shared       bool   `json:"shared"`
		Sort         int    `json:"sort"`
		ValueType    string `json:"value_type"`
	} `json:"tooltip,omitempty"`
	Xaxis struct {
		Buckets interface{}   `json:"buckets"`
		Mode    string        `json:"mode"`
		Name    interface{}   `json:"name"`
		Show    bool          `json:"show"`
		Values  []interface{} `json:"values"`
	} `json:"xaxis,omitempty"`
	Yaxes []struct {
		Format  string      `json:"format"`
		Label   interface{} `json:"label"`
		LogBase int         `json:"logBase"`
		Max     interface{} `json:"max"`
		Min     interface{} `json:"min"`
		Show    bool        `json:"show"`
	} `json:"yaxes,omitempty"`
	Yaxis struct {
		Align      bool        `json:"align"`
		AlignLevel interface{} `json:"alignLevel"`
	} `json:"yaxis,omitempty"`
}

type Panel_5_0

type Panel_5_0 struct {
	AliasColors map[string]string `json:"aliasColors"`
	Alert       *struct {
		AlertRuleTags struct {
		} `json:"alertRuleTags"`
		Conditions []struct {
			Evaluator struct {
				Params []int64 `json:"params"`
				Type   string  `json:"type"`
			} `json:"evaluator"`
			Operator struct {
				Type string `json:"type"`
			} `json:"operator"`
			Query struct {
				Params []string `json:"params"`
			} `json:"query"`
			Reducer struct {
				Params []interface{} `json:"params"`
				Type   string        `json:"type"`
			} `json:"reducer"`
			Type string `json:"type"`
		} `json:"conditions"`
		ExecutionErrorState string `json:"executionErrorState"`
		For                 string `json:"for"`
		Frequency           string `json:"frequency"`
		Handler             int    `json:"handler"`
		Message             string `json:"message"`
		Name                string `json:"name"`
		NoDataState         string `json:"noDataState"`
		Notifications       []struct {
			ID int `json:"id"`
		} `json:"notifications"`
	} `json:"alert,omitempty"`
	Bars       bool   `json:"bars"`
	DashLength int    `json:"dashLength"`
	Dashes     bool   `json:"dashes"`
	Datasource string `json:"datasource"`
	Fill       int    `json:"fill"`
	GridPos    struct {
		H int `json:"h"`
		W int `json:"w"`
		X int `json:"x"`
		Y int `json:"y"`
	} `json:"gridPos,omitempty"`
	ID     int `json:"id"`
	Legend struct {
		Avg          bool `json:"avg"`
		Current      bool `json:"current"`
		Max          bool `json:"max"`
		Min          bool `json:"min"`
		Show         bool `json:"show"`
		Total        bool `json:"total"`
		Values       bool `json:"values"`
		AlignAsTable bool `json:"alignAsTable"`
	} `json:"legend,omitempty"`
	Lines           bool          `json:"lines"`
	Linewidth       int           `json:"linewidth"`
	Links           []interface{} `json:"links"`
	NullPointMode   string        `json:"nullPointMode"`
	Percentage      bool          `json:"percentage"`
	Pointradius     int           `json:"pointradius"`
	Points          bool          `json:"points"`
	Renderer        string        `json:"renderer"`
	SeriesOverrides []interface{} `json:"seriesOverrides"`
	SpaceLength     int           `json:"spaceLength"`
	Stack           bool          `json:"stack"`
	SteppedLine     bool          `json:"steppedLine"`
	Targets         []struct {
		Expr           string `json:"expr"`
		Format         string `json:"format"`
		Instant        bool   `json:"instant"`
		IntervalFactor int    `json:"intervalFactor"`
		LegendFormat   string `json:"legendFormat"`
		RefID          string `json:"refId"`
	} `json:"targets"`
	Thresholds []interface{} `json:"thresholds"`
	TimeFrom   interface{}   `json:"timeFrom"`
	TimeShift  interface{}   `json:"timeShift"`
	Title      string        `json:"title"`
	Tooltip    struct {
		Shared    bool   `json:"shared"`
		Sort      int    `json:"sort"`
		ValueType string `json:"value_type"`
	} `json:"tooltip,omitempty"`
	Transparent bool   `json:"transparent"`
	Type        string `json:"type"`
	Xaxis       struct {
		Buckets interface{}   `json:"buckets"`
		Mode    string        `json:"mode"`
		Name    interface{}   `json:"name"`
		Show    bool          `json:"show"`
		Values  []interface{} `json:"values"`
	} `json:"xaxis,omitempty"`
	Yaxes []struct {
		Format  string      `json:"format"`
		Label   interface{} `json:"label"`
		LogBase int         `json:"logBase"`
		Max     interface{} `json:"max"`
		Min     interface{} `json:"min"`
		Show    bool        `json:"show"`
	} `json:"yaxes,omitempty"`
}

func (*Panel_5_0) MarshalJSON

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

type Row

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

type Templating

type Templating struct {
	List []struct {
		Current struct {
			IsNone   bool   `json:"isNone"`
			Selected bool   `json:"selected"`
			Text     string `json:"text"`
			Value    string `json:"value"`
		} `json:"current,omitempty"`
		Hide           int           `json:"hide"`
		IncludeAll     bool          `json:"includeAll"`
		Multi          bool          `json:"multi"`
		Name           string        `json:"name"`
		Options        []interface{} `json:"options"`
		Query          interface{}   `json:"query"`
		QueryValue     string        `json:"queryValue"`
		Refresh        int           `json:"refresh"`
		Regex          string        `json:"regex"`
		SkipURLSync    bool          `json:"skipUrlSync"`
		Type           string        `json:"type"`
		AllValue       interface{}   `json:"allValue"`
		Datasource     interface{}   `json:"datasource"`
		Definition     string        `json:"definition"`
		Label          string        `json:"label"`
		Sort           int           `json:"sort"`
		TagValuesQuery string        `json:"tagValuesQuery"`
		Tags           []interface{} `json:"tags"`
		TagsQuery      string        `json:"tagsQuery"`
		UseTags        bool          `json:"useTags"`
		Auto           bool          `json:"auto"`
		AutoCount      int           `json:"auto_count"`
		AutoMin        string        `json:"auto_min"`
	} `json:"list"`
}

Jump to

Keyboard shortcuts

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