Documentation
¶
Index ¶
- Constants
- Variables
- func CreateDestinationPath(v string)
- func DefaultUserPassword(username string) string
- func GetSlug(title string) string
- func NewDashboardFilter(entries ...string) filters.Filter
- func NewDataSourceFilter(name string) filters.Filter
- func NewFolderFilter() filters.Filter
- func NewTeamFilter(entries ...string) filters.Filter
- func NewUserFilter(label string) filters.Filter
- type AlertNotificationsApi
- type AuthenticationApi
- type CloudStorage
- type ContextStorage
- type DashNGoImpl
- func (s *DashNGoImpl) CreateAPIKey(name, role string, expiration int64) (*models.NewAPIKeyResult, error)
- func (s *DashNGoImpl) CreateServiceAccount(name, role string, expiration int64) (*models.ServiceAccountDTO, error)
- func (s *DashNGoImpl) CreateServiceAccountToken(serviceAccountId int64, name string, expiration int64) (*models.NewAPIKeyResult, error)
- func (s *DashNGoImpl) DeleteAllAlertNotifications() []string
- func (s *DashNGoImpl) DeleteAllDashboards(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllServiceAccounts() []string
- func (s *DashNGoImpl) DeleteAllTokens() []string
- func (s *DashNGoImpl) DeleteAllUsers(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteServiceAccountTokens(serviceId int64) []string
- func (s *DashNGoImpl) DeleteTeam(filter filters.Filter) ([]*models.TeamDTO, error)
- func (s *DashNGoImpl) ExportAlertNotifications() []string
- func (s *DashNGoImpl) ExportDashboards(filterReq filters.Filter)
- func (s *DashNGoImpl) ExportDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportFolderPermissions(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
- func (s *DashNGoImpl) ExportUsers(filter filters.Filter) []models.UserProfileDTO
- func (s *DashNGoImpl) GetServerInfo() map[string]interface{}
- func (s *DashNGoImpl) ImportAlertNotifications() []string
- func (s *DashNGoImpl) ImportDashboards(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportFolderPermissions(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
- func (s *DashNGoImpl) ImportUsers(filter filters.Filter) []string
- func (s *DashNGoImpl) ListAPIKeys() []*models.APIKeyDTO
- func (s *DashNGoImpl) ListAlertNotifications() []*models.AlertNotification
- func (s *DashNGoImpl) ListDashboards(filterReq filters.Filter) []*models.Hit
- func (s *DashNGoImpl) ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
- func (s *DashNGoImpl) ListFolder(filter filters.Filter) []*models.Hit
- func (s *DashNGoImpl) ListFolderPermissions(filter filters.Filter) map[*models.Hit][]*models.DashboardACLInfoDTO
- func (s *DashNGoImpl) ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
- func (s *DashNGoImpl) ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
- func (s *DashNGoImpl) ListOrganizations() []*models.OrgDTO
- func (s *DashNGoImpl) ListServiceAccounts() []*api.ServiceAccountDTOWithTokens
- func (s *DashNGoImpl) ListServiceAccountsTokens(id int64) ([]*models.TokenDTO, error)
- func (s *DashNGoImpl) ListTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
- func (s *DashNGoImpl) ListUsers(filter filters.Filter) []*models.UserSearchHitDTO
- func (s *DashNGoImpl) Login()
- func (s *DashNGoImpl) PromoteUser(userLogin string) (string, error)
- func (s *DashNGoImpl) SetStorage(v Storage)
- type DashboardsApi
- type DataSourcesApi
- type FoldersApi
- type GrafanaService
- type LibraryElementsApi
- type LocalStorage
- type OrganizationsApi
- type ServiceAccountApi
- type Storage
- type TeamsApi
- type TokenApi
- type UserPermission
- type UsersApi
Constants ¶
const ( CloudType = "cloud_type" BucketName = "bucket_name" Prefix = "prefix" Kind = "kind" )
const (
AdminUserPermission = 4
)
const StorageContext = ContextStorage("storage")
Variables ¶
var ( DefaultFolderName = "General" DefaultFolderId = int64(0) )
Functions ¶
func CreateDestinationPath ¶
func CreateDestinationPath(v string)
CreateDestinationPath Handle osMkdir Errors
func DefaultUserPassword ¶
func NewDashboardFilter ¶
func NewFolderFilter ¶
func NewTeamFilter ¶
func NewUserFilter ¶ added in v0.4.5
Types ¶
type AlertNotificationsApi ¶
type AlertNotificationsApi interface {
ListAlertNotifications() []*models.AlertNotification
ImportAlertNotifications() []string
ExportAlertNotifications() []string
DeleteAllAlertNotifications() []string
}
AlertNotificationsApi Contract definition Deprecated: Marked as Deprecated as of Grafana 9.0, Moving to ContactPoints is recommended
type AuthenticationApi ¶
type AuthenticationApi interface {
TokenApi
ServiceAccountApi
Login()
}
AuthenticationApi Contract definition
type CloudStorage ¶
type CloudStorage struct {
BucketRef *blob.Bucket
BucketName string
Prefix string
StorageName string
}
func (*CloudStorage) FindAllFiles ¶
func (s *CloudStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)
func (*CloudStorage) Name ¶
func (s *CloudStorage) Name() string
type ContextStorage ¶
type ContextStorage string
type DashNGoImpl ¶
type DashNGoImpl struct {
// contains filtered or unexported fields
}
func NewDashNGoImpl ¶
func NewDashNGoImpl() *DashNGoImpl
func (*DashNGoImpl) CreateAPIKey ¶
func (s *DashNGoImpl) CreateAPIKey(name, role string, expiration int64) (*models.NewAPIKeyResult, error)
CreateAPIKey create a new key for the given role and expiration specified
func (*DashNGoImpl) CreateServiceAccount ¶
func (s *DashNGoImpl) CreateServiceAccount(name, role string, expiration int64) (*models.ServiceAccountDTO, error)
func (*DashNGoImpl) CreateServiceAccountToken ¶
func (s *DashNGoImpl) CreateServiceAccountToken(serviceAccountId int64, name string, expiration int64) (*models.NewAPIKeyResult, error)
func (*DashNGoImpl) DeleteAllAlertNotifications ¶
func (s *DashNGoImpl) DeleteAllAlertNotifications() []string
Removes all current alert notification channels
func (*DashNGoImpl) DeleteAllDashboards ¶
func (s *DashNGoImpl) DeleteAllDashboards(filter filters.Filter) []string
DeleteAllDashboards clears all current dashboards being monitored. Any folder not white listed will not be affected
func (*DashNGoImpl) DeleteAllDataSources ¶
func (s *DashNGoImpl) DeleteAllDataSources(filter filters.Filter) []string
Removes all current datasources
func (*DashNGoImpl) DeleteAllFolder ¶
func (s *DashNGoImpl) DeleteAllFolder(filter filters.Filter) []string
DeleteAllFolder deletes all the matching folders from grafana
func (*DashNGoImpl) DeleteAllLibraryElements ¶
func (s *DashNGoImpl) DeleteAllLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) DeleteAllServiceAccounts ¶
func (s *DashNGoImpl) DeleteAllServiceAccounts() []string
func (*DashNGoImpl) DeleteAllTokens ¶
func (s *DashNGoImpl) DeleteAllTokens() []string
DeleteAllTokens Deletes all known tokens
func (*DashNGoImpl) DeleteAllUsers ¶
func (s *DashNGoImpl) DeleteAllUsers(filter filters.Filter) []string
DeleteAllUsers remove all users excluding admin or anything matching the filter
func (*DashNGoImpl) DeleteServiceAccountTokens ¶
func (s *DashNGoImpl) DeleteServiceAccountTokens(serviceId int64) []string
func (*DashNGoImpl) DeleteTeam ¶
DeleteTeam removes all Teams
func (*DashNGoImpl) ExportAlertNotifications ¶
func (s *DashNGoImpl) ExportAlertNotifications() []string
ExportAlertNotifications: exports all alert notification channels to grafana. NOTE: credentials will be missing and need to be set manually after export TODO implement configuring sensitive fields for different kinds of alert notification channels
func (*DashNGoImpl) ExportDashboards ¶
func (s *DashNGoImpl) ExportDashboards(filterReq filters.Filter)
ExportDashboards finds all the dashboards in the configured location and exports them to grafana. if the folder doesn't exist, it'll be created.
func (*DashNGoImpl) ExportDataSources ¶
func (s *DashNGoImpl) ExportDataSources(filter filters.Filter) []string
ExportDataSources: exports all datasources to grafana using the credentials configured in config file.
func (*DashNGoImpl) ExportFolder ¶
func (s *DashNGoImpl) ExportFolder(filter filters.Filter) []string
ExportFolder upload all the given folders to grafana
func (*DashNGoImpl) ExportFolderPermissions ¶ added in v0.4.5
func (s *DashNGoImpl) ExportFolderPermissions(filter filters.Filter) []string
ExportFolderPermissions update current folder permissions to match local file system. Note: This expects all the current users and teams to already exist.
func (*DashNGoImpl) ExportLibraryElements ¶
func (s *DashNGoImpl) ExportLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) ExportTeams ¶
func (s *DashNGoImpl) ExportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
Export Teams
func (*DashNGoImpl) ExportUsers ¶
func (s *DashNGoImpl) ExportUsers(filter filters.Filter) []models.UserProfileDTO
func (*DashNGoImpl) GetServerInfo ¶
func (s *DashNGoImpl) GetServerInfo() map[string]interface{}
GetServerInfo returns basic Grafana Server info
func (*DashNGoImpl) ImportAlertNotifications ¶
func (s *DashNGoImpl) ImportAlertNotifications() []string
ImportAlertNotifications: will read in all the configured alert notification channels.
func (*DashNGoImpl) ImportDashboards ¶
func (s *DashNGoImpl) ImportDashboards(filter filters.Filter) []string
ImportDashboards saves all dashboards matching query to configured location
func (*DashNGoImpl) ImportDataSources ¶
func (s *DashNGoImpl) ImportDataSources(filter filters.Filter) []string
ImportDataSources will read in all the configured datasources. NOTE: credentials cannot be retrieved and need to be set via configuration
func (*DashNGoImpl) ImportFolder ¶
func (s *DashNGoImpl) ImportFolder(filter filters.Filter) []string
ImportFolder Download all the given folders matching filter
func (*DashNGoImpl) ImportFolderPermissions ¶ added in v0.4.5
func (s *DashNGoImpl) ImportFolderPermissions(filter filters.Filter) []string
ImportFolderPermissions downloads all the current folder permissions based on filter.
func (*DashNGoImpl) ImportLibraryElements ¶
func (s *DashNGoImpl) ImportLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) ImportTeams ¶
func (s *DashNGoImpl) ImportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
Import Teams
func (*DashNGoImpl) ImportUsers ¶
func (s *DashNGoImpl) ImportUsers(filter filters.Filter) []string
func (*DashNGoImpl) ListAPIKeys ¶
func (s *DashNGoImpl) ListAPIKeys() []*models.APIKeyDTO
ListAPIKeys returns a list of all known API Keys and service accounts
func (*DashNGoImpl) ListAlertNotifications ¶
func (s *DashNGoImpl) ListAlertNotifications() []*models.AlertNotification
func (*DashNGoImpl) ListDashboards ¶
func (s *DashNGoImpl) ListDashboards(filterReq filters.Filter) []*models.Hit
ListDashboards List all dashboards optionally filtered by folder name. If folderFilters is blank, defaults to the configured Monitored folders
func (*DashNGoImpl) ListDataSources ¶
func (s *DashNGoImpl) ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
ListDataSources list all the currently configured datasources
func (*DashNGoImpl) ListFolder ¶
func (s *DashNGoImpl) ListFolder(filter filters.Filter) []*models.Hit
ListFolder list the current existing folders that match the given filter.
func (*DashNGoImpl) ListFolderPermissions ¶ added in v0.4.5
func (s *DashNGoImpl) ListFolderPermissions(filter filters.Filter) map[*models.Hit][]*models.DashboardACLInfoDTO
ListFolderPermissions retrieves all current folder permissions TODO: add concurrency to folder permissions calls
func (*DashNGoImpl) ListLibraryElements ¶
func (s *DashNGoImpl) ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
func (*DashNGoImpl) ListLibraryElementsConnections ¶
func (s *DashNGoImpl) ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
func (*DashNGoImpl) ListOrganizations ¶
func (s *DashNGoImpl) ListOrganizations() []*models.OrgDTO
ListOrganizations: List all dashboards
func (*DashNGoImpl) ListServiceAccounts ¶
func (s *DashNGoImpl) ListServiceAccounts() []*api.ServiceAccountDTOWithTokens
func (*DashNGoImpl) ListServiceAccountsTokens ¶
func (s *DashNGoImpl) ListServiceAccountsTokens(id int64) ([]*models.TokenDTO, error)
func (*DashNGoImpl) ListTeams ¶
func (s *DashNGoImpl) ListTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
List all Teams
func (*DashNGoImpl) ListUsers ¶
func (s *DashNGoImpl) ListUsers(filter filters.Filter) []*models.UserSearchHitDTO
ListUsers list all grafana users
func (*DashNGoImpl) Login ¶
func (s *DashNGoImpl) Login()
Login Logs into grafana returning a legacyClient instance using Token or Basic Auth
func (*DashNGoImpl) PromoteUser ¶
func (s *DashNGoImpl) PromoteUser(userLogin string) (string, error)
PromoteUser promote the user to have Admin Access
type DashboardsApi ¶
type DashboardsApi interface {
ListDashboards(filter filters.Filter) []*models.Hit
ImportDashboards(filter filters.Filter) []string
ExportDashboards(filter filters.Filter)
DeleteAllDashboards(filter filters.Filter) []string
// contains filtered or unexported methods
}
DashboardsApi Contract definition
type DataSourcesApi ¶
type DataSourcesApi interface {
ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
ImportDataSources(filter filters.Filter) []string
ExportDataSources(filter filters.Filter) []string
DeleteAllDataSources(filter filters.Filter) []string
}
DataSourcesApi Contract definition
type FoldersApi ¶
type FoldersApi interface {
ListFolder(filter filters.Filter) []*models.Hit
ImportFolder(filter filters.Filter) []string
ExportFolder(filter filters.Filter) []string
DeleteAllFolder(filter filters.Filter) []string
//Permissions
ListFolderPermissions(filter filters.Filter) map[*models.Hit][]*models.DashboardACLInfoDTO
ImportFolderPermissions(filter filters.Filter) []string
ExportFolderPermissions(filter filters.Filter) []string
}
FoldersApi Contract definition
type GrafanaService ¶
type GrafanaService interface {
OrganizationsApi
DashboardsApi
DataSourcesApi
AlertNotificationsApi
UsersApi
FoldersApi
LibraryElementsApi
TeamsApi
AuthenticationApi
//MetaData
GetServerInfo() map[string]interface{}
}
func NewApiService ¶
func NewApiService(override ...string) GrafanaService
type LibraryElementsApi ¶
type LibraryElementsApi interface {
ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
ImportLibraryElements(filter filters.Filter) []string
ExportLibraryElements(filter filters.Filter) []string
DeleteAllLibraryElements(filter filters.Filter) []string
}
type LocalStorage ¶
type LocalStorage struct {
}
LocalStorage default storage engine
func (*LocalStorage) FindAllFiles ¶
func (s *LocalStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)
func (LocalStorage) Name ¶
func (LocalStorage) Name() string
type OrganizationsApi ¶
OrganizationsApi Contract definition
type ServiceAccountApi ¶
type ServiceAccountApi interface {
ListServiceAccounts() []*api.ServiceAccountDTOWithTokens
ListServiceAccountsTokens(id int64) ([]*models.TokenDTO, error)
DeleteAllServiceAccounts() []string
DeleteServiceAccountTokens(serviceId int64) []string
CreateServiceAccountToken(name int64, role string, expiration int64) (*models.NewAPIKeyResult, error)
CreateServiceAccount(name, role string, expiration int64) (*models.ServiceAccountDTO, error)
}
type Storage ¶
type Storage interface {
WriteFile(filename string, data []byte, mode fs.FileMode) error // WriteFile returns error or writes byte array to destination
ReadFile(filename string) ([]byte, error) // ReadFile returns byte array or error with data from file
FindAllFiles(folder string, fullPath bool) ([]string, error) // FindAllFiles recursively list all files for a given path
Name() string // Name of storage engine
}
TODO: pull all the cloud based interaction into a Plugin System
func NewLocalStorage ¶
type TeamsApi ¶
type TeamsApi interface {
//Team
ImportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
ExportTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
ListTeams(filter filters.Filter) map[*models.TeamDTO][]*models.TeamMemberDTO
DeleteTeam(filter filters.Filter) ([]*models.TeamDTO, error)
}
type UserPermission ¶
type UserPermission models.PermissionType
type UsersApi ¶
type UsersApi interface {
//User
ListUsers(filter filters.Filter) []*models.UserSearchHitDTO
ImportUsers(filter filters.Filter) []string
ExportUsers(filter filters.Filter) []models.UserProfileDTO
PromoteUser(userLogin string) (string, error)
DeleteAllUsers(filter filters.Filter) []string
}
UsersApi Contract definition