grafana

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 26 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

View Source
const (
	GlobalAlertNotificationPolicyName = "global"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse added in v0.3.0

type APIResponse interface {
	Code() int
	Error() string
	String() string
}

type AlertContactPointHandler added in v0.3.0

type AlertContactPointHandler struct {
	grizzly.BaseHandler
}

AlertContactPointHandler is a Grizzly Handler for Grafana contactPoints

func NewAlertContactPointHandler added in v0.3.0

func NewAlertContactPointHandler(provider grizzly.Provider) *AlertContactPointHandler

NewAlertContactPointHandler returns a new Grizzly Handler for Grafana contactPoints

func (*AlertContactPointHandler) Add added in v0.3.0

Add pushes a contactPoint to Grafana via the API

func (*AlertContactPointHandler) GetByUID added in v0.3.0

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

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

func (*AlertContactPointHandler) GetRemote added in v0.3.0

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

GetRemote retrieves a contactPoint as a Resource

func (*AlertContactPointHandler) GetSpecUID added in v0.4.0

func (h *AlertContactPointHandler) GetSpecUID(resource grizzly.Resource) (string, error)

func (*AlertContactPointHandler) ListRemote added in v0.3.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*AlertContactPointHandler) Parse added in v0.3.0

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

func (*AlertContactPointHandler) ResourceFilePath added in v0.3.0

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

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

func (*AlertContactPointHandler) Update added in v0.3.0

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

Update pushes a contactPoint to Grafana via the API

func (*AlertContactPointHandler) Validate added in v0.3.0

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

Validate returns the uid of resource

type AlertNotificationPolicyHandler added in v0.3.0

type AlertNotificationPolicyHandler struct {
	grizzly.BaseHandler
}

AlertNotificationPolicyHandler is a Grizzly Handler for Grafana alertNotificationPolicies

func NewAlertNotificationPolicyHandler added in v0.3.0

func NewAlertNotificationPolicyHandler(provider grizzly.Provider) *AlertNotificationPolicyHandler

NewAlertNotificationPolicyHandler returns a new Grizzly Handler for Grafana alertNotificationPolicies

func (*AlertNotificationPolicyHandler) Add added in v0.3.0

Add pushes a alertNotificationPolicy to Grafana via the API

func (*AlertNotificationPolicyHandler) GetByUID added in v0.3.0

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

func (*AlertNotificationPolicyHandler) GetRemote added in v0.3.0

GetRemote retrieves a alertNotificationPolicy as a Resource

func (*AlertNotificationPolicyHandler) GetSpecUID added in v0.4.0

func (h *AlertNotificationPolicyHandler) GetSpecUID(resource grizzly.Resource) (string, error)

func (*AlertNotificationPolicyHandler) ListRemote added in v0.3.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*AlertNotificationPolicyHandler) Parse added in v0.3.0

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

func (*AlertNotificationPolicyHandler) ResourceFilePath added in v0.3.0

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

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

func (*AlertNotificationPolicyHandler) Update added in v0.3.0

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

Update pushes a alertNotificationPolicy to Grafana via the API

func (*AlertNotificationPolicyHandler) Validate added in v0.3.0

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

Validate returns the uid of resource

type AlertRuleGroupHandler added in v0.3.0

type AlertRuleGroupHandler struct {
	grizzly.BaseHandler
}

AlertRuleGroupHandler is a Grizzly Handler for Grafana alertRuleGroups

func NewAlertRuleGroupHandler added in v0.3.0

func NewAlertRuleGroupHandler(provider grizzly.Provider) *AlertRuleGroupHandler

NewAlertRuleGroupHandler returns a new Grizzly Handler for Grafana alertRuleGroups

func (*AlertRuleGroupHandler) Add added in v0.3.0

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

Add pushes a alertRuleGroup to Grafana via the API

func (*AlertRuleGroupHandler) GetByUID added in v0.3.0

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

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

func (*AlertRuleGroupHandler) GetRemote added in v0.3.0

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

GetRemote retrieves a alertRuleGroup as a Resource

func (*AlertRuleGroupHandler) GetSpecUID added in v0.4.0

func (h *AlertRuleGroupHandler) GetSpecUID(resource grizzly.Resource) (string, error)

func (*AlertRuleGroupHandler) ListRemote added in v0.3.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*AlertRuleGroupHandler) Parse added in v0.3.0

func (h *AlertRuleGroupHandler) Parse(m map[string]any) (*grizzly.Resource, error)

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

func (*AlertRuleGroupHandler) ResourceFilePath added in v0.3.0

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

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

func (*AlertRuleGroupHandler) Update added in v0.3.0

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

Update pushes a alertRuleGroup to Grafana via the API

func (*AlertRuleGroupHandler) Validate added in v0.3.0

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

Validate checks that the uid format is valid

type ClientProvider added in v0.3.0

type ClientProvider interface {
	Client() (*gclient.GrafanaHTTPAPI, error)
	Config() *config.GrafanaConfig
}

type DashboardHandler

type DashboardHandler struct {
	grizzly.BaseHandler
}

DashboardHandler is a Grizzly Handler for Grafana dashboards

func NewDashboardHandler

func NewDashboardHandler(provider grizzly.Provider) *DashboardHandler

NewDashboardHandler returns configuration defining a new Grafana Dashboard Handler

func (*DashboardHandler) Add

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

Add pushes a new dashboard to Grafana via the API

func (*DashboardHandler) DashboardJSONGetHandler added in v0.4.0

func (h *DashboardHandler) DashboardJSONGetHandler(p grizzly.Server) http.HandlerFunc

func (*DashboardHandler) DashboardJSONPostHandler added in v0.4.0

func (h *DashboardHandler) DashboardJSONPostHandler(p grizzly.Server) http.HandlerFunc

func (*DashboardHandler) Detect added in v0.4.0

func (h *DashboardHandler) Detect(data map[string]any) bool

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) GetProxyEndpoints added in v0.4.0

func (h *DashboardHandler) GetProxyEndpoints(p grizzly.Server) []grizzly.ProxyEndpoint

func (*DashboardHandler) GetRemote

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

GetRemote retrieves a dashboard as a resource

func (*DashboardHandler) GetSpecUID added in v0.4.0

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

func (*DashboardHandler) ListRemote added in v0.2.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*DashboardHandler) Parse

func (h *DashboardHandler) Parse(m map[string]any) (*grizzly.Resource, error)

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) ProxyURL added in v0.4.0

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

func (*DashboardHandler) ResourceFilePath added in v0.2.0

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

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

func (*DashboardHandler) RootDashboardPageHandler added in v0.4.0

func (h *DashboardHandler) RootDashboardPageHandler(p grizzly.Server) http.HandlerFunc

func (*DashboardHandler) Snapshot added in v0.4.1

func (h *DashboardHandler) Snapshot(resource grizzly.Resource, expiresSeconds int) error

Snapshot pushes dashboards as snapshots

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 added in v0.2.0

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

Validate returns the uid of resource

type DatasourceHandler

type DatasourceHandler struct {
	grizzly.BaseHandler
}

DatasourceHandler is a Grizzly Handler for Grafana datasources

func NewDatasourceHandler

func NewDatasourceHandler(provider grizzly.Provider) *DatasourceHandler

NewDatasourceHandler returns a new Grizzly Handler for Grafana datasources

func (*DatasourceHandler) Add

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

Add pushes a datasource to Grafana via the API

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) GetRemote

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

GetRemote retrieves a datasource as a Resource

func (*DatasourceHandler) GetSpecUID added in v0.4.0

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

func (*DatasourceHandler) ListRemote added in v0.2.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*DatasourceHandler) Parse

func (h *DatasourceHandler) Parse(m map[string]any) (*grizzly.Resource, error)

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 added in v0.2.0

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 added in v0.2.0

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

Validate returns the uid of resource

type ErrUidsMissing

type ErrUidsMissing []string

ErrUidsMissing reports UIDs are missing for Dashboards

