-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
- Loading branch information
1 parent
ca155f5
commit ce005fc
Showing
2 changed files
with
60 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package controllers | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
var ( | ||
evalLoopHistogram = prometheus.NewHistogram( | ||
prometheus.HistogramOpts{ | ||
Name: "config_policies_evaluation_duration_seconds", | ||
Help: "The seconds that it takes to evaluate all configuration policies on the cluster", | ||
Buckets: []float64{1, 3, 9, 10.5, 15, 30, 60, 90, 120, 180, 300, 450, 600}, | ||
}, | ||
) | ||
policyEvalSecondsCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "config_policy_evaluation_seconds_total", | ||
Help: "The total seconds taken while evaluating the configuration policy. Use this alongside " + | ||
"config_policy_evaluation_total.", | ||
}, | ||
[]string{"name"}, | ||
) | ||
policyEvalCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "config_policy_evaluation_total", | ||
Help: "The total number of evaluations of the configuration policy. Use this alongside " + | ||
"config_policy_evaluation_seconds_total.", | ||
}, | ||
[]string{"name"}, | ||
) | ||
compareObjSecondsCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "compare_objects_seconds_total", | ||
Help: "The total seconds taken while comparing policy objects. Use this alongside " + | ||
"compare_objects_evaluation_total.", | ||
}, | ||
[]string{"config_policy_name", "namespace", "object"}, | ||
) | ||
compareObjEvalCounter = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "compare_objects_evaluation_total", | ||
Help: "The total number of times the comparison algorithm is run on an object. " + | ||
"Use this alongside compare_objects_seconds_total.", | ||
}, | ||
[]string{"config_policy_name", "namespace", "object"}, | ||
) | ||
) | ||
|
||
func init() { | ||
// Register custom metrics with the global Prometheus registry | ||
metrics.Registry.MustRegister(evalLoopHistogram) | ||
metrics.Registry.MustRegister(policyEvalSecondsCounter) | ||
metrics.Registry.MustRegister(policyEvalCounter) | ||
metrics.Registry.MustRegister(compareObjSecondsCounter) | ||
metrics.Registry.MustRegister(compareObjEvalCounter) | ||
metrics.Registry.MustRegister(policyRelatedObjectGauge) | ||
} |