grafana

package
v0.0.0-...-17f80f1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDashboard

func DeleteDashboard(options *DeleteOptions) error

func NewAlertRule

func NewAlertRule(options *AlertOptions) *alerting.RuleBuilder

func NewContactPoint

func NewContactPoint(options *ContactPointOptions) *alerting.ContactPointBuilder

func NewNotificationTemplatesFromFile

func NewNotificationTemplatesFromFile(filepath string) (map[string]alerting.NotificationTemplate, error)

func Pointer

func Pointer[T any](d T) *T

Types

type AlertOptions

type AlertOptions struct {
	Name              string
	Summary           string
	Description       string
	RunbookURL        string
	For               string
	NoDataState       alerting.RuleNoDataState
	RuleExecErrState  alerting.RuleExecErrState
	Tags              map[string]string
	Query             []RuleQuery
	QueryRefCondition string
	Condition         []ConditionQuery
}

type Builder

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

func NewBuilder

func NewBuilder(options *BuilderOptions) *Builder

func (*Builder) AddAlert

func (b *Builder) AddAlert(alerts ...*alerting.RuleBuilder)

func (*Builder) AddContactPoint

func (b *Builder) AddContactPoint(contactPoints ...*alerting.ContactPointBuilder)

func (*Builder) AddNotificationPolicy

func (b *Builder) AddNotificationPolicy(notificationPolicies ...*alerting.NotificationPolicyBuilder)

func (*Builder) AddPanel

func (b *Builder) AddPanel(panel ...*Panel)

func (*Builder) AddRow

func (b *Builder) AddRow(title string)

func (*Builder) AddVars

func (b *Builder) AddVars(items ...cog.Builder[dashboard.VariableModel])

func (*Builder) Build

func (b *Builder) Build() (*Dashboard, error)

type BuilderOptions

type BuilderOptions struct {
	Name       string
	Tags       []string
	Refresh    string
	TimeFrom   string
	TimeTo     string
	TimeZone   string
	AlertsTags map[string]string
}

type ConditionQuery

type ConditionQuery struct {
	RefID               string
	IntervalMs          *float64
	MaxDataPoints       *int64
	ReduceExpression    *ReduceExpression
	MathExpression      *MathExpression
	ResampleExpression  *ResampleExpression
	ThresholdExpression *ThresholdExpression
}

type ContactPointOptions

type ContactPointOptions struct {
	Name     string
	Type     alerting.ContactPointType
	Settings map[string]interface{}
}

type CustomVariableOptions

type CustomVariableOptions struct {
	*VariableOption
	Values map[string]any
}

type Dashboard

type Dashboard struct {
	Dashboard            *dashboard.Dashboard
	Alerts               []alerting.Rule
	ContactPoints        []alerting.ContactPoint
	NotificationPolicies []alerting.NotificationPolicy
}

func (*Dashboard) DeployToGrafana

func (db *Dashboard) DeployToGrafana(options *DeployOptions) error

func (*Dashboard) GenerateJSON

func (db *Dashboard) GenerateJSON() ([]byte, error)

type DataSource

type DataSource struct {
	Name string
	UID  string
}

func GetDataSourceFromGrafana

func GetDataSourceFromGrafana(name string, grafanaURL string, grafanaToken string) (*DataSource, error)

func NewDataSource

func NewDataSource(name, uid string) *DataSource

type DeleteOptions

type DeleteOptions struct {
	Name         string
	GrafanaURL   string
	GrafanaToken string
}

type DeployOptions

type DeployOptions struct {
	GrafanaURL            string
	GrafanaToken          string
	FolderName            string
	EnableAlerts          bool
	NotificationTemplates string
}

type GaugePanelOptions

type GaugePanelOptions struct {
	*PanelOptions
}

type HeatmapPanelOptions

type HeatmapPanelOptions struct {
	*PanelOptions
}

type IntervalVariableOptions

type IntervalVariableOptions struct {
	*VariableOption
	Interval string
}

type LegendOptions

type LegendOptions struct {
	Placement   common.LegendPlacement
	DisplayMode common.LegendDisplayMode
	Calcs       []string
}

type LogPanelOptions

type LogPanelOptions struct {
	*PanelOptions
}

type MathExpression

type MathExpression struct {
	Expression string
}

type NotificationPolicyOptions