func (ErrUidsMissing) Error

func (e ErrUidsMissing) Error() string

type FolderHandler added in v0.2.0

type FolderHandler struct {
	grizzly.BaseHandler
}

FolderHandler is a Grizzly Handler for Grafana dashboard folders

func NewFolderHandler added in v0.2.0

func NewFolderHandler(provider grizzly.Provider) *FolderHandler

NewFolderHandler returns configuration defining a new Grafana Folder Handler

func (*FolderHandler) Add added in v0.2.0

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

Add pushes a new folder to Grafana via the API

func (*FolderHandler) GetByUID added in v0.2.0

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

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

func (*FolderHandler) GetRemote added in v0.2.0

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

GetRemote retrieves a folder as a resource

func (*FolderHandler) GetSpecUID added in v0.4.0

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

func (*FolderHandler) ListRemote added in v0.2.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*FolderHandler) Parse added in v0.2.0

func (h *FolderHandler) Parse(m map[string]any) (*grizzly.Resource, error)

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

func (*FolderHandler) ResourceFilePath added in v0.2.0

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

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

func (*FolderHandler) Sort added in v0.4.0

func (h *FolderHandler) Sort(resources grizzly.Resources) grizzly.Resources

Sort sorts according to handler needs

func (*FolderHandler) Update added in v0.2.0

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

Update pushes a folder to Grafana via the API

func (*FolderHandler) Validate added in v0.2.0

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

Validate returns the uid of resource

type LibraryElementHandler added in v0.3.0

type LibraryElementHandler struct {
	grizzly.BaseHandler
}

LibraryElementHandler is a Grizzly Handler for Grafana dashboard folders

func NewLibraryElementHandler added in v0.3.0

func NewLibraryElementHandler(provider grizzly.Provider) *LibraryElementHandler

NewLibraryElementHandler returns configuration defining a new Grafana Library Element Handler

func (*LibraryElementHandler) Add added in v0.3.0

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

Add pushes a new element to Grafana via the API

func (*LibraryElementHandler) GetByUID added in v0.3.0

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

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

func (*LibraryElementHandler) GetRemote added in v0.3.0

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

GetRemote retrieves an element as a resource

func (*LibraryElementHandler) GetSpecUID added in v0.4.0

func (h *LibraryElementHandler) GetSpecUID(resource grizzly.Resource) (string, error)

func (*LibraryElementHandler) ListRemote added in v0.3.0

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

ListRemote retrieves as list of UIDs of all remote resources

func (*LibraryElementHandler) Parse added in v0.3.0

func (h *LibraryElementHandler) Parse(m map[string]any) (*grizzly.Resource, error)

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

func (*LibraryElementHandler) Prepare added in v0.3.0

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

Prepare gets a resource ready for dispatch to the remote endpoint

func (*LibraryElementHandler) ResourceFilePath added in v0.3.0

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

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

func (*LibraryElementHandler) Unprepare added in v0.3.0

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

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

func (*LibraryElementHandler) Update added in v0.3.0

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

Update pushes an element to Grafana via the API

func (*LibraryElementHandler) Validate added in v0.3.0

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

Validate returns the uid of resource

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is a grizzly.Provider implementation for Grafana.

func NewProvider added in v0.3.0

func NewProvider(config *config.GrafanaConfig) (*Provider, error)

NewProvider instantiates a new Provider.

func (*Provider) APIVersion

func (p *Provider) APIVersion() string

APIVersion returns the group and version of this provider

func (*Provider) Client added in v0.3.0

func (p *Provider) Client() (*gclient.GrafanaHTTPAPI, error)

func (*Provider) Config added in v0.4.0

func (p *Provider) Config() *config.GrafanaConfig

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) Name added in v0.4.1

func (p *Provider) Name() string

func (*Provider) SetupProxy added in v0.4.0

func (p *Provider) SetupProxy() (*httputil.ReverseProxy, error)

func (*Provider) Version

func (p *Provider) Version() string

Version returns the version of this provider

Jump to

Keyboard shortcuts

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