keeper

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadObjectsFromWorkDir

func LoadObjectsFromWorkDir(Grafana GrafanaInterface)

LoadObjectsFromWorkDir is first stage when Grafana-keeper is in Normal keeping Grafana's objects mode Function deletes all datasources and dashboards in Grafana Then it loads objects from work directory Repeat on error with retryInterval until load all Finally save crc32 checksum of all objects Return after all operations will be finished

func SaveAllObjects

func SaveAllObjects(Grafana GrafanaInterface)

SaveAllObjects is what Grafana-keeper do in save-script mode It saves all datasources and dashboards to work directory Call on start when checksum lists are empty for all current objects to be saved Function terminates main process on error

func SaveNewObjectsPeriodically

func SaveNewObjectsPeriodically(Grafana GrafanaInterface)

SaveNewObjectsPeriodically repeat each retryInterval: compare current Grafana objects's checksum with saved on previous step to check if the object has been changed, save all new and changed datasources and dashboards, renew checksum each time while checking objects, continue the loop while Grafana-keeper is active

Types

type Grafana

type Grafana struct {
	BaseURL  string
	WorkDir  string
	SaveFlag bool
	DScrc32  map[int]uint32
	DBcrc32  map[string]uint32
}

Grafana is internal data of GrafanaInterface

func (*Grafana) DeleteAllDashboards

func (grafana *Grafana) DeleteAllDashboards() error

DeleteAllDashboards deletes all Grafana's dashboards

func (*Grafana) DeleteAllDatasources

func (grafana *Grafana) DeleteAllDatasources() error

DeleteAllDatasources deletes all Grafana's datasources

func (*Grafana) GetAllDashboardsCrc32

func (grafana *Grafana) GetAllDashboardsCrc32() error

GetAllDashboardsCrc32 get list of all dashboards, request json data of each and calculate crc32 checksum

func (*Grafana) GetAllDatasourcesCrc32

func (grafana *Grafana) GetAllDatasourcesCrc32() error

GetAllDatasourcesCrc32 get list of all datasources, request json data of each and calculate crc32 checksum

func (*Grafana) IsSaveScriptMode

func (grafana *Grafana) IsSaveScriptMode() bool

IsSaveScriptMode returns save-script mode status

func (*Grafana) LoadAllDashboards

func (grafana *Grafana) LoadAllDashboards() error

LoadAllDashboards loads dashboards from work directory files

func (*Grafana) LoadAllDatasources

func (grafana *Grafana) LoadAllDatasources() error

LoadAllDatasources loads datasources from work directory files

func (*Grafana) SaveNewDashboards

func (grafana *Grafana) SaveNewDashboards() error

SaveNewDashboards saves all new and changed Grafana's dashboards to files in work directory

func (*Grafana) SaveNewDatasources

func (grafana *Grafana) SaveNewDatasources() error

SaveNewDatasources saves all new and changed Grafana's datasources to files in work directory

type GrafanaInterface

type GrafanaInterface interface {
	IsSaveScriptMode() bool
	DeleteAllDatasources() error
	LoadAllDatasources() error
	SaveNewDatasources() error
	GetAllDatasourcesCrc32() error
	DeleteAllDashboards() error
	LoadAllDashboards() error
	SaveNewDashboards() error
	GetAllDashboardsCrc32() error
}

GrafanaInterface to access Grafana API

func Init

func Init() GrafanaInterface

Init should be called first to arrange the Grafana-keeper environment It parse and check command line arguments, set running mode, prepare Grafana's base url with authentication

func NewGrafana

func NewGrafana(baseURL string, workDir string, saveFlag bool) GrafanaInterface

NewGrafana creates GrafanaInterface

Jump to

Keyboard shortcuts

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