forked from kubevirt/cluster-network-addons-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor metrics using operator-observability package
Signed-off-by: João Vilaça <jvilaca@redhat.com>
- Loading branch information
1 parent
344d4ba
commit 785c6ec
Showing
48 changed files
with
7,252 additions
and
353 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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
# Cluster Network Addons Operator metrics | ||
> This file is auto generated by metricsdocs, run 'make generate-doc' in order to update it. | ||
# Cluster Network Addons Operator Metrics | ||
|
||
This document aims to help users that are not familiar with metrics exposed by the Cluster Network Addons Operator. | ||
All metrics documented here are auto-generated by the utility tool 'tools/metricsdocs' and reflects exactly what is being exposed. | ||
## Cluster Network Addons Operator Metrics List | ||
### kubevirt_cnao_cr_kubemacpool_aggregated | ||
Total count of KubeMacPool manager pods deployed by CNAO CR. Type: Gauge. | ||
|
||
### kubevirt_cnao_cr_kubemacpool_deployed | ||
KubeMacpool is deployed by CNAO CR. Type: Gauge. | ||
|
||
### kubevirt_cnao_cr_ready | ||
CNAO CR Ready. Type: Gauge. | ||
|
||
### kubevirt_cnao_kubemacpool_duplicate_macs | ||
Total count of duplicate KubeMacPool MAC addresses. Type: Gauge. | ||
|
||
### kubevirt_cnao_kubemacpool_manager_up | ||
Total count of running KubeMacPool manager pods. Type: Gauge. | ||
|
||
### kubevirt_cnao_operator_up | ||
Total count of running CNAO operators. Type: Gauge. | ||
|
||
## Developing new metrics | ||
After developing new metrics or changing old ones, please run 'make generate-doc' to regenerate this document. | ||
|
||
All metrics documented here are auto-generated and reflect exactly what is being | ||
exposed. After developing new metrics or changing old ones please regenerate | ||
this document. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package metrics | ||
|
||
import "github.com/machadovilaca/operator-observability/pkg/operatormetrics" | ||
|
||
var ( | ||
metrics = [][]operatormetrics.Metric{ | ||
operatorMetrics, | ||
} | ||
) | ||
|
||
func SetupMetrics() error { | ||
return operatormetrics.RegisterMetrics(metrics...) | ||
} | ||
|
||
func ListMetrics() []operatormetrics.Metric { | ||
return operatormetrics.ListMetrics() | ||
} |
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,48 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/machadovilaca/operator-observability/pkg/operatormetrics" | ||
|
||
cnao "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/shared" | ||
"github.com/kubevirt/cluster-network-addons-operator/pkg/controller/statusmanager" | ||
) | ||
|
||
var ( | ||
operatorMetrics = []operatormetrics.Metric{ | ||
cnaoCrReady, | ||
kmpDeployed, | ||
} | ||
|
||
cnaoCrReady = operatormetrics.NewGauge( | ||
operatormetrics.MetricOpts{ | ||
Name: "kubevirt_cnao_cr_ready", | ||
Help: "CNAO CR Ready", | ||
}, | ||
) | ||
|
||
kmpDeployed = operatormetrics.NewGauge( | ||
operatormetrics.MetricOpts{ | ||
Name: "kubevirt_cnao_cr_kubemacpool_deployed", | ||
Help: "KubeMacpool is deployed by CNAO CR", | ||
}, | ||
) | ||
) | ||
|
||
func ResetMonitoredComponents() { | ||
setGaugeParam(false, cnaoCrReady) | ||
setGaugeParam(false, kmpDeployed) | ||
} | ||
|
||
func TrackMonitoredComponents(conf *cnao.NetworkAddonsConfigSpec, statusManager *statusmanager.StatusManager) { | ||
isKubemacpoolDeployed := conf.KubeMacPool != nil | ||
setGaugeParam(isKubemacpoolDeployed, kmpDeployed) | ||
setGaugeParam(statusManager.IsStatusAvailable(), cnaoCrReady) | ||
} | ||
|
||
func setGaugeParam(setTrueFlag bool, gaugeParam *operatormetrics.Gauge) { | ||
if setTrueFlag { | ||
gaugeParam.Set(1) | ||
} else { | ||
gaugeParam.Set(0) | ||
} | ||
} |
Oops, something went wrong.