Skip to content

docs(vpa): document Prometheus history provider behavior#9724

Open
ulascansenturk wants to merge 1 commit into
kubernetes:masterfrom
ulascansenturk:docs/9228-prometheus-history-provider
Open

docs(vpa): document Prometheus history provider behavior#9724
ulascansenturk wants to merge 1 commit into
kubernetes:masterfrom
ulascansenturk:docs/9228-prometheus-history-provider

Conversation

@ulascansenturk

Copy link
Copy Markdown
Contributor

/area vertical-pod-autoscaler
/kind documentation

What this PR does / why we need it:

Documents two behaviors of the VPA recommender's Prometheus history provider that were previously undocumented (raised in #9228):

  • Pod label loading — how --metric-for-pod-labels and --pod-label-prefix are used to reconstruct Pod labels (including a kube-state-metrics setup), so that historical metrics belonging to already-deleted Pods can be matched to a VPA object. Also notes that the label metric must be a range query.
  • Checkpoints + reachability — that --storage=prometheus disables VPACheckpoint writing entirely, and that history is loaded only once at startup and is silently skipped (logged, not retried) if Prometheus is unreachable.

No code changes; documentation only.

Which issue(s) this PR fixes:

Fixes #9228

Special notes for your reviewer:

Findings originally reported by @plkokanov and @vitanovs in the issue. I verified each against the recommender source (history_provider.go, recommender_controller.go, cluster_feeder.go) before writing.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. area/vertical-pod-autoscaler Issues or PRs related to the Vertical Pod Autoscaler component kind/documentation Categorizes issue or PR as related to documentation. labels Jun 2, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ulascansenturk
Once this PR has been reviewed and has the lgtm label, please assign raywainman for approval. For more information see the Code Review Process.

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

Details 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 k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 2, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @ulascansenturk!

It looks like this is your first PR to kubernetes/autoscaler 🎉. 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/autoscaler 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. 😃

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 2, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @ulascansenturk. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 2, 2026
@ulascansenturk

Copy link
Copy Markdown
Contributor Author

Hi @adrianmoisey, I picked this one up. I noticed your earlier comment about possibly deprecating the Prometheus history provider since nobody is maintaining it right now. Before this gets merged I wanted to check whether improving these docs is still worth it, or whether you'd rather hold off because deprecation is coming soon. Happy either way, I just don't want to add docs for something you're about to remove.

Two other things while I'm here.

While verifying the behavior for this PR I think I ran into a separate bug. initHistoryProvider in recommender_controller.go never copies HistoryCPUMetric and HistoryMemoryMetric into the PrometheusHistoryProviderConfig, so CPUMetricName and MemoryMetricName stay empty and the --history-cpu-metric and --history-memory-metric flags don't actually take effect. I can open a separate issue for that if it's useful.

If the integration mainly needs someone to keep an eye on it, I'm happy to keep working in this area and help out with the open Prometheus issues.

@ulascansenturk ulascansenturk force-pushed the docs/9228-prometheus-history-provider branch from 34ff653 to 1b856cb Compare June 2, 2026 13:02
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 2, 2026
@adrianmoisey

Copy link
Copy Markdown
Member

I noticed your earlier comment about possibly deprecating the Prometheus history provider since nobody is maintaining it right now. Before this gets merged I wanted to check whether improving these docs is still worth it, or whether you'd rather hold off because deprecation is coming soon.

Heya

Thanks for doing this, I think we're good to merge it anyway. We've had no formal discussions around deprecation, so let's work on the assumption that it's sticking around for now.

Comment on lines +255 to +260
> History is loaded **once, at recommender startup**. If Prometheus cannot be reached at
> that time, the error is logged (`Cannot get cluster history`) and the recommender
> continues **without** any historical data — it does not retry, crash, or fall back to
> checkpoints. It will only have the live samples it gathers from the metrics server from
> that point on. If you expect history to be loaded, confirm the recommender can reach
> `--prometheus-address` at startup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of thing is great, thanks!
I didn't know this happened, and I'm assuming users don't know that either.

@adrianmoisey

Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a table of contents at the start of this markdown file that also needs updating

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the TOC with hack/update-toc.sh; both new sections are in it now.

Document two behaviors of the VPA recommender's Prometheus history
provider that were previously undocumented:

- How Pod labels are loaded via the --metric-for-pod-labels and
  --pod-label-prefix flags (including the kube-state-metrics setup),
  so historical metrics from deleted Pods can be matched to a VPA.
- That storage=prometheus disables checkpoint writing, and that
  history is loaded once at startup and silently skipped if Prometheus
  is unreachable.

Signed-off-by: ulascansenturk <ulascansenturk@protonmail.com>
@ulascansenturk ulascansenturk force-pushed the docs/9228-prometheus-history-provider branch from 1b856cb to 600df0a Compare June 4, 2026 20:40
@ulascansenturk

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for clearing up the deprecation question.

I updated the table of contents with mdtoc (hack/update-toc.sh), so the two new sections now show up there. Pushed in the latest commit.

On the separate bug I mentioned (initHistoryProvider not copying HistoryCPUMetric and HistoryMemoryMetric into the config, so --history-cpu-metric and --history-memory-metric are ignored): I will open a dedicated issue for it so it can be tracked and fixed on its own, rather than mixing it into this docs PR.

@adrianmoisey

Copy link
Copy Markdown
Member

Thanks for doing this. I'd like to actually walk through the code to double check this one, before approving it. Since I'm not very familiar with the promtheus parts of VPA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/vertical-pod-autoscaler Issues or PRs related to the Vertical Pod Autoscaler component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the prometheus history provider docs

3 participants