Skip to content

Commit

Permalink
Add canary paused / failed metrics (#56)
Browse files Browse the repository at this point in the history
* Add canary paused metric

* Add canary failed metric
  • Loading branch information
xornivore committed Nov 3, 2020
1 parent f0fff1b commit 4720595
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion controllers/extendeddaemonset/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const (
extendeddaemonsetStatusIgnoredUnresponsiveNodes = "eds_status_ignored_unresponsive_nodes"
extendeddaemonsetStatusCanaryActivated = "eds_status_canary_activated"
extendeddaemonsetStatusCanaryNumberOfNodes = "eds_status_canary_node_number"
extendeddaemonsetStatusCanaryPaused = "eds_status_canary_paused"
extendeddaemonsetStatusCanaryFailed = "eds_status_canary_failed"
extendeddaemonsetLabels = "eds_labels"
)

Expand Down Expand Up @@ -190,7 +192,7 @@ func generateMetricFamilies() []ksmetric.FamilyGenerator {
{
Name: extendeddaemonsetStatusCanaryActivated,
Type: ksmetric.Gauge,
Help: "The status of the canary deployement, set to 1 if active, else 0",
Help: "The status of the canary deployment, set to 1 if active, else 0",
GenerateFunc: func(obj interface{}) *ksmetric.Family {
eds := obj.(*datadoghqv1alpha1.ExtendedDaemonSet)
labelKeys, labelValues := utils.GetLabelsValues(&eds.ObjectMeta)
Expand All @@ -213,6 +215,65 @@ func generateMetricFamilies() []ksmetric.FamilyGenerator {
}
},
},
{
Name: extendeddaemonsetStatusCanaryPaused,
Type: ksmetric.Gauge,
Help: "The paused state of the canary deployment, set to 1 if paused, else 0",
GenerateFunc: func(obj interface{}) *ksmetric.Family {
eds := obj.(*datadoghqv1alpha1.ExtendedDaemonSet)
labelKeys, labelValues := utils.GetLabelsValues(&eds.ObjectMeta)
val := float64(0)

if eds.Status.Canary != nil {
rs := eds.Status.Canary.ReplicaSet
labelKeys = append(labelKeys, "replicaset")
labelValues = append(labelValues, rs)
paused, reason := IsCanaryDeploymentPaused(eds.Annotations)
if paused {
val = 1
labelKeys = append(labelKeys, "paused_reason")
labelValues = append(labelValues, string(reason))
}
}
return &ksmetric.Family{
Metrics: []*ksmetric.Metric{
{
Value: val,
LabelKeys: labelKeys,
LabelValues: labelValues,
},
},
}
},
},
{
Name: extendeddaemonsetStatusCanaryFailed,
Type: ksmetric.Gauge,
Help: "The failed state of the canary deployment, set to 1 if failed, else 0",
GenerateFunc: func(obj interface{}) *ksmetric.Family {
eds := obj.(*datadoghqv1alpha1.ExtendedDaemonSet)
labelKeys, labelValues := utils.GetLabelsValues(&eds.ObjectMeta)
val := float64(0)

if eds.Status.Canary != nil {
rs := eds.Status.Canary.ReplicaSet
labelKeys = append(labelKeys, "replicaset")
labelValues = append(labelValues, rs)
if IsCanaryDeploymentFailed(eds.Annotations) {
val = 1
}
}
return &ksmetric.Family{
Metrics: []*ksmetric.Metric{
{
Value: val,
LabelKeys: labelKeys,
LabelValues: labelValues,
},
},
}
},
},
{
Name: extendeddaemonsetStatusCanaryNumberOfNodes,
Type: ksmetric.Gauge,
Expand Down

0 comments on commit 4720595

Please sign in to comment.