dashbuilder

package
v0.0.0-...-9480115 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpJSON

func DumpJSON(obj any) string

func Template

func Template(tmpl string, templateContext any) (string, error)

Types

type Builder

type Builder struct {
	*Templates
}

func NewBuilder

func NewBuilder(t *Templates) *Builder

func (*Builder) BuildPanel

func (b *Builder) BuildPanel(pc PanelContext) (resultPanel *grafana.Panel, err error)

func (*Builder) InitPanelDefault

func (b *Builder) InitPanelDefault(p *grafana.Panel)

func (*Builder) InitTargetDefault

func (b *Builder) InitTargetDefault(metricType, metricName string, t *grafana.Target, pc PanelContext)

type Config

type Config struct {
	GrafanaURL        string                    `json:"grafana_url" yaml:"grafana_url"`
	GrafanaToken      string                    `json:"grafana_token" yaml:"grafana_token"`
	PrometheusURL     string                    `json:"prometheus_url" yaml:"prometheus_url"`
	Templates         map[string]*grafana.Panel `json:"templates" yaml:"templates"`
	PanelLoaderConfig []*PanelConfig            `json:"panels" yaml:"panels"`
}

type Desc

type Desc interface {
	Name() string
	Description() string
	Unit() string
	MetricType() string
}

type Loader

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

func NewLoader

func NewLoader(cli *prometheus.Client) *Loader

func (*Loader) LoadMetricMetadata

func (l *Loader) LoadMetricMetadata(ctx context.Context, m string) (*prometheus.Metadata, error)

func (*Loader) LoadPanelContext

func (l *Loader) LoadPanelContext(ctx context.Context, templates *Templates, panels []*PanelConfig) (map[string]PanelContext, error)

type PanelConfig

type PanelConfig struct {
	Name         string         `json:"name" yaml:"name"`
	Folder       string         `json:"folder" yaml:"folder"`
	TemplateName string         `json:"template" yaml:"template"`
	Customs      map[string]any `json:"customs" yaml:"customs"`
}

type PanelContext

type PanelContext struct {
	Name         string
	Folder       string
	MD           prometheus.Metadata
	Template     grafana.Panel
	TemplateJSON []byte
	Customs      map[string]any
}

type Templates

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

func NewTemplates

func NewTemplates(cfg *Config) (*Templates, error)

func (*Templates) GetTemplate

func (t *Templates) GetTemplate(key string) (template *grafana.Panel, templateJson []byte, ok bool)

Jump to

Keyboard shortcuts

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