From 4bce781ea8e4a3aa9cfa8165c8147bb637f2452c Mon Sep 17 00:00:00 2001 From: Han Kang Date: Wed, 7 Feb 2024 09:03:26 -0800 Subject: [PATCH 1/2] Update instrumentation.md Add a snippet about preferring labels to embedding labels in metric names. --- .../sig-instrumentation/instrumentation.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/contributors/devel/sig-instrumentation/instrumentation.md b/contributors/devel/sig-instrumentation/instrumentation.md index 2c48ffcc897..f72dcd46528 100644 --- a/contributors/devel/sig-instrumentation/instrumentation.md +++ b/contributors/devel/sig-instrumentation/instrumentation.md @@ -242,6 +242,27 @@ metric could look as follows: ``` kube_pod_restarts and on(namespace, pod) kube_pod_info{uuid=”ABC”} ``` +## When to use labels + +Labels should be used to mark dimensions about the measured quantity. It can be +tempting to embed a label in the _name_ of a metric, but often this is a bad idea +as it can make it slightly more difficult to do ratios. If you find yourself +creating two metrics with the exact same schema that you are likely to want to +compare against each other, it's probably better to merge them into a single metric +and introduced a new label for the differentiating dimension. + +For instance, you should **_prefer_**: + +``` +apiserver_authorization_config_controller_reloads_total{descision=[SUCCESS, FAILURE]} +``` + +...over this variant: + +``` +apiserver_authorization_config_controller_automatic_reload_failures_total +apiserver_authorization_config_controller_automatic_reload_success_total +``` ## Deprecating Metrics From be1503383b8eb786af1a67e34af23c8f3024feac Mon Sep 17 00:00:00 2001 From: Han Kang Date: Wed, 7 Feb 2024 09:26:19 -0800 Subject: [PATCH 2/2] fix spelling --- contributors/devel/sig-instrumentation/instrumentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributors/devel/sig-instrumentation/instrumentation.md b/contributors/devel/sig-instrumentation/instrumentation.md index f72dcd46528..347b91de246 100644 --- a/contributors/devel/sig-instrumentation/instrumentation.md +++ b/contributors/devel/sig-instrumentation/instrumentation.md @@ -254,7 +254,7 @@ and introduced a new label for the differentiating dimension. For instance, you should **_prefer_**: ``` -apiserver_authorization_config_controller_reloads_total{descision=[SUCCESS, FAILURE]} +apiserver_authorization_config_controller_reloads_total{decision=[SUCCESS, FAILURE]} ``` ...over this variant: