Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: canary_check_invalid_count metric #2261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checks/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (c *HTTPChecker) Check(ctx *context.Context, extConfig external.Check) pkg.

//nolint:staticcheck
if check.Endpoint != "" && check.URL != "" {
return results.Failf("cannot specify both endpoint and url")
return results.Invalidf("cannot specify both endpoint and url")
}

//nolint:staticcheck
Expand Down
18 changes: 17 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func setupMetrics() {
checkLabels,
)

OpsInvalidCount = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "canary_check_invalid_count",
Help: "The total number of invalid checks",
},
[]string{"type", "endpoint", "canary_name", "canary_namespace", "owner", "severity", "key", "name"},
)

CanaryCheckInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "canary_check_info",
Expand All @@ -86,7 +94,7 @@ func setupMetrics() {
checkLabels,
)

prometheus.MustRegister(Gauge, CanaryCheckInfo, OpsCount, OpsSuccessCount, OpsFailedCount, RequestLatency)
prometheus.MustRegister(Gauge, CanaryCheckInfo, OpsCount, OpsSuccessCount, OpsInvalidCount, OpsFailedCount, RequestLatency)
}

var (
Expand All @@ -103,6 +111,7 @@ var (
Gauge *prometheus.GaugeVec

// Check specific metrics
OpsInvalidCount *prometheus.CounterVec
OpsCount *prometheus.CounterVec
OpsFailedCount *prometheus.CounterVec
OpsSuccessCount *prometheus.CounterVec
Expand Down Expand Up @@ -259,6 +268,12 @@ func Record(
}
}
} else {
if result.Invalid {
OpsInvalidCount.WithLabelValues(checkMetricLabels...).Inc()
} else {
OpsFailedCount.WithLabelValues(checkMetricLabels...).Inc()
}

fail.Append(1)
Gauge.WithLabelValues(gaugeLabels...).Set(1)

Expand All @@ -272,6 +287,7 @@ func Record(
} else {
_latency = types.Latency{}
}

return _uptime, _latency
}

Expand Down
Loading