grafana

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

README

Grizzly Provider for Grafana Resources

This package contains a Grizzly provider containing a suite of "Handlers" for Grafana resources such as:

  • Dashboards
  • Datasources
  • Alert and Recording Rules
  • Synthetic Monitoring Checks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpClient

func NewHttpClient() (*http.Client, error)

func NewSyntheticMonitoringClient

func NewSyntheticMonitoringClient() (*smapi.Client, error)

NewSyntheticMonitoringClient creates a new client for synthetic monitoring go client

Types

type CTClient

type CTClient interface {
	// contains filtered or unexported methods
}

type CTService

type CTService struct {
}

type Dashboard

type Dashboard map[string]interface{}

Dashboard encapsulates a dashboard

func (*Dashboard) UID

func (d *Dashboard) UID() string

UID retrieves the UID from a dashboard

type DashboardHandler

type DashboardHandler struct {
	Provider Provider
}

DashboardHandler is a Grizzly Handler for Grafana dashboards

func NewDashboardHandler

func NewDashboardHandler(provider Provider) *DashboardHandler

NewDashboardHandler returns configuration defining a new Grafana Dashboard Handler

func (*DashboardHandler) APIVersion

func (h *DashboardHandler) APIVersion() string

APIVersion returns the group and version for the provider of which this handler is a part

func (*DashboardHandler) Add

func (h *DashboardHandler) Add(resource grizzly.Resource) error

Add pushes a new dashboard to Grafana via the API

func (*DashboardHandler) FindResourceFiles

func (h *DashboardHandler) FindResourceFiles(dir string) ([]string, error)

FindResourceFiles identifies files within a directory that this handler can process

func (*DashboardHandler) GetByUID

func (h *DashboardHandler) GetByUID(UID string) (*grizzly.Resource, error)

GetByUID retrieves JSON for a resource from an endpoint, by UID

func (*DashboardHandler) GetExtension

func (h *DashboardHandler) GetExtension() string

GetExtension returns the file name extension for a dashboard

func (*DashboardHandler) GetRemote

func (h *DashboardHandler) GetRemote(resource grizzly.Resource) (*grizzly.Resource, error)

GetRemote retrieves a dashboard as a resource

func (*DashboardHandler) GetUID

func (h *DashboardHandler) GetUID(resource grizzly.Resource) (string, error)

GetUID returns the UID for a resource

func (*DashboardHandler) Kind

func (h *DashboardHandler) Kind() string

Kind returns the name for this handler

func (*DashboardHandler) ListRemote

func (h *DashboardHandler) ListRemote() ([]string, error)

ListRemote retrieves as list of UIDs of all remote resources

func (*DashboardHandler) Parse

Parse parses a manifest object into a struct for this resource type

func (*DashboardHandler) Prepare

func (h *DashboardHandler) Prepare(existing, resource grizzly.Resource) *grizzly.Resource

Prepare gets a resource ready for dispatch to the remote endpoint

func (*DashboardHandler) Preview

func (h *DashboardHandler) Preview(resource grizzly.Resource, opts *grizzly.PreviewOpts) error

Preview renders Jsonnet then pushes them to the endpoint if previews are possible

func (*DashboardHandler) ResourceFilePath

