grafanadashboard

package
v4.10.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DeleteDashboardByUIDUrl    = "%v/api/dashboards/uid/%v"
	CreateOrUpdateDashboardUrl = "%v/api/dashboards/db"
	CreateOrUpdateFolderUrl    = "%v/api/folders"
	DeleteFolderByUIDUrl       = "%v/api/folders/%v"
	GetFolderByIDUrl           = "%v/api/folders/id/%v"
)
View Source
const (
	ControllerName = "controller_grafanadashboard"
)
View Source
const (
	NonNamespacedFolderName = "Non-Namespaced"
)

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager, namespace string) error

Add creates a new GrafanaDashboard Controller and adds it to the Manager. The Manager will set fields on the Controller and Start it when the Manager is Started.

func SetupWithManager

func SetupWithManager(mgr ctrl.Manager, r reconcile.Reconciler, namespace string) error

SetupWithManager sets up the controller with the Manager.

Types

type DashboardPipeline

type DashboardPipeline interface {
	ProcessDashboard(knownHash string, folderId *int64, folderName string, forceRecreate bool) ([]byte, error)
	NewHash() string
}

func NewDashboardPipeline

func NewDashboardPipeline(client client.Client, dashboard *v1alpha1.GrafanaDashboard, ctx context.Context) DashboardPipeline

type DashboardPipelineImpl

type DashboardPipelineImpl struct {
	Client    client.Client
	Dashboard *v1alpha1.GrafanaDashboard
	JSON      string
	Board     map[string]interface{}
	Logger    logr.Logger
	Hash      string
	Context   context.Context
}

func (*DashboardPipelineImpl) NewHash

func (r *DashboardPipelineImpl) NewHash() string

func (*DashboardPipelineImpl) ProcessDashboard

func (r *DashboardPipelineImpl) ProcessDashboard(knownHash string, folderId *int64, folderName string, forceRecreate bool) ([]byte, error)

type GrafanaClient

type GrafanaClient interface {
	CreateOrUpdateDashboard(dashboard []byte, folderId int64, folderName string) (GrafanaResponse, error)
	DeleteDashboardByUID(UID string) (GrafanaResponse, error)
	CreateOrUpdateFolder(folderName string) (GrafanaFolderResponse, error)
	DeleteFolder(folderID *int64) error
	SafeToDelete(dashboards []*v1alpha1.GrafanaDashboardRef, folderID *int64) bool
	GetDashboard(UID string) (GrafanaDashboardResponse, error)
}

func NewGrafanaClient

func NewGrafanaClient(url, user, password string, transport *http.Transport, timeoutSeconds time.Duration) GrafanaClient

type GrafanaClientImpl

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

func (*GrafanaClientImpl) CreateOrUpdateDashboard

func (r *GrafanaClientImpl) CreateOrUpdateDashboard(dashboard []byte, folderID int64, folderName string) (GrafanaResponse, error)

Submit dashboard json to grafana

func (*GrafanaClientImpl) CreateOrUpdateFolder

func (r *GrafanaClientImpl) CreateOrUpdateFolder(folderInputName string) (GrafanaFolderResponse, error)

func (*GrafanaClientImpl) DeleteDashboardByUID

func (r *GrafanaClientImpl) DeleteDashboardByUID(UID string) (GrafanaResponse, error)

Delete a dashboard given by a UID

func (*GrafanaClientImpl) DeleteFolder

func (r *GrafanaClientImpl) DeleteFolder(deleteID *int64) error

func (*GrafanaClientImpl) GetDashboard

func (r *GrafanaClientImpl) GetDashboard(UID string) (GrafanaDashboardResponse, error)

func (*GrafanaClientImpl) SafeToDelete

func (r *GrafanaClientImpl) SafeToDelete(dashlist []*v1alpha1.GrafanaDashboardRef, id *int64) bool

type GrafanaDashboard

type GrafanaDashboard struct {
	ID      *uint   `json:"id"`
	UID     *string `json:"uid"`
	Title   *string `json:"title"`
	Version *uint   `json:"version"`
}

type GrafanaDashboardMeta

type GrafanaDashboardMeta struct {
	FolderID    *uint   `json:"folderId"`
	FolderTitle *string `json:"folderTitle"`
	Version     *uint   `json:"version"`
}

type GrafanaDashboardReconciler

type GrafanaDashboardReconciler struct {
	Client client.Client
	Scheme *runtime.Scheme

	Log logr.Logger
	// contains filtered or unexported fields
}

GrafanaDashboardReconciler reconciles a GrafanaDashboard object

func (*GrafanaDashboardReconciler) Reconcile

func (r *GrafanaDashboardReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the GrafanaDashboard object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.7.0/pkg/reconcile

func (*GrafanaDashboardReconciler) SetupWithManager

func (r *GrafanaDashboardReconciler) SetupWithManager(mgr manager.Manager) error

type GrafanaDashboardResponse

type GrafanaDashboardResponse struct {
	Meta      *GrafanaDashboardMeta `json:"meta,omitempty"`
	Dashboard *GrafanaDashboard     `json:"dashboard,omitempty"`
}

type GrafanaFolderRequest

type GrafanaFolderRequest struct {
	Title string `json:"title"`
}

type GrafanaFolderResponse

type GrafanaFolderResponse struct {
	ID    *int64 `json:"id"`
	Title string `json:"title"`
	UID   string `json:"uid"`
}

type GrafanaRequest

type GrafanaRequest struct {
	Dashboard  json.RawMessage `json:"dashboard"`
	FolderId   int64           `json:"folderId"`
	FolderName string          `json:"folderName"`
	Overwrite  bool            `json:"overwrite"`
}

type GrafanaResponse

type GrafanaResponse struct {
	ID         *uint   `json:"id"`
	OrgID      *uint   `json:"orgId"`
	Message    *string `json:"message"`
	Slug       *string `json:"slug"`
	Version    *int    `json:"version"`
	Status     *string `json:"resp"`
	UID        *string `json:"uid"`
	URL        *string `json:"url"`
	FolderId   *int64  `json:"folderId"`
	FolderName string  `json:"folderName"`
}

type SourceType

type SourceType int
const (
	SourceTypeJson    SourceType = 1
	SourceTypeJsonnet SourceType = 2
	SourceTypeUnknown SourceType = 3
)

Jump to

Keyboard shortcuts

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