Documentation ¶
Index ¶
- Constants
- Variables
- func TimeToGrafanaString(t time.Time) string
- type AlertNotification
- type Annotation
- type Client
- func (c *Client) AddOrgUser(orgId int64, user, role string) error
- func (c *Client) AlertNotification(id int64) (*AlertNotification, error)
- func (c *Client) Annotations(params map[string]string) ([]Annotation, error)
- func (c *Client) CreateUser(user User) (int64, error)
- func (c *Client) Dashboard(slug string) (*Dashboard, error)deprecated
- func (c *Client) DataSource(id int64) (*DataSource, error)
- func (c *Client) DeleteAlertNotification(id int64) error
- func (c *Client) DeleteAnnotation(id int64) (string, error)
- func (c *Client) DeleteAnnotationByRegionID(id int64) (string, error)
- func (c *Client) DeleteDashboard(uid string) (string, error)
- func (c *Client) DeleteDataSource(id int64) error
- func (c *Client) DeleteFolder(id string) error
- func (c *Client) DeleteOrg(id int64) error
- func (c *Client) DeletePlaylist(id int64) error
- func (c *Client) DeleteUser(id int64) error
- func (c *Client) ExportPanelAsImage(dashboardID string, orgID int64, panelID int64, timeRange TimeRange, ...) error
- func (c *Client) Folder(id int64) (*Folder, error)
- func (c *Client) FolderByUID(uid string) (*Folder, error)
- func (c *Client) Folders() ([]Folder, error)
- func (c *Client) GetDashboard(uid string) (*Dashboard, error)
- func (c *Client) NewAlertNotification(a *AlertNotification) (int64, error)
- func (c *Client) NewAnnotation(a *Annotation) (int64, error)
- func (c *Client) NewDashboard(dashboard Dashboard) (*DashboardSaveResponse, error)
- func (c *Client) NewDataSource(s *DataSource) (int64, error)
- func (c *Client) NewFolder(title string) (Folder, error)
- func (c *Client) NewFolderWithUID(title, uid string) (Folder, error)
- func (c *Client) NewGraphiteAnnotation(gfa *GraphiteAnnotation) (int64, error)
- func (c *Client) NewOrg(name string) (int64, error)
- func (c *Client) NewPlaylist(s *Playlist) (int64, error)
- func (c *Client) Org(id int64) (Org, error)
- func (c *Client) OrgByName(name string) (Org, error)
- func (c *Client) OrgUsers(orgId int64) ([]OrgUser, error)
- func (c *Client) Orgs() ([]Org, error)
- func (c *Client) Playlist(id int64) (*Playlist, error)
- func (c *Client) RemoveOrgUser(orgId, userId int64) error
- func (c *Client) SaveDashboard(model map[string]interface{}, overwrite bool) (*DashboardSaveResponse, error)deprecated
- func (c *Client) SearchDashboard(query string, folderID string) ([]Dashboards, error)
- func (c *Client) SearchFolder(query string) ([]Folder, error)
- func (c *Client) UpdateAlertNotification(a *AlertNotification) error
- func (c *Client) UpdateAnnotation(a *Annotation) (int64, error)
- func (c *Client) UpdateDataSource(s *DataSource) error
- func (c *Client) UpdateFolder(id string, name string) error
- func (c *Client) UpdateOrg(id int64, name string) error
- func (c *Client) UpdateOrgUser(orgId, userId int64, role string) error
- func (c *Client) UpdatePlaylist(s *Playlist) error
- func (c *Client) UserByEmail(email string) (User, error)
- func (c *Client) Users() ([]User, error)
- type Dashboard
- type DashboardAnnotation
- type DashboardDeleteResponse
- type DashboardMeta
- type DashboardModel
- type DashboardPanel
- type DashboardSaveResponse
- type Dashboards
- type DataSource
- type Folder
- type GrafanaPanelExportSize
- type GraphiteAnnotation
- type JSONData
- type Link
- type Org
- type OrgUser
- type Playlist
- type PlaylistItem
- type SecureJSONData
- type TimeRange
- type User
Constants ¶
const ( // GrafanaAPIPanelRender Base for the Grafana Render API GrafanaAPIPanelRender = "/render/d-solo" // GrafanaAPIPanelRenderWidth Default Panel Export Width GrafanaAPIPanelRenderWidth = 1000 // GrafanaAPIPanelRenderHeight Default Panel Export Height GrafanaAPIPanelRenderHeight = 500 )
Variables ¶
var MissingQueryParameterError error
MissingQueryParameterError the error Type for Missing Query Parameters
Functions ¶
func TimeToGrafanaString ¶
Types ¶
type AlertNotification ¶
type Annotation ¶
type Annotation struct { ID int64 `json:"id,omitempty"` AlertID int64 `json:"alertId,omitempty"` DashboardID int64 `json:"dashboardId"` PanelID int64 `json:"panelId"` UserID int64 `json:"userId,omitempty"` UserName string `json:"userName,omitempty"` NewState string `json:"newState,omitempty"` PrevState string `json:"prevState,omitempty"` Time int64 `json:"time"` TimeEnd int64 `json:"timeEnd,omitempty"` Text string `json:"text"` Metric string `json:"metric,omitempty"` RegionID int64 `json:"regionId,omitempty"` Type string `json:"type,omitempty"` Tags []string `json:"tags,omitempty"` IsRegion bool `json:"isRegion,omitempty"` }
Annotation represents a Grafana API Annotation
type Client ¶
func New ¶
New creates a new grafana client auth can be in user:pass format, or it can be an api key
func (*Client) AlertNotification ¶
func (c *Client) AlertNotification(id int64) (*AlertNotification, error)
func (*Client) Annotations ¶
func (c *Client) Annotations(params map[string]string) ([]Annotation, error)
Annotations fetches the annotations queried with the params it's passed
func (*Client) DataSource ¶
func (c *Client) DataSource(id int64) (*DataSource, error)
func (*Client) DeleteAlertNotification ¶
func (*Client) DeleteAnnotation ¶
DeleteAnnotation deletes the annotation of the ID it is passed
func (*Client) DeleteAnnotationByRegionID ¶
DeleteAnnotationByRegionID deletes the annotation corresponding to the region ID it is passed
func (*Client) DeleteDashboard ¶
DeleteDashboard deletes a grafana dashoboard
func (*Client) DeleteDataSource ¶
func (*Client) DeleteFolder ¶
func (*Client) DeletePlaylist ¶
func (*Client) DeleteUser ¶
func (*Client) ExportPanelAsImage ¶
func (c *Client) ExportPanelAsImage( dashboardID string, orgID int64, panelID int64, timeRange TimeRange, exportSize GrafanaPanelExportSize, dashboardVars map[string][]string, timeZone string, output string) error
ExportPanelAsImage a Grafana Panel to the Local Filesystem Save the Panel as PNG
func (*Client) GetDashboard ¶
GetDashboard get a dashboard by UID
func (*Client) NewAlertNotification ¶
func (c *Client) NewAlertNotification(a *AlertNotification) (int64, error)
func (*Client) NewAnnotation ¶
func (c *Client) NewAnnotation(a *Annotation) (int64, error)
NewAnnotation creates a new annotation with the Annotation it is passed
func (*Client) NewDashboard ¶
func (c *Client) NewDashboard(dashboard Dashboard) (*DashboardSaveResponse, error)
func (*Client) NewDataSource ¶
func (c *Client) NewDataSource(s *DataSource) (int64, error)
func (*Client) NewFolderWithUID ¶
NewFolderWithUID allows to create a new folder by specifying a custom UID. It is duplicated in order to maintain compatibility with existent tools
func (*Client) NewGraphiteAnnotation ¶
func (c *Client) NewGraphiteAnnotation(gfa *GraphiteAnnotation) (int64, error)
NewGraphiteAnnotation creates a new annotation with the GraphiteAnnotation it is passed
func (*Client) RemoveOrgUser ¶
func (*Client) SaveDashboard
deprecated
func (c *Client) SaveDashboard(model map[string]interface{}, overwrite bool) (*DashboardSaveResponse, error)
Deprecated: use NewDashboard instead
func (*Client) SearchDashboard ¶
func (c *Client) SearchDashboard(query string, folderID string) ([]Dashboards, error)
SearchDashboard search a dashboard in Grafana
func (*Client) SearchFolder ¶
SearchFolder search a folder in Grafana
func (*Client) UpdateAlertNotification ¶
func (c *Client) UpdateAlertNotification(a *AlertNotification) error
func (*Client) UpdateAnnotation ¶
func (c *Client) UpdateAnnotation(a *Annotation) (int64, error)
UpdateAnnotation updates an existing annotation with the Annotation it is passed
func (*Client) UpdateDataSource ¶
func (c *Client) UpdateDataSource(s *DataSource) error
func (*Client) UpdateOrgUser ¶
func (*Client) UpdatePlaylist ¶
type Dashboard ¶
type Dashboard struct { Meta DashboardMeta `json:"meta"` Model DashboardModel `json:"dashboard"` Folder int64 `json:"folderId"` Overwrite bool `json:"overwrite"` }
func (Dashboard) FrontendURL ¶
func (Dashboard) GetPanelFromDashboard ¶
func (d Dashboard) GetPanelFromDashboard(panelID int64) (DashboardPanel, error)
GetPanelFromDashboard Returns the Panel from a dashboard by given PanelID
type DashboardAnnotation ¶
type DashboardDeleteResponse ¶
type DashboardDeleteResponse struct {
Title string `json:title`
}
DashboardDeleteResponse grafana response for delete dashboard
type DashboardMeta ¶
type DashboardModel ¶
type DashboardModel struct { Annotations struct { List []DashboardAnnotation `json:"list"` } `json:"annotations"` Editable bool `json:"editable"` GnetID interface{} `json:"gnetId"` GraphTooltip int `json:"graphTooltip"` ID int `json:"id"` Iteration int64 `json:"iteration"` Links []Link `json:"links"` Panels []DashboardPanel `json:"panels"` Refresh bool `json:"refresh"` SchemaVersion int `json:"schemaVersion"` Style string `json:"style"` Tags []interface{} `json:"tags"` Templating struct { List []struct { AllValue interface{} `json:"allValue"` Current struct { Text string `json:"text"` Value string `json:"value"` } `json:"current"` Hide int `json:"hide"` IncludeAll bool `json:"includeAll"` Label interface{} `json:"label"` Multi bool `json:"multi"` Name string `json:"name"` Options []struct { Selected bool `json:"selected"` Text string `json:"text"` Value string `json:"value"` } `json:"options"` Query string `json:"query"` SkipURLSync bool `json:"skipUrlSync"` Type string `json:"type"` } `json:"list"` } `json:"templating"` Time TimeRange `json:"time"` Timepicker struct { RefreshIntervals []string `json:"refresh_intervals"` } `json:"timepicker"` Timezone string `json:"timezone"` Title string `json:"title"` UID string `json:"uid"` Version int `json:"version"` }
type DashboardPanel ¶
type DashboardPanel struct { Bars bool `json:"bars"` DashLength int `json:"dashLength"` Dashes bool `json:"dashes"` Description string `json:"description"` Fill int `json:"fill"` FillGradient int `json:"fillGradient"` GridPos struct { H int `json:"h"` W int `json:"w"` X int `json:"x"` Y int `json:"y"` } `json:"gridPos"` ID int64 `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"` } `json:"legend"` Lines bool `json:"lines"` Linewidth int `json:"linewidth"` Links []Link `json:"links"` NullPointMode string `json:"nullPointMode"` Options struct { DataLinks []interface{} `json:"dataLinks"` } `json:"options"` 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"` Thresholds []interface{} `json:"thresholds"` TimeFrom interface{} `json:"timeFrom"` TimeRegions []interface{} `json:"timeRegions"` 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"` 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"` 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"` Yaxis struct { Align bool `json:"align"` AlignLevel interface{} `json:"alignLevel"` } `json:"yaxis"` }
func (DashboardPanel) AsPartOfUrl ¶
func (p DashboardPanel) AsPartOfUrl() string
type DashboardSaveResponse ¶
type DashboardSaveResponse struct { Slug string `json:"slug"` ID int64 `json:"id"` UID string `json:"uid"` URL string `json:"url"` Status string `json:"status"` Version int64 `json:"version"` }
DashboardSaveResponse grafana response for create dashboard
type Dashboards ¶
type Dashboards struct { ID int64 `json:"id"` UID string `json:"uid"` Title string `json:"title"` URI string `json:"uri"` URL string `json:"url"` Starred bool `json:"isStarred"` FolderID int64 `json:"folderId"` FolderUID string `json:"folderUid"` FolderTitle string `json:"folderTitle"` }
Dashboards represent json returned by search API
type DataSource ¶
type DataSource struct { Id int64 `json:"id,omitempty"` Name string `json:"name"` Type string `json:"type"` URL string `json:"url"` Access string `json:"access"` Database string `json:"database,omitempty"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` OrgId int64 `json:"orgId,omitempty"` IsDefault bool `json:"isDefault"` ReadOnly bool `json:"readOnly"` BasicAuth bool `json:"basicAuth"` BasicAuthUser string `json:"basicAuthUser,omitempty"` BasicAuthPassword string `json:"basicAuthPassword,omitempty"` JSONData JSONData `json:"jsonData,omitempty"` SecureJSONData SecureJSONData `json:"secureJsonData,omitempty"` }
type GrafanaPanelExportSize ¶
func (GrafanaPanelExportSize) AsPartOfUrl ¶
func (size GrafanaPanelExportSize) AsPartOfUrl() (string, error)
func (*GrafanaPanelExportSize) New ¶
func (size *GrafanaPanelExportSize) New(width int, height int)
type GraphiteAnnotation ¶
type GraphiteAnnotation struct { What string `json:"what"` When int64 `json:"when"` Data string `json:"data"` Tags []string `json:"tags,omitempty"` }
GraphiteAnnotation represents a Grafana API annotation in Graphite format
type JSONData ¶
type JSONData struct { // CloudWatch specific AssumeRoleArn string `json:"assumeRoleArn,omitempty"` AuthType string `json:"authType,omitempty"` CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"` DefaultRegion string `json:"defaultRegion,omitempty"` // Graphite specific GraphiteVersion string `json:"graphiteVersion,omitempty"` // Elasticsearch specific EsVersion int64 `json:"esVersion,omitempty"` Interval string `json:"interval,omitempty"` MaxConcurrentShardRequests int64 `json:"maxConcurrentShardRequests,omitempty"` TimeField string `json:"timeField,omitempty"` // OpenTSDB specific TSDBResolution int64 `json:"tsdbResolution,omitempty"` TSDBVersion int64 `json:"tsdbVersion,omitempty"` // PostgreSQL specific SSLMode string `json:"sslmode,omitempty"` // Prometheus specific QueryTimeout string `json:"queryTimeout,omitempty"` // General KeepCookies []string `json:"keepCookies,omitempty"` ScrapeInterval string `json:"timeInterval,omitempty"` }
JSONData is a representation of the datasource `jsonData` property
type Playlist ¶
type Playlist struct { Id int64 `json:"id,omitempty"` Name string `json:"name"` Interval string `json:"interval"` URL string `json:"url"` Items []PlaylistItem `json:"items"` }
type PlaylistItem ¶
type SecureJSONData ¶
type SecureJSONData struct { // CloudWatch specific AccessKey string `json:"accessKey,omitempty"` SecretKey string `json:"secretKey,omitempty"` // General Password string `json:"password,omitempty"` }
SecureJSONData is a representation of the datasource `secureJsonData` property