package promlint
import "github.com/prometheus/client_golang/prometheus/testutil/promlint"
Package promlint provides a linter for Prometheus metrics.
Index ¶
- type Linter
- func New(r io.Reader) *Linter
- func NewWithMetricFamilies(mfs []*dto.MetricFamily) *Linter
- func (l *Linter) AddCustomValidations(vs ...Validation)
- func (l *Linter) Lint() ([]Problem, error)
- type Problem
- type Validation
Types ¶
type Linter ¶
type Linter struct {
// contains filtered or unexported fields
}
A Linter is a Prometheus metrics linter. It identifies issues with metric names, types, and metadata, and reports them to the caller.
func New ¶
New creates a new Linter that reads an input stream of Prometheus metrics in the Prometheus text exposition format.
func NewWithMetricFamilies ¶
func NewWithMetricFamilies(mfs []*dto.MetricFamily) *Linter
NewWithMetricFamilies creates a new Linter that reads from a slice of MetricFamily protobuf messages.
func (*Linter) AddCustomValidations ¶
func (l *Linter) AddCustomValidations(vs ...Validation)
AddCustomValidations adds custom validations to the linter.
func (*Linter) Lint ¶
Lint performs a linting pass, returning a slice of Problems indicating any issues found in the metrics stream. The slice is sorted by metric name and issue description.
type Problem ¶
type Problem struct { // The name of the metric indicated by this Problem. Metric string // A description of the issue for this Problem. Text string }
A Problem is an issue detected by a linter.
type Validation ¶
type Validation = func(mf *dto.MetricFamily) []error
Source Files ¶
problem.go promlint.go validation.go
Directories ¶
Path | Synopsis |
---|---|
prometheus/testutil/promlint/validations |
- Version
- v1.22.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 12 hours ago –
Tools for package owners.