Skip to content

Add support for parsing duration (time.ParseDuration) on custom resource state metrics #2625

@solidDoWant

Description

@solidDoWant

What would you like to be added:

I would like custom state metrics to be able to parse resource duration fields into metric value. For example, they should be able to parse duration: 1h into 3600.

Why is this needed:

Some resources (like cert-manager certificates) store valuable information, such as how long a certificate is valid for, as a duration string.

Describe the solution you'd like

I would like KSM to support parsing these values, similarly to other values, as described here.

Additional context

This is not as trivial as adding a three line if this can be parsed; set the metric to the time.ParseDuration value. Custom resources already support parsing resource quantities such as 250m (i.e. 1/4 of a CPU), which is indistinguishable from the duration 250m (i.e. four hours and ten minutes). The config likely would need to support explicitly stating how a metric should be converted (which is probably desirable anyway).

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

Backlog (stale)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions