From b34b6c1059d4f3af222815158c7b76da6d38d162 Mon Sep 17 00:00:00 2001 From: Gopi-eng2202 Date: Fri, 15 Nov 2024 15:09:18 +0530 Subject: [PATCH] #2469 Best practices: Metric names Signed-off-by: Gopi-eng2202 --- content/docs/practices/naming.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/content/docs/practices/naming.md b/content/docs/practices/naming.md index 92211e3ca..6f3cc5e49 100644 --- a/content/docs/practices/naming.md +++ b/content/docs/practices/naming.md @@ -39,6 +39,26 @@ A metric name... (for a pseudo-metric that provides [metadata](https://www.robustperception.io/exposing-the-software-version-to-prometheus) about the running binary) * data\_pipeline\_last\_record\_processed\_timestamp_seconds (for a timestamp that tracks the time of the latest record processed in a data processing pipeline) +* ...that has a `unit` in its name, must always have that `unit` as the last word. Note that an accumulating count such as `total` will be the last word, in addition to the unit if applicable. Examples, + * request\_size\_bytes + * request\_size\_bytes_total + * process\_cpu\_seconds + * process\_cpu\_seconds_total +* ...that has a accumulating count such as `total`, can have two different naming scenarios. + * If the metric name has a unit, then the unit must be the last word before the accumulating count. Examples, + * process\_cpu\_seconds_total + * request\_size\_bytes_total + * If the metric name does'nt have a real unit, then the naming can follow any sorting order in a way that it fits your use case, such as `grouping similar metric names`. Examples, + * If you decided to name something as "net\_conntrack\_dialer\_conn", then it can have the following group names. (Note that this is only an example and you can follow your own order, if it improves your work flow) + * net\_conntrack\_dialer\_conn\_total + * net\_conntrack\_dialer\_conn\_failed\_total + * net\_conntrack\_dialer\_conn\_established\_total + * net\_conntrack\_dialer\_conn\_closed\_total + or + * net\_conntrack\_dialer\_conn\_total + * net\_conntrack\_dialer\_conn\_total\_failed + * net\_conntrack\_dialer\_conn\_total\_established + * net\_conntrack\_dialer\_conn\_total\_closed * ...should represent the same logical thing-being-measured across all label dimensions. * request duration