Skip to content

krr simple fails with history-duration under 24h due to rounding bug in Prometheus query #452

Closed

Description

@dmartzol

Describe the bug
When running krr simple with --history-duration set to a value less than 24 hours (e.g., 1), the tool fails with a Prometheus API error and does not generate recommendations. It appears that durations under 24 hours are being rounded to 0 days, leading to an invalid PromQL query.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy Prometheus and run a workload in a namespace (e.g., default)
  2. Run:
    krr simple --namespace=default --history-duration=1 --prometheus-url=<your_prom_url>
  3. Observe the error:
   prometheus_api_client.exceptions.PrometheusApiClientException: HTTP Status Code 400
(b'{"status":"error","errorType":"bad_data","error":"invalid parameter \\"query\\": 8:27: parse error: duration must be greater than
0"}')

Expected behavior
krr should correctly interpret history durations shorter than 24 hours (e.g., 1, 6) and form valid Prometheus queries.

Screenshots
N/A

Are you interested in contributing a fix for this?
Maybe

Desktop (please complete the following information):

  • Prometheus version: 2.26.0
  • prometheus-community/prometheus helm chart version (14.6.0)
  • Version: krr v1.24.0

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context

  • Using --history-duration=24 works fine.

Let me know if more logs or testing are needed.

Activity

  1. dmartzol commented on Jul 24, 2025

    @dmartzol
    Author

    A PR was just opened to fix this issue: #453

  2. dmartzol commented on Jul 24, 2025

    @dmartzol
    Author

    Issue fixed in record time #453 Thank you @arikalon1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions