client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

promlint: Add timestamp_seconds suffix restriction

Open assafad opened this issue 1 year ago • 3 comments

What this PR does

Add a rule to promlint, restricting timestamp_seconds suffix for non-gauge metrics. timestamp_seconds metrics are not cumulative and shouldn't be split to buckets or quantiles. They should be of gauge type. For example, in https://kubernetes.io/docs/reference/instrumentation/metrics/#list-of-stable-kubernetes-metrics and https://github.com/kubernetes/kube-state-metrics/tree/main/docs/metrics, all timestamp_seconds metrics are gauges.

assafad avatar May 20 '24 16:05 assafad

@ArthurSens Can you please review this PR?

assafad avatar May 20 '24 16:05 assafad

Isn't there a linter that already fails if a counter doesn't end with _total? Wouldn't it catch this case as well?

ArthurSens avatar May 27 '24 13:05 ArthurSens

Isn't there a linter that already fails if a counter doesn't end with _total? Wouldn't it catch this case as well?

@ArthurSens For counters yes, but it won't catch other metrics types using the timestamp_seconds suffix. I don't see how timestamps are relevant for histogram and summaries, since they shouldn't be split to buckets or quantiles, so I think this validation makes sense.

assafad avatar May 29 '24 13:05 assafad

@bwplotka thanks for your review :)

assafad avatar Aug 07 '24 08:08 assafad