Documentation ¶
Index ¶
- Constants
- Variables
- type Alert
- type AlertCondition
- type AlertNotification
- type AlertlistPanel
- type Annotation
- type Axis
- type Board
- type BoardProperties
- type BoolInt
- type BoolString
- type Client
- func (r *Client) CreateDatasource(ds Datasource) (StatusMessage, error)
- func (r *Client) CreateFolder(f Folder) (resp FolderProperties, err error)
- func (r *Client) CreateUser(user User) (StatusMessage, error)
- func (r *Client) DeleteDashboard(slug string) (StatusMessage, error)
- func (r *Client) DeleteDatasource(id uint) (StatusMessage, error)
- func (r *Client) DeleteDatasourceByName(name string) (StatusMessage, error)
- func (r *Client) GetActualUser() (User, error)
- func (r *Client) GetAllDatasources() ([]Datasource, error)
- func (r *Client) GetAllUsers() ([]User, error)
- func (r *Client) GetDashboard(slug string) (Board, BoardProperties, error)
- func (r *Client) GetDatasource(id uint) (Datasource, error)
- func (r *Client) GetDatasourceByName(name string) (Datasource, error)
- func (r *Client) GetDatasourceTypes() (map[string]DatasourceType, error)
- func (r *Client) GetFolder(uid string) (resp FolderProperties, err error)
- func (r *Client) GetRawDashboard(slug string) ([]byte, BoardProperties, error)
- func (r *Client) GetUser(id uint) (User, error)
- func (r *Client) SearchDashboards(query string, starred bool, tags ...string) ([]FoundBoard, error)
- func (r *Client) SearchUsersWithPaging(query *string, perpage, page *int) (PageUsers, error)
- func (r *Client) SetDashboard(board Board, overwrite bool, folderId int) (StatusMessage, error)
- func (r *Client) SetRawDashboard(raw []byte) error
- func (r *Client) SwitchUserContext(uid uint, oid uint) (StatusMessage, error)
- func (r *Client) UpdateDatasource(ds Datasource) (StatusMessage, error)
- type Current
- type CustomPanel
- type DashlistPanel
- type Datasource
- type DatasourceType
- type FloatString
- type Folder
- type FolderProperties
- type FoundBoard
- type GraphPanel
- type HeatmapPanel
- type Height
- type IntString
- type MapType
- type Option
- type Org
- type OrgUser
- type PageUsers
- type Panel
- func NewAlertlist(title string) *Panel
- func NewCustom(title string) *Panel
- func NewDashlist(title string) *Panel
- func NewGraph(title string) *Panel
- func NewHeatmap(title string) *Panel
- func NewPluginlist(title string) *Panel
- func NewSinglestat(title string) *Panel
- func NewTable(title string) *Panel
- func NewText(title string) *Panel
- func (p *Panel) AddTarget(t *Target)
- func (p *Panel) GetTargets() *[]Target
- func (p *Panel) MarshalJSON() ([]byte, error)
- func (p *Panel) RepeatDatasourcesForEachTarget(dsNames ...string)
- func (p *Panel) RepeatTargetsForDatasources(dsNames ...string)
- func (p *Panel) ResetTargets()
- func (p *Panel) SetTarget(t *Target)
- func (p *Panel) UnmarshalJSON(b []byte) (err error)
- type PluginlistPanel
- type RangeMap
- type Row
- type RowPanel
- type SeriesOverride
- type SinglestatPanel
- type StatusMessage
- type TablePanel
- type Target
- type TemplateVar
- type Templating
- type TextPanel
- type Threshold
- type Time
- type Timepicker
- type Tooltip
- type User
- type UserRole
Examples ¶
Constants ¶
const ( TemplatingHideNone = iota TemplatingHideLabel TemplatingHideVariable )
Constants for templating
const ( CustomType panelType = iota DashlistType GraphType HeatMapType TableType TextType PluginlistType AlertlistType SinglestatType )
Each panel may be one of these types.
const MixedSource = "-- Mixed --"
Variables ¶
var DefaultHTTPClient = http.DefaultClient
DefaultHTTPClient initialized Grafana with appropriate conditions. It allows you globally redefine HTTP client.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { Conditions []AlertCondition `json:"conditions,omitempty"` ExecutionErrorState string `json:"executionErrorState,omitempty"` Frequency string `json:"frequency,omitempty"` Handler int `json:"handler,omitempty"` Name string `json:"name,omitempty"` NoDataState string `json:"noDataState,omitempty"` Notifications []AlertNotification `json:"notifications,omitempty"` Message string `json:"message,omitempty"` }
type AlertCondition ¶
type AlertCondition struct { Evaluator struct { Params []float64 `json:"params,omitempty"` Type string `json:"type,omitempty"` } `json:"evaluator,omitempty"` Operator struct { Type string `json:"type,omitempty"` } `json:"operator,omitempty"` Query struct { Params []string `json:"params,omitempty"` } `json:"query,omitempty"` Reducer struct { Params []string `json:"params,omitempty"` Type string `json:"type,omitempty"` } `json:"reducer,omitempty"` Type string `json:"type,omitempty"` }
type AlertNotification ¶
type AlertlistPanel ¶
type Annotation ¶
type Annotation struct { Name string `json:"name"` Datasource *string `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"` TextField string `json:"textField"` }
type Axis ¶
type Axis struct { Format string `json:"format"` LogBase int `json:"logBase"` Max *FloatString `json:"max,omitempty"` Min *FloatString `json:"min,omitempty"` Show bool `json:"show"` Label string `json:"label,omitempty"` }
for a graph panel
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"` 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"` // contains filtered or unexported fields }
Board represents Grafana dashboard.
func NewBoard ¶
Example ¶
package main import ( "encoding/json" "fmt" "github.com/grafana-tools/sdk" ) func main() { board := sdk.NewBoard("Sample dashboard title") board.ID = 1 row1 := board.AddRow("Sample row title") row1.Add(sdk.NewGraph("Sample graph")) graphWithDs := sdk.NewGraph("Sample graph 2") target := sdk.Target{ RefID: "A", Datasource: "Sample Source 1", Expr: "sample request 1"} graphWithDs.AddTarget(&target) row1.Add(graphWithDs) data, _ := json.MarshalIndent(board, "", " ") fmt.Printf("%s", data) }
Output: { "id": 1, "slug": "", "title": "Sample dashboard title", "originalTitle": "", "tags": null, "style": "dark", "timezone": "browser", "editable": true, "hideControls": false, "sharedCrosshair": false, "panels": null, "rows": [ { "title": "Sample row title", "showTitle": false, "collapse": false, "editable": true, "height": "250px", "panels": [ { "editable": false, "error": false, "gridPos": {}, "id": 1, "isNew": true, "renderer": "flot", "span": 12, "title": "Sample graph", "transparent": false, "type": "graph", "aliasColors": null, "bars": false, "fill": 0, "legend": { "alignAsTable": false, "avg": false, "current": false, "hideEmpty": false, "hideZero": false, "max": false, "min": false, "rightSide": false, "show": false, "total": false, "values": false }, "lines": false, "linewidth": 0, "nullPointMode": "connected", "percentage": false, "pointradius": 5, "points": false, "stack": false, "steppedLine": false, "tooltip": { "shared": false, "value_type": "" }, "x-axis": true, "y-axis": true, "xaxis": { "format": "", "logBase": 0, "show": false }, "yaxes": null }, { "editable": false, "error": false, "gridPos": {}, "id": 2, "isNew": true, "renderer": "flot", "span": 12, "title": "Sample graph 2", "transparent": false, "type": "graph", "aliasColors": null, "bars": false, "fill": 0, "legend": { "alignAsTable": false, "avg": false, "current": false, "hideEmpty": false, "hideZero": false, "max": false, "min": false, "rightSide": false, "show": false, "total": false, "values": false }, "lines": false, "linewidth": 0, "nullPointMode": "connected", "percentage": false, "pointradius": 5, "points": false, "stack": false, "steppedLine": false, "targets": [ { "refId": "A", "datasource": "Sample Source 1", "expr": "sample request 1" } ], "tooltip": { "shared": false, "value_type": "" }, "x-axis": true, "y-axis": true, "xaxis": { "format": "", "logBase": 0, "show": false }, "yaxes": null } ], "repeat": null } ], "templating": { "list": null }, "annotations": { "list": null }, "schemaVersion": 0, "version": 0, "links": null, "time": { "from": "", "to": "" }, "timepicker": { "refresh_intervals": null, "time_options": null } }
func (*Board) RemoveTags ¶
func (*Board) UpdateSlug ¶
type BoardProperties ¶
type BoardProperties struct { IsStarred bool `json:"isStarred,omitempty"` IsHome bool `json:"isHome,omitempty"` IsSnapshot bool `json:"isSnapshot,omitempty"` Type string `json:"type,omitempty"` CanSave bool `json:"canSave"` CanEdit bool `json:"canEdit"` CanStar bool `json:"canStar"` Slug string `json:"slug"` 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"` }
BoardProperties keeps metadata of a dashboard.
type BoolString ¶
func (BoolString) MarshalJSON ¶
func (s BoolString) MarshalJSON() ([]byte, error)
func (*BoolString) UnmarshalJSON ¶
func (s *BoolString) UnmarshalJSON(raw []byte) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client uses Grafana REST API for interacting with Grafana server.
func NewClient ¶
NewClient initializes client for interacting with an instance of Grafana server; apiKeyOrBasicAuth accepts either 'username:password' basic authentication credentials, or a Grafana API key
func (*Client) CreateDatasource ¶
func (r *Client) CreateDatasource(ds Datasource) (StatusMessage, error)
CreateDatasource creates a new datasource. It reflects POST /api/datasources API call.
func (*Client) CreateFolder ¶
func (r *Client) CreateFolder(f Folder) (resp FolderProperties, err error)
func (*Client) CreateUser ¶
func (r *Client) CreateUser(user User) (StatusMessage, error)
CreateUser creates a new global user Only work with Basic Authentication It reflects POST /api/admin/users
func (*Client) DeleteDashboard ¶
func (r *Client) DeleteDashboard(slug string) (StatusMessage, error)
DeleteDashboard deletes dashboard that selected by slug string. Grafana only can delete a dashboard in a database. File dashboards may be only loaded with HTTP API but not deteled.
func (*Client) DeleteDatasource ¶
func (r *Client) DeleteDatasource(id uint) (StatusMessage, error)
DeleteDatasource deletes an existing datasource by ID. It reflects DELETE /api/datasources/:datasourceId API call.
func (*Client) DeleteDatasourceByName ¶
func (r *Client) DeleteDatasourceByName(name string) (StatusMessage, error)
DeleteDatasourceByName deletes an existing datasource by Name. It reflects DELETE /api/datasources/name/:datasourceName API call.
func (*Client) GetActualUser ¶
GetActualUser gets an actual user.
func (*Client) GetAllDatasources ¶
func (r *Client) GetAllDatasources() ([]Datasource, error)
GetAllDatasources loads all datasources. It reflects GET /api/datasources API call.
func (*Client) GetAllUsers ¶
GetAllUsers gets all users.
func (*Client) GetDashboard ¶
func (r *Client) GetDashboard(slug string) (Board, BoardProperties, error)
GetDashboard loads a dashboard from Grafana instance along with metadata for a dashboard. For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from a database assumed. Database dashboards may have "db/" prefix or may have not, it will be appended automatically.
func (*Client) GetDatasource ¶
func (r *Client) GetDatasource(id uint) (Datasource, error)
GetDatasource gets an datasource by ID. It reflects GET /api/datasources/:datasourceId API call.
func (*Client) GetDatasourceByName ¶
func (r *Client) GetDatasourceByName(name string) (Datasource, error)
GetDatasourceByName gets an datasource by Name. It reflects GET /api/datasources/name/:datasourceName API call.
func (*Client) GetDatasourceTypes ¶
func (r *Client) GetDatasourceTypes() (map[string]DatasourceType, error)
GetDatasourceTypes gets all available plugins for the datasources. It reflects GET /api/datasources/plugins API call.
func (*Client) GetFolder ¶
func (r *Client) GetFolder(uid string) (resp FolderProperties, err error)
func (*Client) GetRawDashboard ¶
func (r *Client) GetRawDashboard(slug string) ([]byte, BoardProperties, error)
GetRawDashboard loads a dashboard JSON from Grafana instance along with metadata for a dashboard. Contrary to GetDashboard() it not unpack loaded JSON to Board structure. Instead it returns it as byte slice. It guarantee that data of dashboard returned untouched by conversion with Board so no matter how properly fields from a current version of Grafana mapped to our Board fields. It useful for backuping purposes when you want a dashboard exactly with same data as it exported by Grafana.
For dashboards from a filesystem set "file/" prefix for slug. By default dashboards from a database assumed. Database dashboards may have "db/" prefix or may have not, it will be appended automatically.
func (*Client) SearchDashboards ¶
SearchDashboards search dashboards by substring of their title. It allows restrict the result set with only starred dashboards and only for tags (logical OR applied to multiple tags).
func (*Client) SearchUsersWithPaging ¶
SearchUsersWithPaging search users with paging query optional. query value is contained in one of the name, login or email fields. Query values with spaces need to be url encoded e.g. query=Jane%20Doe perpage optional. default 1000 page optional. default 1 http://docs.grafana.org/http_api/user/#search-users http://docs.grafana.org/http_api/user/#search-users-with-paging
func (*Client) SetDashboard ¶
SetDashboard updates existing dashboard or creates a new one. Set dasboard ID to nil to create a new dashboard. Set overwrite to true if you want to overwrite existing dashboard with newer version or with same dashboard title. Grafana only can create or update a dashboard in a database. File dashboards may be only loaded with HTTP API but not created or updated.
func (*Client) SetRawDashboard ¶
SetRawDashboard updates existing dashboard or creates a new one. Contrary to SetDashboard() it accepts raw JSON instead of Board structure. Grafana only can create or update a dashboard in a database. File dashboards may be only loaded with HTTP API but not created or updated.
func (*Client) SwitchUserContext ¶
func (r *Client) SwitchUserContext(uid uint, oid uint) (StatusMessage, error)
func (*Client) UpdateDatasource ¶
func (r *Client) UpdateDatasource(ds Datasource) (StatusMessage, error)
UpdateDatasource updates a datasource from data passed in argument. It reflects PUT /api/datasources/:datasourceId API call.
type Current ¶
type Current struct { Tags []*string `json:"tags,omitempty"` Text string `json:"text"` Value interface{} `json:"value"` // TODO select more precise type }
for templateVar
type CustomPanel ¶
type CustomPanel map[string]interface{}
type DashlistPanel ¶
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"` IsDefault bool `json:"isDefault"` JSONData interface{} `json:"jsonData"` }
Datasource as described in the doc http://docs.grafana.org/reference/http_api/#get-all-datasources
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 FloatString ¶
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 FolderProperties ¶
type FolderProperties 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 FoundBoard ¶
type FoundBoard struct { ID uint `json:"id"` Title string `json:"title"` URI string `json:"uri"` Type string `json:"type"` Tags []string `json:"tags"` IsStarred bool `json:"isStarred"` }
FoundBoard keeps result of search with metadata of a dashboard.
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 *uint `json:"decimals,omitempty"` Fill int `json:"fill"` 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"` } `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 int `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? }
type HeatmapPanel ¶
type HeatmapPanel struct { Cards struct { CardPadding interface{} `json:"cardPadding"` CardRound interface{} `json:"cardRound"` } `json:"cards"` Color struct { CardColor string `json:"cardColor"` ColorScale string `json:"colorScale"` ColorScheme string `json:"colorScheme"` Exponent float64 `json:"exponent"` Mode string `json:"mode"` } `json:"color"` DataFormat string `json:"dataFormat"` Heatmap struct { } `json:"heatmap"` HideZeroBuckets bool `json:"hideZeroBuckets"` HighlightCards bool `json:"highlightCards"` //ID int `json:"id"` Legend struct { Show bool `json:"show"` } `json:"legend"` ReverseYBuckets bool `json:"reverseYBuckets"` TimeFrom interface{} `json:"timeFrom"` TimeShift interface{} `json:"timeShift"` //Title string `json:"title"` Tooltip struct { Show bool `json:"show"` ShowHistogram bool `json:"showHistogram"` } `json:"tooltip"` //Type string `json:"type"` XAxis struct { Show bool `json:"show"` } `json:"xAxis"` XBucketNumber interface{} `json:"xBucketNumber"` XBucketSize interface{} `json:"xBucketSize"` YAxis struct { Decimals interface{} `json:"decimals"` Format string `json:"format"` LogBase int `json:"logBase"` Max interface{} `json:"max"` Min interface{} `json:"min"` Show bool `json:"show"` SplitFactor interface{} `json:"splitFactor"` } `json:"yAxis"` YBucketBound string `json:"yBucketBound"` YBucketNumber interface{} `json:"yBucketNumber"` YBucketSize interface{} `json:"yBucketSize"` Targets []Target `json:"targets,omitempty"` }
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 ¶
type IntString ¶
IntString represents special type for json values that could be strings or ints: 100 or "100"
func NewIntString ¶
func (*IntString) MarshalJSON ¶
MarshalJSON implements custom marshalling for IntString type
func (*IntString) UnmarshalJSON ¶
UnmarshalJSON implements custom unmarshalling for IntString type
type Option ¶
type Option struct { Text string `json:"text"` Value string `json:"value"` Selected bool `json:"selected"` }
for templateVar
type Panel ¶
type Panel struct { // Should be initialized only one type of panels. // OfType field defines which of types below will be used. *GraphPanel *HeatmapPanel *TablePanel *TextPanel *SinglestatPanel *DashlistPanel *PluginlistPanel *RowPanel *AlertlistPanel *CustomPanel // contains filtered or unexported fields }
Panel represents panels of different types defined in Grafana.
func NewAlertlist ¶
func NewDashlist ¶
NewDashlist initializes panel with a dashlist panel.
func NewHeatmap ¶
func NewPluginlist ¶
NewPluginlist initializes panel with a singlestat panel.
func NewSinglestat ¶
NewSinglestat initializes panel with a singlestat panel.
func (*Panel) AddTarget ¶
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 ¶
GetTargets is iterate over all panel targets. It just returns nil if no targets defined for panel of concrete type.
func (*Panel) MarshalJSON ¶
func (*Panel) RepeatDatasourcesForEachTarget ¶
MapDatasources on all existing targets for the panel.
func (*Panel) RepeatTargetsForDatasources ¶
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 ¶
SetTarget updates a target if target with such refId exists or creates a new one.
func (*Panel) UnmarshalJSON ¶
type PluginlistPanel ¶
type PluginlistPanel struct {
Limit int `json:"limit,omitempty"`
}
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) 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) AddTable ¶
func (r *Row) AddTable(data *TablePanel)
type SeriesOverride ¶
type SeriesOverride struct { Alias string `json:"alias"` Bars *bool `json:"bars,omitempty"` Color *string `json:"color,omitempty"` Fill *int `json:"fill,omitempty"` FillBelowTo *string `json:"fillBelowTo,omitempty"` Legend *bool `json:"legend,omitempty"` Lines *bool `json:"lines,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 struct { MaxValue float32 `json:"maxValue"` MinValue float32 `json:"minValue"` Show bool `json:"show"` ThresholdLabels bool `json:"thresholdLabels"` ThresholdMarkers bool `json:"thresholdMarkers"` } `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 struct { FillColor *string `json:"fillColor,omitempty"` Full bool `json:"full,omitempty"` LineColor *string `json:"lineColor,omitempty"` Show bool `json:"show,omitempty"` } `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 StatusMessage ¶
type StatusMessage struct { ID *uint `json:"id"` OrgID *uint `json:"orgId"` Message *string `json:"message"` Slug *string `json:"slug"` Version *int `json:"version"` Status *string `json:"resp"` }
StatusMessage reflects status message as it returned by Grafana REST API.
type TablePanel ¶
type TablePanel struct { Columns []column `json:"columns"` Sort *struct { Col uint `json:"col"` Desc bool `json:"desc"` } `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 string `json:"datasource,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 Elasticsearch DsType *string `json:"dsType,omitempty"` Metrics []struct { ID string `json:"id"` Field string `json:"field"` Type string `json:"type"` Meta interface{} `json:"meta"` Settings interface{} `json:"settings"` } `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"` MinDocCount int `json:"min_doc_count"` } `json:"settings"` } `json:"bucketAggs,omitempty"` // 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 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 *string `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 string `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 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"` // hexidecimal color (e.g. #629e51, only when ColorMode is "custom") FillColor string `json:"fillColor,omitempty"` // hexidecimal color (e.g. #629e51, only when ColorMode is "custom") LineColor string `json:"lineColor,omitempty"` // left or right Yaxis string `json:"yaxis,omitempty"` }
type Timepicker ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
backup-dashboards
This is a simple example of usage of Grafana client for copying dashboards and saving them to a disk.
|
This is a simple example of usage of Grafana client for copying dashboards and saving them to a disk. |
backup-datasources
This is a simple example of usage of Grafana client for copying dashboards and saving them to a disk.
|
This is a simple example of usage of Grafana client for copying dashboards and saving them to a disk. |
import-dashboards
This is a simple example of usage of Grafana client for importing dashboards from a bunch of JSON files (current dir used).
|
This is a simple example of usage of Grafana client for importing dashboards from a bunch of JSON files (current dir used). |
import-dashboards-raw
This is a simple example of usage of Grafana sdk for importing dashboards from a bunch of JSON files (current dir used).
|
This is a simple example of usage of Grafana sdk for importing dashboards from a bunch of JSON files (current dir used). |
import-datasources
This is a simple example of usage of Grafana client for importing datasources from a bunch of JSON files (current dir used).
|
This is a simple example of usage of Grafana client for importing datasources from a bunch of JSON files (current dir used). |