Monitoring Linter is a Golang linter designed to ensure that in Kubernetes operator projects,
monitoring-related practices are implemented within the pkg/monitoring
directory using operator-observability methods.
It verifies that all metrics, alerts and recording rules registrations are centralized in this directory.
The use of Prometheus registration methods is restricted across the entire project.
go install github.com/assafad/monitoringlinter/cmd/monitoringlinter@latest
Once installed, you can run the Monitoring Linter against your Kubernetes operator project by using the following command:
monitoringlinter ./...
-
The following Prometheus registration methods calls are restricted across all the project:
prometheus.Register() prometheus.MustRegister()
-
The following operator-observability methods calls are allowed only within
pkg/monitoring
directory:operatormetrics.RegisterMetrics() operatorrules.RegisterAlerts() operatorrules.RegisterRecordingRules()
-
Examples for calls that are allowed across all the project, as they are not registering metrics, alerts or recording rules:
prometheus.NewHistogram() operatormetrics.ListMetrics()