Documentation
¶
Index ¶
- Constants
- type Builder
- func (b *Builder) AddSection(file, group, name, expression string, failed, success []string)
- func (b *Builder) AddTotalCheckedGroups(count int)
- func (b *Builder) Dump() error
- func (b *Builder) DumpJSON() error
- func (b *Builder) DumpPrometheusMetrics() error
- func (b *Builder) DumpTree() error
- func (b *Builder) DumpYAML() error
- func (b *Builder) HasContent() bool
- func (b *Builder) ToJSON() (string, error)
- func (b *Builder) ToPrometheusMetrics() error
- func (b *Builder) ToTree() (string, error)
- func (b *Builder) ToYAML() (string, error)
- type BuilderOption
- type Report
- type Section
- type Sections
- type Tree
Constants ¶
const ( // DefaultFormat dumps Report as Text. DefaultFormat = "graph" // YAMLFormat dumps Report as YAML. YAMLFormat = "yaml" // JSONFormat dumps Report as JSON. JSONFormat = "json" // PrometheusFormat converts Report to Prometheus metrics. // This format is only used internally by Promcheck and cannot be set via cli flags. PrometheusFormat = "prometheus" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// Report represents the report data
Report Report `json:"promcheck" yaml:"promcheck"`
// contains filtered or unexported fields
}
Builder represents the report.
func (*Builder) AddSection ¶
AddSection adds a new section to the report.
func (*Builder) AddTotalCheckedGroups ¶ added in v1.0.2
AddTotalCheckedGroups adds checked groups to the total amount. TotalGroups is used for report metrics.
func (*Builder) DumpJSON ¶
DumpJSON prints the report to the builder's output target in json format.
func (*Builder) DumpPrometheusMetrics ¶ added in v1.1.0
DumpPrometheusMetrics converts the report to Prometheus metrics.
func (*Builder) DumpTree ¶
DumpTree prints the report to the builder's output target in text format.
func (*Builder) DumpYAML ¶
DumpYAML prints the report to the builder's output target in yaml format.
func (*Builder) HasContent ¶
HasContent checks if we actually have anything to report.
func (*Builder) ToPrometheusMetrics ¶ added in v1.1.0
ToPrometheusMetrics returns the report as Prometheus metrics served by the exporter.
type BuilderOption ¶ added in v1.1.3
type BuilderOption func(*Builder)
BuilderOption represents builder options.
func WithFormat ¶ added in v1.1.3
func WithFormat(format string) BuilderOption
WithFormat sets the builder's output format.
func WithMetrics ¶ added in v1.1.3
func WithMetrics(metrics metrics.Metrics) BuilderOption
WithMetrics configures the Builder to use custom specified metrics.
func WithWriter ¶ added in v1.1.3
func WithWriter(w io.Writer) BuilderOption
WithWriter specifies a custom io.Writer to write to. By default, os.Stdout is used.
func WithoutColor ¶ added in v1.1.3
func WithoutColor() BuilderOption
WithoutColor passing this BuilderOption to the NewBuilder disables terminal color.
type Report ¶
type Report struct {
// Sections represents a list of result data
Sections Sections `json:"results,omitempty" yaml:"results,omitempty"`
// TotalRules represents the total amount of checked groups
TotalGroups int `json:"groups_total,omitempty" yaml:"groups_total,omitempty"`
// TotalGroups represents the total amount of checked rules
TotalRules int `json:"rules_total,omitempty" yaml:"rules_total,omitempty"`
// TotalSelectorsFailed represents the total amount of probed selectors not containing a result value
TotalSelectorsFailed int `json:"selectors_failed_total,omitempty" yaml:"selectors_failed_total,omitempty"`
// TotalSelectorsSuccess represents the total amount of probed selectors containing a result value
TotalSelectorsSuccess int `json:"selectors_success_total,omitempty" yaml:"selectors_success_total,omitempty"`
// RatioFailedTotal represents the ratio of selectors without a result value / total amount of selectors
RatioFailedTotal float32 `json:"ratio_failed_total,omitempty" yaml:"ratio_failed_total,omitempty"`
}
Report represents report data.
type Section ¶
type Section struct {
// File represents the file name of the checked rule
File string `json:"file" yaml:"file"`
// Group represents the group name of the checked rule
Group string `json:"group" yaml:"group"`
// Name represents the recording rule or alert name
Name string `json:"name" yaml:"name"`
// Expression represents the rule's PromQL expression string
Expression string `json:"expression" yaml:"expression"`
// NoResults represents a list of the rule's PromQL selectors which did not successfully returned a result value
NoResults []string `json:"no_results" yaml:"no_results"`
// Results represents a list of the rule's PromQL selectors which successfully returned a result value
Results []string `json:"results" yaml:"results"`
}
Section represents a report section.