type NotificationPolicyOptions struct {
	Continue          *bool
	GroupBy           []string
	GroupInterval     string
	GroupWait         string
	MuteTimeIntervals []string
	Receiver          string // must match name of ContactPoint Name
	ObjectMatchers    []alerting.ObjectMatcher
	Provenance        *alerting.Provenance
	RepeatInterval    string
	Routes            []*alerting.NotificationPolicyBuilder
}

type Panel

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

func NewGaugePanel

func NewGaugePanel(options *GaugePanelOptions) *Panel

func NewHeatmapPanel

func NewHeatmapPanel(options *HeatmapPanelOptions) *Panel

func NewLogPanel

func NewLogPanel(options *LogPanelOptions) *Panel

func NewStatPanel

func NewStatPanel(options *StatPanelOptions) *Panel

func NewTablePanel

func NewTablePanel(options *TablePanelOptions) *Panel

func NewTimeSeriesPanel

func NewTimeSeriesPanel(options *TimeSeriesPanelOptions) *Panel

type PanelOptions

type PanelOptions struct {
	Datasource  string
	Title       string
	Description string
	Span        uint32
	Height      uint32
	Decimals    float64
	Unit        string
	NoValue     string
	Min         *float64
	Max         *float64
	Query       []Query
	Threshold   *ThresholdOptions
	Transform   *TransformOptions
	ColorScheme dashboard.FieldColorModeId
}

type Query

type Query struct {
	Expr    string
	Legend  string
	Instant bool
	Min     float64
	Format  prometheus.PromQueryFormat
}

type QueryVariableOptions

type QueryVariableOptions struct {
	*VariableOption
	Datasource    string
	Query         string
	Multi         bool
	Regex         string
	IncludeAll    bool
	QueryWithType map[string]any
	Hide          *dashboard.VariableHide
}

type ReduceExpression

type ReduceExpression struct {
	Expression string
	Reducer    expr.TypeReduceReducer
}

type ResampleExpression

type ResampleExpression struct {
	Expression  string
	DownSampler expr.TypeResampleDownsampler
	UpSampler   expr.TypeResampleUpsampler
}

type RuleQuery

type RuleQuery struct {
	Expr         string
	RefID        string
	Datasource   string
	LegendFormat string
	Instant      bool
}

type StatPanelOptions

type StatPanelOptions struct {
	*PanelOptions
	TextSize    float64
	ValueSize   float64
	JustifyMode common.BigValueJustifyMode
	ColorMode   common.BigValueColorMode
	GraphMode   common.BigValueGraphMode
	TextMode    common.BigValueTextMode
	Orientation common.VizOrientation
	Mappings    []dashboard.ValueMapping
}

type TablePanelOptions

type TablePanelOptions struct {
	*PanelOptions
}

type ThresholdConditionsOption

type ThresholdConditionsOption struct {
	Params []float64
	Type   TypeThresholdType
}

type ThresholdExpression

type ThresholdExpression struct {
	Expression                 string
	ThresholdConditionsOptions ThresholdConditionsOption
}

type ThresholdOptions

type ThresholdOptions struct {
	Mode  dashboard.ThresholdsMode
	Steps []dashboard.Threshold
}

type TimeSeriesPanelOptions

type TimeSeriesPanelOptions struct {
	*PanelOptions
	AlertOptions      *AlertOptions
	FillOpacity       float64
	ScaleDistribution common.ScaleDistribution
	LegendOptions     *LegendOptions
	ThresholdStyle    common.GraphThresholdsStyleMode
}

type TransformOptions

type TransformOptions struct {
	ID      string
	Options map[string]string
}

type TypePlatform

type TypePlatform string
const (
	TypePlatformKubernetes TypePlatform = "kubernetes"
	TypePlatformDocker     TypePlatform = "docker"
)

type TypeThresholdType

type TypeThresholdType string
const (
	TypeThresholdTypeGt           TypeThresholdType = "gt"
	TypeThresholdTypeLt           TypeThresholdType = "lt"
	TypeThresholdTypeWithinRange  TypeThresholdType = "within_range"
	TypeThresholdTypeOutsideRange TypeThresholdType = "outside_range"
)

type VariableOption

type VariableOption struct {
	Name         string
	Label        string
	Description  string
	CurrentText  string
	CurrentValue string
}

type VariableOptionValues

type VariableOptionValues struct {
}

Jump to

Keyboard shortcuts

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