-
Notifications
You must be signed in to change notification settings - Fork 47
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: João Vilaça <[email protected]>
- Loading branch information
1 parent
4f1a32a
commit b498f67
Showing
19 changed files
with
125 additions
and
476 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
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
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
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
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
File renamed without changes.
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,24 @@ | ||
package metrics | ||
|
||
import "github.com/machadovilaca/operator-observability/pkg/operatormetrics" | ||
|
||
var ( | ||
operatorMetrics = []operatormetrics.Metric{ | ||
sspOperatorReconcileSucceeded, | ||
} | ||
|
||
sspOperatorReconcileSucceeded = operatormetrics.NewGauge( | ||
operatormetrics.MetricOpts{ | ||
Name: "kubevirt_ssp_operator_reconcile_succeeded", | ||
Help: "Set to 1 if the reconcile process of all operands completes with no errors, and to 0 otherwise", | ||
}, | ||
) | ||
) | ||
|
||
func SetSspOperatorReconcileSucceeded(isSucceeded bool) { | ||
value := 0.0 | ||
if isSucceeded { | ||
value = 1.0 | ||
} | ||
sspOperatorReconcileSucceeded.Set(value) | ||
} |
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
File renamed without changes.
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,16 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/machadovilaca/operator-observability/pkg/operatormetrics" | ||
runtimemetrics "sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
func SetupMetrics() { | ||
operatormetrics.Register = runtimemetrics.Registry.Register | ||
|
||
if err := operatormetrics.RegisterMetrics( | ||
templateMetrics, | ||
); err != nil { | ||
panic(err) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
pkg/monitoring/metrics/template-validator/template_metrics.go
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,44 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/machadovilaca/operator-observability/pkg/operatormetrics" | ||
ioprometheusclient "github.com/prometheus/client_model/go" | ||
) | ||
|
||
var ( | ||
templateMetrics = []operatormetrics.Metric{ | ||
commonTemplatesRestored, | ||
templateValidatorRejected, | ||
} | ||
|
||
commonTemplatesRestored = operatormetrics.NewCounter( | ||
operatormetrics.MetricOpts{ | ||
Name: "kubevirt_ssp_common_templates_restored_total", | ||
Help: "The total number of common templates restored by the operator back to their original state", | ||
}, | ||
) | ||
|
||
templateValidatorRejected = operatormetrics.NewCounter( | ||
operatormetrics.MetricOpts{ | ||
Name: "kubevirt_ssp_template_validator_rejected_total", | ||
Help: "The total number of rejected template validators", | ||
}, | ||
) | ||
) | ||
|
||
func IncCommonTemplatesRestored() { | ||
commonTemplatesRestored.Inc() | ||
} | ||
|
||
func GetCommonTemplatesRestored() (float64, error) { | ||
dto := &ioprometheusclient.Metric{} | ||
err := commonTemplatesRestored.Write(dto) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return dto.Counter.GetValue(), nil | ||
} | ||
|
||
func IncTemplateValidatorRejected() { | ||
templateValidatorRejected.Inc() | ||
} |
Oops, something went wrong.