-
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.
refactor recording rules and alerts code
Signed-off-by: avlitman <[email protected]>
- Loading branch information
Showing
24 changed files
with
737 additions
and
394 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
# SSP Operator metrics | ||
This document aims to help users that are not familiar with metrics exposed by the SSP Operator. | ||
All metrics documented here are auto-generated by the utility tool `tools/metricsdocs` and reflects exactly what is being exposed. | ||
|
||
## SSP Operator Metrics List | ||
### kubevirt_ssp_common_templates_restored_increase | ||
The increase in the number of common templates restored by the operator back to their original state, over the last hour. Type: Gauge. | ||
|
||
### kubevirt_ssp_common_templates_restored_total | ||
The total number of common templates restored by the operator back to their original state. Type: Counter. | ||
|
||
### kubevirt_ssp_operator_reconcile_succeeded | ||
Set to 1 if the reconcile process of all operands completes with no errors, and to 0 otherwise. Type: Gauge. | ||
|
||
### kubevirt_ssp_operator_reconcile_succeeded_aggregated | ||
The total number of ssp-operator pods reconciling with no errors. Type: Gauge. | ||
|
||
### kubevirt_ssp_operator_up | ||
The total number of running ssp-operator pods. Type: Gauge. | ||
|
||
### kubevirt_ssp_template_validator_rejected_increase | ||
The increase in the number of rejected template validators, over the last hour. Type: Gauge. | ||
|
||
### kubevirt_ssp_template_validator_rejected_total | ||
The total number of rejected template validators. Type: Counter. | ||
|
||
### kubevirt_ssp_template_validator_up | ||
The total number of running virt-template-validator pods. Type: Gauge. | ||
|
||
### kubevirt_ssp_vm_rbd_block_volume_without_rxbounce | ||
VM with RBD mounted Block volume (without rxbounce option set). Type: Gauge. | ||
[ALPHA] VM with RBD mounted Block volume (without rxbounce option set). 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
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,89 @@ | ||
package alerts | ||
|
||
import ( | ||
promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
"k8s.io/utils/ptr" | ||
) | ||
|
||
const ( | ||
severityAlertLabelKey = "severity" | ||
healthImpactAlertLabelKey = "operator_health_impact" | ||
) | ||
|
||
func operatorAlerts() []promv1.Rule { | ||
return []promv1.Rule{ | ||
{ | ||
Alert: "SSPDown", | ||
Expr: intstr.FromString("kubevirt_ssp_operator_up == 0"), | ||
For: ptr.To[promv1.Duration]("5m"), | ||
Annotations: map[string]string{ | ||
"summary": "All SSP operator pods are down.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "critical", | ||
healthImpactAlertLabelKey: "critical", | ||
}, | ||
}, | ||
{ | ||
Alert: "SSPTemplateValidatorDown", | ||
Expr: intstr.FromString("kubevirt_ssp_template_validator_up == 0"), | ||
For: ptr.To[promv1.Duration]("5m"), | ||
Annotations: map[string]string{ | ||
"summary": "All Template Validator pods are down.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "critical", | ||
healthImpactAlertLabelKey: "critical", | ||
}, | ||
}, | ||
{ | ||
Alert: "SSPFailingToReconcile", | ||
Expr: intstr.FromString("(kubevirt_ssp_operator_reconcile_succeeded_aggregated == 0) and (kubevirt_ssp_operator_up > 0)"), | ||
For: ptr.To[promv1.Duration]("5m"), | ||
Annotations: map[string]string{ | ||
"summary": "The ssp-operator pod is up but failing to reconcile.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "critical", | ||
healthImpactAlertLabelKey: "critical", | ||
}, | ||
}, | ||
{ | ||
Alert: "SSPHighRateRejectedVms", | ||
Expr: intstr.FromString("kubevirt_ssp_template_validator_rejected_increase > 5"), | ||
For: ptr.To[promv1.Duration]("5m"), | ||
Annotations: map[string]string{ | ||
"summary": "High rate of rejected Vms.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "warning", | ||
healthImpactAlertLabelKey: "warning", | ||
}, | ||
}, | ||
{ | ||
Alert: "SSPCommonTemplatesModificationReverted", | ||
Expr: intstr.FromString("kubevirt_ssp_common_templates_restored_increase > 0"), | ||
For: ptr.To[promv1.Duration]("0m"), | ||
Annotations: map[string]string{ | ||
"summary": "Common Templates manual modifications were reverted by the operator.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "warning", | ||
healthImpactAlertLabelKey: "none", | ||
}, | ||
}, | ||
{ | ||
Alert: "VirtualMachineCRCErrors", | ||
Expr: intstr.FromString("(count(kubevirt_ssp_vm_rbd_block_volume_without_rxbounce > 0) or vector(0)) > 0"), | ||
Annotations: map[string]string{ | ||
"description": "{{ $value }} Virtual Machines are in risk of causing CRC errors and major service outages.", | ||
"summary": "When running VMs using ODF storage with 'rbd' mounter or 'rbd.csi.ceph.com provisioner', it will report bad crc/signature errors and cluster performance will be severely degraded if krbd:rxbounce is not set.", | ||
}, | ||
Labels: map[string]string{ | ||
severityAlertLabelKey: "warning", | ||
healthImpactAlertLabelKey: "none", | ||
}, | ||
}, | ||
} | ||
} |
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,51 @@ | ||
package alerts | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/machadovilaca/operator-observability/pkg/operatorrules" | ||
promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" | ||
) | ||
|
||
const ( | ||
prometheusRunbookAnnotationKey = "runbook_url" | ||
partOfAlertLabelKey = "kubernetes_operator_part_of" | ||
partOfAlertLabelValue = "kubevirt" | ||
componentAlertLabelKey = "kubernetes_operator_component" | ||
componentAlertLabelValue = "ssp-operator" | ||
defaultRunbookURLTemplate = "https://kubevirt.io/monitoring/runbooks/%s" | ||
runbookURLTemplateEnv = "RUNBOOK_URL_TEMPLATE" | ||
) | ||
|
||
func Register() error { | ||
alerts := [][]promv1.Rule{ | ||
operatorAlerts(), | ||
} | ||
|
||
runbookURLTemplate := getRunbookURLTemplate() | ||
for _, alertGroup := range alerts { | ||
for _, alert := range alertGroup { | ||
alert.Labels[partOfAlertLabelKey] = partOfAlertLabelValue | ||
alert.Labels[componentAlertLabelKey] = componentAlertLabelValue | ||
alert.Annotations[prometheusRunbookAnnotationKey] = fmt.Sprintf(runbookURLTemplate, alert.Alert) | ||
} | ||
} | ||
|
||
return operatorrules.RegisterAlerts(alerts...) | ||
} | ||
|
||
func getRunbookURLTemplate() string { | ||
runbookURLTemplate, exists := os.LookupEnv(runbookURLTemplateEnv) | ||
if !exists { | ||
runbookURLTemplate = defaultRunbookURLTemplate | ||
} | ||
|
||
if strings.Count(runbookURLTemplate, "%s") != 1 { | ||
panic(errors.New("runbook URL template must have exactly 1 %s substring")) | ||
} | ||
|
||
return runbookURLTemplate | ||
} |
Oops, something went wrong.