2 Copyright 2018 The Kubernetes Authors.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
20 "github.com/prometheus/client_golang/prometheus"
21 "sigs.k8s.io/controller-runtime/pkg/metrics"
25 // ReconcileTotal is a prometheus counter metrics which holds the total
26 // number of reconciliations per controller. It has two labels. controller label refers
27 // to the controller name and result label refers to the reconcile result i.e
28 // success, error, requeue, requeue_after
29 ReconcileTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
30 Name: "controller_runtime_reconcile_total",
31 Help: "Total number of reconciliations per controller",
32 }, []string{"controller", "result"})
34 // ReconcileErrors is a prometheus counter metrics which holds the total
35 // number of errors from the Reconciler
36 ReconcileErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
37 Name: "controller_runtime_reconcile_errors_total",
38 Help: "Total number of reconciliation errors per controller",
39 }, []string{"controller"})
41 // ReconcileTime is a prometheus metric which keeps track of the duration
43 ReconcileTime = prometheus.NewHistogramVec(prometheus.HistogramOpts{
44 Name: "controller_runtime_reconcile_time_seconds",
45 Help: "Length of time per reconciliation per controller",
46 }, []string{"controller"})
50 metrics.Registry.MustRegister(
54 // expose process metrics like CPU, Memory, file descriptor usage etc.
55 prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
56 // expose Go runtime metrics like GC stats, memory stats etc.
57 prometheus.NewGoCollector(),