func (h *DashboardHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string

ResourceFilePath returns the location on disk where a resource should be updated

func (*DashboardHandler) Unprepare

func (h *DashboardHandler) Unprepare(resource grizzly.Resource) *grizzly.Resource

Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison

func (*DashboardHandler) Update

func (h *DashboardHandler) Update(existing, resource grizzly.Resource) error

Update pushes a dashboard to Grafana via the API

func (*DashboardHandler) Validate

func (h *DashboardHandler) Validate(resource grizzly.Resource) error

Validate returns the uid of resource

type DashboardWrapper

type DashboardWrapper struct {
	Dashboard Dashboard `json:"dashboard"`
	FolderID  int64     `json:"folderId"`
	Overwrite bool      `json:"overwrite"`
	Meta      struct {
		FolderID    int64  `json:"folderId"`
		FolderTitle string `json:"folderTitle"`
		FolderUID   string `json:"folderUid"`
		FolderURL   string `json:"folderUrl"`
	} `json:"meta"`
}

DashboardWrapper adds wrapper to a dashboard JSON. Caters both for Grafana's POST API as well as GET which require different JSON.

func (*DashboardWrapper) UID

func (d *DashboardWrapper) UID() string

UID retrieves the UID from a dashboard wrapper

type DatasourceHandler

type DatasourceHandler struct {
	Provider Provider
}

DatasourceHandler is a Grizzly Handler for Grafana datasources

func NewDatasourceHandler

func NewDatasourceHandler(provider Provider) *DatasourceHandler

NewDatasourceHandler returns a new Grizzly Handler for Grafana datasources

func (*DatasourceHandler) APIVersion

func (h *DatasourceHandler) APIVersion() string

APIVersion returns group and version of the provider of this resource

func (*DatasourceHandler) Add

func (h *DatasourceHandler) Add(resource grizzly.Resource) error

Add pushes a datasource to Grafana via the API

func (*DatasourceHandler) FindResourceFiles

func (h *DatasourceHandler) FindResourceFiles(dir string) ([]string, error)

FindResourceFiles identifies files within a directory that this handler can process

func (*DatasourceHandler) GetByUID

func (h *DatasourceHandler) GetByUID(UID string) (*grizzly.Resource, error)

GetByUID retrieves JSON for a resource from an endpoint, by UID

func (*DatasourceHandler) GetExtension

func (h *DatasourceHandler) GetExtension() string

GetExtension returns the file name extension for a datasource

func (*DatasourceHandler) GetRemote

func (h *DatasourceHandler) GetRemote(resource grizzly.Resource) (*grizzly.Resource, error)

GetRemote retrieves a datasource as a Resource

func (*DatasourceHandler) GetUID

func (h *DatasourceHandler) GetUID(resource grizzly.Resource) (string, error)

GetUID returns the UID for a resource

func (*DatasourceHandler) Kind

func (h *DatasourceHandler) Kind() string

Kind returns the kind for this handler

func (*DatasourceHandler) ListRemote

func (h *DatasourceHandler) ListRemote() ([]string, error)

ListRemote retrieves as list of UIDs of all remote resources

func (*DatasourceHandler) Parse

Parse parses a manifest object into a struct for this resource type

func (*DatasourceHandler) Prepare

func (h *DatasourceHandler) Prepare(existing, resource grizzly.Resource) *grizzly.Resource

Prepare gets a resource ready for dispatch to the remote endpoint

func (*DatasourceHandler) ResourceFilePath

func (h *DatasourceHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string

ResourceFilePath returns the location on disk where a resource should be updated

func (*DatasourceHandler) Unprepare

func (h *DatasourceHandler) Unprepare(resource grizzly.Resource) *grizzly.Resource

Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison

func (*DatasourceHandler) Update

func (h *DatasourceHandler) Update(existing, resource grizzly.Resource) error

Update pushes a datasource to Grafana via the API

func (*DatasourceHandler) Validate

func (h *DatasourceHandler) Validate(resource grizzly.Resource) error

Validate returns the uid of resource

type ErrNon200Response

type ErrNon200Response struct {
	Type     string
	UID      string
	Response *http.Response
}

func NewErrNon200Response

func NewErrNon200Response(typ, uid string, resp *http.Response) ErrNon200Response

func (ErrNon200Response) Error

func (e ErrNon200Response) Error() string

type ErrUidsMissing

type ErrUidsMissing []string

ErrUidsMissing reports UIDs are missing for Dashboards

func (ErrUidsMissing) Error

func (e ErrUidsMissing) Error() string

type Folder

type Folder map[string]interface{}

func (*Folder) ID

func (f *Folder) ID() float64

func (*Folder) UID

func (f *Folder) UID() string

type FolderHandler

type FolderHandler struct {
	Provider Provider
}

FolderHandler is a Grizzly Handler for Grafana dashboard folders

func NewFolderHandler

func NewFolderHandler(provider Provider) *FolderHandler

NewFolderHandler returns configuration defining a new Grafana Folder Handler

func (*FolderHandler) APIVersion

func (h *FolderHandler) APIVersion() string

APIVersion returns the group and version for the provider of which this handler is a part

func (*FolderHandler) Add

func (h *FolderHandler) Add(resource grizzly.Resource) error

Add pushes a new folder to Grafana via the API

func (*FolderHandler) FindResourceFiles

func (h *FolderHandler) FindResourceFiles(dir string) ([]string, error)

FindResourceFiles identifies files within a directory that this handler can process

func (*FolderHandler) GetByUID

func (h *FolderHandler) GetByUID(UID string) (*grizzly.Resource, error)

GetByUID retrieves JSON for a resource from an endpoint, by UID

func (*FolderHandler) GetExtension

func (h *FolderHandler) GetExtension() string

GetExtension returns the file name extension for a dashboard

func (*FolderHandler) GetRemote

func (h *FolderHandler) GetRemote(resource grizzly.Resource) (*grizzly.Resource, error)

GetRemote retrieves a folder as a resource

func (*FolderHandler) GetUID

func (h *FolderHandler) GetUID(resource grizzly.Resource) (string, error)

GetUID returns the UID for a resource

func (*FolderHandler) Kind

func (h *FolderHandler) Kind() string

Kind returns the name for this handler

func (*FolderHandler) ListRemote

func (h *FolderHandler) ListRemote() ([]string, error)

ListRemote retrieves as list of UIDs of all remote resources

func (*FolderHandler) Parse

Parse parses a manifest object into a struct for this resource type

func (*FolderHandler) Prepare

func (h *FolderHandler) Prepare(existing, resource grizzly.Resource) *grizzly.Resource

Prepare gets a resource ready for dispatch to the remote endpoint

func (*FolderHandler) ResourceFilePath

func (h *FolderHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string

ResourceFilePath returns the location on disk where a resource should be updated

func (*FolderHandler) Unprepare

func (h *FolderHandler) Unprepare(resource grizzly.Resource) *grizzly.Resource

Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison

func (*FolderHandler) Update

func (h *FolderHandler) Update(existing, resource grizzly.Resource) error

Update pushes a folder to Grafana via the API

func (*FolderHandler) Validate

func (h *FolderHandler) Validate(resource grizzly.Resource) error

Validate returns the uid of resource

type Probes

type Probes struct {
	ByID   map[int64]synthetic_monitoring.Probe
	ByName map[string]synthetic_monitoring.Probe
}

type PrometheusRuleGroup

type PrometheusRuleGroup struct {
	Namespace string                   `yaml:"-"`
	Name      string                   `yaml:"name"`
	Rules     []map[string]interface{} `yaml:"rules"`
}

PrometheusRuleGroup encapsulates a list of rules

type PrometheusRuleGrouping

type PrometheusRuleGrouping struct {
	Namespace string                `json:"namespace"`
	Groups    []PrometheusRuleGroup `json:"groups"`
}

PrometheusRuleGrouping encapsulates a set of named rule groups

type Provider

type Provider struct{}

Provider defines a Grafana Provider

func (*Provider) APIVersion

func (p *Provider) APIVersion() string

APIVersion returns the group and version of this provider

func (*Provider) GetHandlers

func (p *Provider) GetHandlers() []grizzly.Handler

GetHandlers identifies the handlers for the Grafana provider

func (*Provider) Group

func (p *Provider) Group() string

Group returns the group name of the Grafana provider

func (*Provider) Version

func (p *Provider) Version() string

Version returns the version of this provider

type RuleHandler

type RuleHandler struct {
	Provider Provider
}

RuleHandler is a Grizzly Handler for Prometheus Rules

func NewRuleHandler

func NewRuleHandler(provider Provider) *RuleHandler

NewRuleHandler returns a new Grizzly Handler for Prometheus Rules

func (*RuleHandler) APIVersion

func (h *RuleHandler) APIVersion() string

APIVersion returns the group and version for the provider of which this handler is a part

func (*RuleHandler) Add

func (h *RuleHandler) Add(resource grizzly.Resource) error

Add pushes a datasource to Grafana via the API

func (*RuleHandler) FindResourceFiles

func (h *RuleHandler) FindResourceFiles(dir string) ([]string, error)

FindResourceFiles identifies files within a directory that this handler can process

func (*RuleHandler) GetByUID

func (h *RuleHandler) GetByUID(UID string) (*grizzly.Resource, error)

GetByUID retrieves JSON for a resource from an endpoint, by UID

func (*RuleHandler) GetExtension

func (h *RuleHandler) GetExtension() string

GetExtension returns the file name extension for a rule grouping

func (*RuleHandler) GetRemote

func (h *RuleHandler) GetRemote(resource grizzly.Resource) (*grizzly.Resource, error)

GetRemote retrieves a datasource as a Resource

func (*RuleHandler) GetUID

func (h *RuleHandler) GetUID(resource grizzly.Resource) (string, error)

GetUID returns the UID for a resource

func (*RuleHandler) Kind

func (h *RuleHandler) Kind() string

Kind returns the name for this handler

func (*RuleHandler) ListRemote

func (h *RuleHandler) ListRemote() ([]string, error)

ListRemote retrieves as list of UIDs of all remote resources

func (*RuleHandler) Parse

Parse parses a manifest object into a struct for this resource type

func (*RuleHandler) Prepare

func (h *RuleHandler) Prepare(existing, resource grizzly.Resource) *grizzly.Resource

Prepare gets a resource ready for dispatch to the remote endpoint

func (*RuleHandler) ResourceFilePath

func (h *RuleHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string

ResourceFilePath returns the location on disk where a resource should be updated

func (*RuleHandler) Unprepare

func (h *RuleHandler) Unprepare(resource grizzly.Resource) *grizzly.Resource

Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison

func (*RuleHandler) Update

func (h *RuleHandler) Update(existing, resource grizzly.Resource) error

Update pushes a datasource to Grafana via the API

func (*RuleHandler) Validate

func (h *RuleHandler) Validate(resource grizzly.Resource) error

Validate returns the uid of resource

type SnapshotResp

type SnapshotResp struct {
	DeleteKey string `json:"deleteKey"`
	DeleteURL string `json:"deleteUrl"`
	Key       string `json:"key"`
	URL       string `json:"url"`
}

SnapshotResp encapsulates the response to a snapshot request

type SyntheticMonitoringHandler

type SyntheticMonitoringHandler struct {
	Provider Provider
}

SyntheticMonitoringHandler is a Grizzly Handler for Grafana Synthetic Monitoring

func NewSyntheticMonitoringHandler

func NewSyntheticMonitoringHandler(provider Provider) *SyntheticMonitoringHandler

NewSyntheticMonitoringHandler returns a Grizzly Handler for Grafana Synthetic Monitoring

func (*SyntheticMonitoringHandler) APIVersion

func (h *SyntheticMonitoringHandler) APIVersion() string

APIVersion returns the group and version for the provider of which this handler is a part

func (*SyntheticMonitoringHandler) Add

Add adds a new check to the SyntheticMonitoring endpoint

func (*SyntheticMonitoringHandler) FindResourceFiles

func (h *SyntheticMonitoringHandler) FindResourceFiles(dir string) ([]string, error)

FindResourceFiles identifies files within a directory that this handler can process

func (*SyntheticMonitoringHandler) GetByUID

GetByUID retrieves JSON for a resource from an endpoint, by UID

func (*SyntheticMonitoringHandler) GetExtension

func (h *SyntheticMonitoringHandler) GetExtension() string

GetExtension returns the file name extension for a check

func (*SyntheticMonitoringHandler) GetRemote

func (h *SyntheticMonitoringHandler) GetRemote(resource grizzly.Resource) (*grizzly.Resource, error)

GetRemote retrieves a datasource as a Resource

func (*SyntheticMonitoringHandler) GetUID

func (h *SyntheticMonitoringHandler) GetUID(resource grizzly.Resource) (string, error)

GetUID returns the UID for a resource

func (*SyntheticMonitoringHandler) Kind

Kind returns the name for this handler

func (*SyntheticMonitoringHandler) ListRemote

func (h *SyntheticMonitoringHandler) ListRemote() ([]string, error)

ListRemote retrieves as list of UIDs of all remote resources

func (*SyntheticMonitoringHandler) Parse

Parse parses a manifest object into a struct for this resource type

func (*SyntheticMonitoringHandler) Prepare

func (h *SyntheticMonitoringHandler) Prepare(existing, resource grizzly.Resource) *grizzly.Resource

Prepare gets a resource ready for dispatch to the remote endpoint

func (*SyntheticMonitoringHandler) ResourceFilePath

func (h *SyntheticMonitoringHandler) ResourceFilePath(resource grizzly.Resource, filetype string) string

ResourceFilePath returns the location on disk where a resource should be updated

func (*SyntheticMonitoringHandler) Unprepare

Unprepare removes unnecessary elements from a remote resource ready for presentation/comparison

func (*SyntheticMonitoringHandler) Update

func (h *SyntheticMonitoringHandler) Update(existing, resource grizzly.Resource) error

Update pushes an updated check to the SyntheticMonitoring endpoing

func (*SyntheticMonitoringHandler) Validate

func (h *SyntheticMonitoringHandler) Validate(resource grizzly.Resource) error

Validate returns the uid of resource

Jump to

Keyboard shortcuts

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