Documentation ¶
Index ¶
- Variables
- func FixUneditableRule(d *Dashboard)
- func Inspect(node syntax.Expr, f func(syntax.Expr) bool)
- type Annotation
- type ConfigurationEntry
- type ConfigurationFile
- type ConfigurationRuleEntries
- type Dashboard
- type DashboardResult
- type DashboardRuleFunc
- func NewTemplateDatasourceRule() *DashboardRuleFunc
- func NewTemplateInstanceRule() *DashboardRuleFunc
- func NewTemplateJobRule() *DashboardRuleFunc
- func NewTemplateLabelPromQLRule() *DashboardRuleFunc
- func NewTemplateOnTimeRangeReloadRule() *DashboardRuleFunc
- func NewUneditableRule() *DashboardRuleFunc
- type DashboardRuleResults
- type Datasource
- type FieldConfig
- type FixableResult
- type Input
- type Panel
- type PanelResult
- type PanelRuleFunc
- type PanelRuleResults
- type RawTemplateValue
- type ReduceOptions
- type Result
- type ResultContext
- type ResultSet
- type Row
- type Rule
- func NewDashboardRuleFunc(name, description string, fn func(Dashboard) DashboardRuleResults) Rule
- func NewPanelRuleFunc(name, description string, fn func(Dashboard, Panel) PanelRuleResults) Rule
- func NewTargetRuleFunc(name, description string, fn func(Dashboard, Panel, Target) TargetRuleResults) Rule
- type RuleResults
- type RuleSet
- type Severity
- type StatOptions
- type Target
- type TargetResult
- type TargetRuleFunc
- func NewTargetCounterAggRule() *TargetRuleFunc
- func NewTargetInstanceRule() *TargetRuleFunc
- func NewTargetJobRule() *TargetRuleFunc
- func NewTargetLogQLAutoRule() *TargetRuleFunc
- func NewTargetLogQLRule() *TargetRuleFunc
- func NewTargetPromQLRule() *TargetRuleFunc
- func NewTargetRateIntervalRule() *TargetRuleFunc
- type TargetRuleResults
- type Template
- type TemplateValue
Constants ¶
This section is empty.
Variables ¶
var ResultSuccess = Result{ Severity: Success, Message: "OK", }
Functions ¶
func FixUneditableRule ¶
func FixUneditableRule(d *Dashboard)
Types ¶
type Annotation ¶
type Annotation struct { Name string `json:"name"` Datasource interface{} `json:"datasource,omitempty"` }
func (*Annotation) GetDataSource ¶
func (a *Annotation) GetDataSource() (Datasource, error)
type ConfigurationEntry ¶
type ConfigurationEntry struct { Reason string `json:"reason,omitempty"` Dashboard string `json:"dashboard,omitempty"` Panel string `json:"panel,omitempty"` // Alerts are currently included, so we can read in configuration for Mixtool. Alert string `json:"alert,omitempty"` // This gets (un)marshalled as a string, because a 0 index is valid, but also the zero value of an int TargetIdx string `json:"targetIdx"` }
ConfigurationEntry will exist precisely once for every instance of a rule violation you wish exclude or downgrade to a warning. Each ConfigurationEntry will have to be an *exact* match to the combination of attributes set. Reason will not be evaluated, and is an opportunity for the author to explain why the exception, or downgrade to warning exists.
func (*ConfigurationEntry) IsMatch ¶
func (ce *ConfigurationEntry) IsMatch(r ResultContext) bool
type ConfigurationFile ¶
type ConfigurationFile struct { Exclusions map[string]*ConfigurationRuleEntries `yaml:"exclusions"` Warnings map[string]*ConfigurationRuleEntries `yaml:"warnings"` Verbose bool `yaml:"-"` Autofix bool `yaml:"-"` }
ConfigurationFile contains a map for rule exclusions, and warnings, where the key is the rule name to be excluded or downgraded to a warning
func NewConfigurationFile ¶
func NewConfigurationFile() *ConfigurationFile
func (*ConfigurationFile) Apply ¶
func (cf *ConfigurationFile) Apply(res ResultContext) ResultContext
func (*ConfigurationFile) Load ¶
func (cf *ConfigurationFile) Load(path string) error
type ConfigurationRuleEntries ¶
type ConfigurationRuleEntries struct { Reason string `json:"reason,omitempty"` Entries []ConfigurationEntry `json:"entries,omitempty"` }
func (*ConfigurationRuleEntries) AddEntry ¶
func (cre *ConfigurationRuleEntries) AddEntry(e ConfigurationEntry)
type Dashboard ¶
type Dashboard struct { Inputs []Input `json:"__inputs"` Title string `json:"title,omitempty"` Templating struct { List []Template `json:"list"` } `json:"templating"` Annotations struct { List []Annotation `json:"list"` } `json:"annotations"` Rows []Row `json:"rows,omitempty"` Panels []Panel `json:"panels,omitempty"` Editable bool `json:"editable,omitempty"` }
Dashboard is a deliberately incomplete representation of the Dashboard type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
func NewDashboard ¶
func (*Dashboard) GetPanels ¶
GetPanels returns the all panels whether they are nested in the (now deprecated) "rows" property or in the top level "panels" property. This also monkeypatches Target.Idx into each panel which is used to uniquely identify panel targets while linting.
func (*Dashboard) GetTemplateByType ¶
GetTemplateByType returns all dashboard templates which match the provided type. Type comparison is case insensitive as it uses strings.EqualFold()
type DashboardResult ¶
type DashboardRuleFunc ¶
type DashboardRuleFunc struct {
// contains filtered or unexported fields
}
func NewTemplateDatasourceRule ¶
func NewTemplateDatasourceRule() *DashboardRuleFunc
func NewTemplateInstanceRule ¶
func NewTemplateInstanceRule() *DashboardRuleFunc
func NewTemplateJobRule ¶
func NewTemplateJobRule() *DashboardRuleFunc
func NewTemplateLabelPromQLRule ¶
func NewTemplateLabelPromQLRule() *DashboardRuleFunc
func NewTemplateOnTimeRangeReloadRule ¶
func NewTemplateOnTimeRangeReloadRule() *DashboardRuleFunc
func NewUneditableRule ¶
func NewUneditableRule() *DashboardRuleFunc
func (DashboardRuleFunc) Description ¶
func (f DashboardRuleFunc) Description() string
func (DashboardRuleFunc) Lint ¶
func (f DashboardRuleFunc) Lint(d Dashboard, s *ResultSet)
func (DashboardRuleFunc) Name ¶
func (f DashboardRuleFunc) Name() string
type DashboardRuleResults ¶
type DashboardRuleResults struct {
Results []DashboardResult
}
func (*DashboardRuleResults) AddError ¶
func (r *DashboardRuleResults) AddError(d Dashboard, message string)
func (*DashboardRuleResults) AddFixableError ¶
func (r *DashboardRuleResults) AddFixableError(d Dashboard, message string, fix func(*Dashboard))
func (*DashboardRuleResults) AddWarning ¶
func (r *DashboardRuleResults) AddWarning(d Dashboard, message string)
type Datasource ¶
func GetDataSource ¶
func GetDataSource(raw interface{}) (Datasource, error)
type FieldConfig ¶
type FieldConfig struct { Defaults dashboard.FieldConfig Overrides []dashboard.DashboardFieldConfigSourceOverrides }
type FixableResult ¶
type Input ¶
type Input struct { Name string `json:"name"` Label string `json:"label"` Type string `json:"type"` PluginID string `json:"pluginId"` }
Input is a deliberately incomplete representation of the Dashboard -> Input type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
type Panel ¶
type Panel struct { Id int `json:"id"` Title string `json:"title"` Description string `json:"description,omitempty"` Targets []Target `json:"targets,omitempty"` Datasource interface{} `json:"datasource,omitempty"` Type string `json:"type"` Panels []Panel `json:"panels,omitempty"` FieldConfig *FieldConfig `json:"fieldConfig,omitempty"` Options json.RawMessage `json:"options,omitempty"` }
Panel is a deliberately incomplete representation of the Dashboard -> Panel type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
func (*Panel) GetDataSource ¶
func (p *Panel) GetDataSource() (Datasource, error)
type PanelResult ¶
type PanelRuleFunc ¶
type PanelRuleFunc struct {
// contains filtered or unexported fields
}
func NewPanelDatasourceRule ¶
func NewPanelDatasourceRule() *PanelRuleFunc
func NewPanelNoTargetsRule ¶
func NewPanelNoTargetsRule() *PanelRuleFunc
func NewPanelTitleDescriptionRule ¶
func NewPanelTitleDescriptionRule() *PanelRuleFunc
func NewPanelUnitsRule ¶
func NewPanelUnitsRule() *PanelRuleFunc
func (PanelRuleFunc) Description ¶
func (f PanelRuleFunc) Description() string
func (PanelRuleFunc) Lint ¶
func (f PanelRuleFunc) Lint(d Dashboard, s *ResultSet)
func (PanelRuleFunc) Name ¶
func (f PanelRuleFunc) Name() string
type PanelRuleResults ¶
type PanelRuleResults struct {
Results []PanelResult
}
type RawTemplateValue ¶
type RawTemplateValue map[string]interface{}
func (*RawTemplateValue) Get ¶
func (raw *RawTemplateValue) Get() (TemplateValue, error)
type ReduceOptions ¶
type ReduceOptions struct {
Fields string `json:"fields,omitempty"`
}
oversimplified Reduce options
type ResultContext ¶
type ResultContext struct { Result RuleResults Rule Rule Dashboard *Dashboard Panel *Panel Target *Target }
ResultContext is used by ResultSet to keep all the state data about a lint execution and it's results.
type ResultSet ¶
type ResultSet struct {
// contains filtered or unexported fields
}
func (*ResultSet) AddResult ¶
func (rs *ResultSet) AddResult(r ResultContext)
AddResult adds a result to the ResultSet, applying the current configuration if set
func (*ResultSet) ByRule ¶
func (rs *ResultSet) ByRule() map[string][]ResultContext
func (*ResultSet) Configure ¶
func (rs *ResultSet) Configure(c *ConfigurationFile)
Configure adds, and applies the provided configuration to all results currently in the ResultSet
func (*ResultSet) MaximumSeverity ¶
func (*ResultSet) ReportByRule ¶
func (rs *ResultSet) ReportByRule()
type Row ¶
type Row struct {
Panels []Panel `json:"panels,omitempty"`
}
Row is a deliberately incomplete representation of the Dashboard -> Row type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
type Rule ¶
func NewDashboardRuleFunc ¶
func NewDashboardRuleFunc(name, description string, fn func(Dashboard) DashboardRuleResults) Rule
func NewPanelRuleFunc ¶
func NewPanelRuleFunc(name, description string, fn func(Dashboard, Panel) PanelRuleResults) Rule
func NewTargetRuleFunc ¶
type RuleResults ¶
type RuleResults struct {
Results []FixableResult
}
type RuleSet ¶
type RuleSet struct {
// contains filtered or unexported fields
}
RuleSet contains a list of linting rules.
func NewRuleSet ¶
func NewRuleSet() RuleSet
type StatOptions ¶
type StatOptions struct {
ReduceOptions ReduceOptions `json:"reduceOptions,omitempty"`
}
Stat panel options is a deliberately incomplete representation of the stat panel options from grafana. The properties which are extracted from JSON are only those used for linting purposes.
type Target ¶
type Target struct { Idx int `json:"-"` // This is the only (best?) way to uniquely identify a target, it is set by GetPanels Datasource interface{} `json:"datasource,omitempty"` Expr string `json:"expr,omitempty"` PanelId int `json:"panelId,omitempty"` RefId string `json:"refId,omitempty"` Hide bool `json:"hide"` }
Target is a deliberately incomplete representation of the Dashboard -> Panel -> Target type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
func (*Target) GetDataSource ¶
func (t *Target) GetDataSource() (Datasource, error)
type TargetRuleFunc ¶
type TargetRuleFunc struct {
// contains filtered or unexported fields
}
func NewTargetCounterAggRule ¶
func NewTargetCounterAggRule() *TargetRuleFunc
func NewTargetInstanceRule ¶
func NewTargetInstanceRule() *TargetRuleFunc
func NewTargetJobRule ¶
func NewTargetJobRule() *TargetRuleFunc
func NewTargetLogQLAutoRule ¶
func NewTargetLogQLAutoRule() *TargetRuleFunc
func NewTargetLogQLRule ¶
func NewTargetLogQLRule() *TargetRuleFunc
func NewTargetPromQLRule ¶
func NewTargetPromQLRule() *TargetRuleFunc
NewTargetPromQLRule builds a lint rule for panels with Prometheus queries which checks: - the query is valid PromQL - the query contains two matchers within every selector - `{job=~"$job", instance=~"$instance"}` - the query is not empty - if the query references another panel then make sure that panel exists
func NewTargetRateIntervalRule ¶
func NewTargetRateIntervalRule() *TargetRuleFunc
NewTargetRateIntervalRule builds a lint rule for panels with Prometheus queries which checks all range vector selectors use $__rate_interval.
func (TargetRuleFunc) Description ¶
func (f TargetRuleFunc) Description() string
func (TargetRuleFunc) Lint ¶
func (f TargetRuleFunc) Lint(d Dashboard, s *ResultSet)
func (TargetRuleFunc) Name ¶
func (f TargetRuleFunc) Name() string
type TargetRuleResults ¶
type TargetRuleResults struct {
Results []TargetResult
}
type Template ¶
type Template struct { Name string `json:"name"` Label string `json:"label"` Type string `json:"type"` RawQuery interface{} `json:"query"` Query string `json:"-"` Datasource interface{} `json:"datasource,omitempty"` Multi bool `json:"multi"` AllValue string `json:"allValue,omitempty"` Current RawTemplateValue `json:"current"` Options []RawTemplateValue `json:"options"` Refresh int `json:"refresh"` }
Target is a deliberately incomplete representation of the Dashboard -> Template type in grafana. The properties which are extracted from JSON are only those used for linting purposes.
func (*Template) GetDataSource ¶
func (t *Template) GetDataSource() (Datasource, error)
func (*Template) UnmarshalJSON ¶
type TemplateValue ¶
Source Files ¶
- configuration.go
- constants.go
- lint.go
- results.go
- rule_panel_datasource.go
- rule_panel_no_targets.go
- rule_panel_title_description.go
- rule_panel_units.go
- rule_target_counter_agg.go
- rule_target_job_instance.go
- rule_target_logql.go
- rule_target_logql_auto.go
- rule_target_promql.go
- rule_target_rate_interval.go
- rule_template_datasource.go
- rule_template_instance.go
- rule_template_job.go
- rule_template_label_promql.go
- rule_template_on_time_change_reload.go
- rule_uneditable.go
- rules.go
- target_utils.go
- variables.go