Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per Resource metrics #516

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/cloud.redhat.com/clowdapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func (r *ClowdAppReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c

log.Info("Reconciliation started", "app", fmt.Sprintf("%s:%s", app.Namespace, app.Name))

if clowderconfig.LoadedConfig.Features.PerProviderMetrics {
requestMetrics.With(prometheus.Labels{"type": "app", "name": app.GetIdent()}).Inc()
}

if app.Spec.Disabled {
log.Info("Reconciliation aborted - set to be disabled", "app", fmt.Sprintf("%s:%s", app.Namespace, app.Name))
return ctrl.Result{}, nil
Expand Down
4 changes: 4 additions & 0 deletions controllers/cloud.redhat.com/clowdenvironment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (r *ClowdEnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Req

log.Info("Reconciliation started", "env", env.Name)

if clowderconfig.LoadedConfig.Features.PerProviderMetrics {
requestMetrics.With(prometheus.Labels{"type": "env", "name": env.Name}).Inc()
}

if env.Spec.Disabled {
log.Info("Reconciliation aborted - set to be disabled", "env", env.Name)
return ctrl.Result{}, nil
Expand Down
1 change: 1 addition & 0 deletions controllers/cloud.redhat.com/clowderconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ClowderConfig struct {
UseComplexStrimziTopicNames bool `json:"useComplexStrimziTopicNames"`
EnableAuthSidecarHook bool `json:"enableAuthSidecarHook"`
KedaResources bool `json:"enableKedaResources"`
PerProviderMetrics bool `json:"perProviderMetrics"`
} `json:"features"`
}

Expand Down
16 changes: 8 additions & 8 deletions controllers/cloud.redhat.com/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ var (
Help: "ClowdEnv Managed Envs",
},
)
clientOpsMetric = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "clowder_api_calls",
Help: "Number of calls to API",
},
[]string{"operation"},
)
clowderVersion = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "clowder_version",
Expand All @@ -42,9 +35,16 @@ var (
},
[]string{"provider", "source"},
)
requestMetrics = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "clowder_reconcile_requests",
Help: "Clowder reconciliation requests",
},
[]string{"type", "name"},
)
)

func init() {
// Register custom metrics with the global prometheus registry
metrics.Registry.MustRegister(managedAppsMetric, managedEnvsMetric, clientOpsMetric, clowderVersion, providerMetrics)
metrics.Registry.MustRegister(managedAppsMetric, managedEnvsMetric, clowderVersion, providerMetrics, requestMetrics)
}