Skip to content

assafad/monitoringlinter

Repository files navigation

monitoring-linter

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.

Installation

go install github.com/assafad/monitoringlinter/cmd/monitoringlinter@latest

Usage

Once installed, you can run the Monitoring Linter against your Kubernetes operator project by using the following command:

monitoringlinter  ./...

Linter Rules

  • 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()