kube-state-metrics icon indicating copy to clipboard operation
kube-state-metrics copied to clipboard

feat: Add HorizontalPodAutoscaler created and deletionTimestamp info into metrics

Open IgorIgnatevBolt opened this issue 6 months ago • 6 comments

What this PR does / why we need it:

For some reason, there is no kube_horizontalpodautoscaler_created metric for HPA with creation timestamp information, PR is about to add it as a similarity to other objects.

Also, add kube_horizontalpodautoscaler_deletion_timestamp metrics to catch the deletion timestamp field.

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)

None

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #

IgorIgnatevBolt avatar May 28 '25 10:05 IgorIgnatevBolt

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: IgorIgnatevBolt / name: Igor Ignatev (8fd0417aa2809c2672a765abd78eb27ec2077bf2)

Welcome @IgorIgnatevBolt!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot avatar May 28 '25 10:05 k8s-ci-robot

/triage accepted @rexagod can you PTAL? Thanks

richabanker avatar May 29 '25 16:05 richabanker

Just a small update, also added kube_horizontalpodautoscaler_deletion_timestamp metrics because I need this and fixed the formatting for the table docs

IgorIgnatevBolt avatar Jun 02 '25 11:06 IgorIgnatevBolt

All commits were squashed into one.

IgorIgnatevBolt avatar Jun 03 '25 16:06 IgorIgnatevBolt

Hi, could you share the use case of kube_horizontalpodautoscaler_created?

If only want to the created timestamp, could we use kube_horizontalpodautoscaler_info?

CatherineF-dev avatar Jun 20 '25 00:06 CatherineF-dev

@CatherineF-dev I'd like to detect resources (for example) older than 7 days with special conditions (eq, last apply label exists or any other), and the created timestamp is very useful in expression for this because the date is defined permanently, initially I tried to use kube_horizontalpodautoscaler_info by measuring the presence of this metric in the required period, unfortunately it cannot be used because it very depends on tsdb where metrics collected and if we don't have this metric for all perion that we want to measure (like lower retention perion) then we cannot trigger alert. All other resources collected by kube-state-metrics have a created timestamp, but for some reason not hpa. I would like the ability to work equally with all resources.

IgorIgnatevBolt avatar Jun 20 '25 05:06 IgorIgnatevBolt

Hi @CatherineF-dev, do you need any more information about PR or anything else that can help you move forward?

IgorIgnatevBolt avatar Jul 30 '25 07:07 IgorIgnatevBolt

/hold for further comments. /lgtm

Thanks for your contribution!

mrueg avatar Aug 20 '25 17:08 mrueg

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IgorIgnatevBolt, mrueg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Aug 20 '25 17:08 k8s-ci-robot

/hold cancel

mrueg avatar Aug 24 '25 21:08 mrueg