Skip to content

Commit d85f05b

Browse files
authored
feat: canary_check_invalid_count metric (#2261)
* feat: canary_check_invalid_count metric * chore: undo some formatting changes
1 parent dbc85a6 commit d85f05b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

checks/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (c *HTTPChecker) Check(ctx *context.Context, extConfig external.Check) pkg.
164164

165165
//nolint:staticcheck
166166
if check.Endpoint != "" && check.URL != "" {
167-
return results.Failf("cannot specify both endpoint and url")
167+
return results.Invalidf("cannot specify both endpoint and url")
168168
}
169169

170170
//nolint:staticcheck

pkg/metrics/metrics.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ func setupMetrics() {
6262
checkLabels,
6363
)
6464

65+
OpsInvalidCount = prometheus.NewCounterVec(
66+
prometheus.CounterOpts{
67+
Name: "canary_check_invalid_count",
68+
Help: "The total number of invalid checks",
69+
},
70+
[]string{"type", "endpoint", "canary_name", "canary_namespace", "owner", "severity", "key", "name"},
71+
)
72+
6573
CanaryCheckInfo = prometheus.NewGaugeVec(
6674
prometheus.GaugeOpts{
6775
Name: "canary_check_info",
@@ -86,7 +94,7 @@ func setupMetrics() {
8694
checkLabels,
8795
)
8896

89-
prometheus.MustRegister(Gauge, CanaryCheckInfo, OpsCount, OpsSuccessCount, OpsFailedCount, RequestLatency)
97+
prometheus.MustRegister(Gauge, CanaryCheckInfo, OpsCount, OpsSuccessCount, OpsInvalidCount, OpsFailedCount, RequestLatency)
9098
}
9199

92100
var (
@@ -103,6 +111,7 @@ var (
103111
Gauge *prometheus.GaugeVec
104112

105113
// Check specific metrics
114+
OpsInvalidCount *prometheus.CounterVec
106115
OpsCount *prometheus.CounterVec
107116
OpsFailedCount *prometheus.CounterVec
108117
OpsSuccessCount *prometheus.CounterVec
@@ -259,6 +268,12 @@ func Record(
259268
}
260269
}
261270
} else {
271+
if result.Invalid {
272+
OpsInvalidCount.WithLabelValues(checkMetricLabels...).Inc()
273+
} else {
274+
OpsFailedCount.WithLabelValues(checkMetricLabels...).Inc()
275+
}
276+
262277
fail.Append(1)
263278
Gauge.WithLabelValues(gaugeLabels...).Set(1)
264279

@@ -272,6 +287,7 @@ func Record(
272287
} else {
273288
_latency = types.Latency{}
274289
}
290+
275291
return _uptime, _latency
276292
}
277293

0 commit comments

Comments
 (0)