metrics: add /metrics endpoint and console_helm_install_count metric#10194
metrics: add /metrics endpoint and console_helm_install_count metric#10194openshift-merge-robot merged 2 commits intoopenshift:masterfrom
Conversation
|
FYI @openshift/openshift-team-monitoring |
|
Ready for review @dperaza4dustbit. |
There was a problem hiding this comment.
| Help: "Number of Helm installation from console.", | |
| Help: "Number of Helm installations from console broken down by chart and version.", |
There was a problem hiding this comment.
AFAIK the only way this function would panic is if you pass a wrong number of labels to WithLabelValues() which would mean that the code is broken somehow.
It's better to use GetMetricWithLabelValues or GetMetricWith() and check the returned error.
|
@simonpasquier Thanks for reviewing! Updated according to your comments. |
280cf92 to
1da9214
Compare
There was a problem hiding this comment.
lets make this Names consts here and use them here and in the metrics_test.go
There was a problem hiding this comment.
lets make these a consts as well and use them across the pkg
There was a problem hiding this comment.
not a native speaker but 'broken down by' sounds a bit odd to me
maybe?
| Help: "Number of Helm installations from console broken down by chart name and version.", | |
| Help: "Number of Helm installations from console, based on chart name and version.", |
There was a problem hiding this comment.
Number of Helm installations from console by chart name and version. should be good
There was a problem hiding this comment.
Went with Number of Helm installations from console by chart name and version., please let me know if that sounds okay @jhadvig
There was a problem hiding this comment.
this wont recover the function since the GetMetricWithLabelValues throws a panic.
Instead
func HandleconsoleHelmInstallsTotal(chartName, chartVersion string) {
defer recoverMetricPanic()
klog.V(4).Infof("metric console_helm_installs_total: %s %s", chartName, chartVersion)
counter, _ := consoleHelmInstallsTotal.GetMetricWithLabelValues(chartName, chartVersion)
counter.Add(1)
}
// We will never want to panic console server because of metric saving.
// Therefore, we will recover our panics here and error log them
// for later diagnosis but will never fail the console server.
func recoverMetricPanic() {
if r := recover(); r != nil {
klog.Errorf("Recovering from metric function - %v", r)
}
}We should do the same for the HandleconsoleHelmUpgradesTotal & HandleconsoleHelmUninstallsTotal functions
There was a problem hiding this comment.
From the official doc it seems like WithLabelValues will panic in the case when GetMetricWithLabelValues returns an error: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#CounterVec.GetMetricWithLabelValues vs. https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#CounterVec.WithLabelValues.
Could you confirm the above doc and GetMetricWithLabelValues will indeed panic? Will proceed to update after confirming :)
There was a problem hiding this comment.
GetMetricWithLabelValues won't panic. WithLabelValues would only panic if you give it an incorrect number of parameters (e.g. your metric declares 2 labels but you only passed 1 value).
In general, it's better to let WithLabelValues crash the program since it means that there's a programmatic error.
There was a problem hiding this comment.
@simonpasquier you are right, WithLabelValues would only panic. Misread the code 👍
There was a problem hiding this comment.
Seems redundant for GET responses. Removed httpOK and explicitly check 200.
There was a problem hiding this comment.
Here Im not sure if this should be part of the middleware code. Since this serves only the purpose of the metrics endpoint. I think this should be part of the handler itself (maybe as a wrapper?)
There was a problem hiding this comment.
Moved this part to a new metricsHandler in server.go to preprocess the request and leave middleware.go unchanged.
967308a to
a9a8a42
Compare
|
Thank you for the reviews @jhadvig! |
There was a problem hiding this comment.
(nit) I would suggest to shorten the label names since from the metric names already tell that it relates to console and Helm.
| consoleHelmChartNameLabel = "console_helm_chart_name" | |
| consoleHelmChartVersionLabel = "console_helm_chart_version" | |
| consoleHelmChartNameLabel = "chart_name" | |
| consoleHelmChartVersionLabel = "chart_version" |
Adds prometheus metrics dependencies for helm. Result of `go mod vendor` and `go mod tidy`. Signed-off-by: Allen Bai <abai@redhat.com>
Works with openshift/console-operator#601 to add a console_helm_install_count counter vector metric. This change will increment the counter each time a user installs a Helm chart in the console. Closes: https://issues.redhat.com/browse/HELM-235 Signed-off-by: Allen Bai <abai@redhat.com> helm/metrics: update according to code reviews Signed-off-by: Allen Bai <abai@redhat.com> helm/metrics: add metrics for helm release upgrades and uninstalls Signed-off-by: Allen Bai <abai@redhat.com>
|
/test e2e-gcp-console |
1 similar comment
|
/test e2e-gcp-console |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dperaza4dustbit, jhadvig, zonggen The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/hold for approvals |
|
/label docs-approved |
|
Install/Uninstall Helm Releases and check the metrics data |
|
A friendly bump @RickJWagner @yapei, is there anything else needed from my side to get this approved? :) |
|
tested Install/Uninstall/Upgrade of Helm releases, working as intended /label qe-approved |
|
/label px-approved |
|
/unhold |
|
/retest |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |

Works with openshift/console-operator#601 to add
a
console_helm_install_count countervector metric. This change willincrement the counter each time a user installs a Helm chart in the
console.Closes: https://issues.redhat.com/browse/HELM-235
Signed-off-by: Allen Bai abai@redhat.com